Commit 32ef6c56 authored by Aurindam Jana's avatar Aurindam Jana
Browse files

V8DebuggerClient: Enable breakpoints on Exceptions

Previously break on exceptions was always enabled. Now, the user
can add a breakpoint on Javascript Exceptions from the breakpoint
window in the debugger.

Change-Id: Ia9ee813d2fccf89b607fe1dcbad47b4084155a48
Reviewed-on: http://codereview.qt-project.org/6348


Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent f1db83be
......@@ -124,6 +124,8 @@ static QString typeToString(BreakpointType type)
return BreakHandler::tr("Watchpoint at Expression");
case BreakpointOnQmlSignalHandler:
return BreakHandler::tr("Breakpoint on QML Signal Handler");
case BreakpointAtJavaScriptThrow:
return BreakHandler::tr("Breakpoint at JavaScript throw");
case UnknownType:
break;
}
......
......@@ -277,6 +277,7 @@ QString BreakpointParameters::toString() const
case BreakpointAtExec:
//case BreakpointAtVFork:
case BreakpointAtSysCall:
case BreakpointAtJavaScriptThrow:
case UnknownType:
break;
}
......
......@@ -140,7 +140,8 @@ enum BreakpointType
BreakpointAtSysCall,
WatchpointAtAddress,
WatchpointAtExpression,
BreakpointOnQmlSignalHandler
BreakpointOnQmlSignalHandler,
BreakpointAtJavaScriptThrow
};
//! \enum Debugger::Internal::BreakpointState
......
......@@ -120,9 +120,10 @@ BreakpointDialog::BreakpointDialog(unsigned engineCapabilities, QWidget *parent)
<< tr("Break when a system call is executed")
<< tr("Break on data access at fixed address")
<< tr("Break on data access at address given by expression")
<< tr("Break on QML signal handler");
<< tr("Break on QML signal handler")
<< tr("Break when JavaScript exception is thrown");
QTC_ASSERT(types.size() == BreakpointOnQmlSignalHandler, return; )
QTC_ASSERT(types.size() == BreakpointAtJavaScriptThrow, return; )
m_ui.comboBoxType->addItems(types);
m_ui.pathChooserFileName->setExpectedKind(Utils::PathChooser::File);
connect(m_ui.comboBoxType, SIGNAL(activated(int)), SLOT(typeChanged(int)));
......@@ -352,6 +353,7 @@ void BreakpointDialog::typeChanged(int)
case BreakpointAtExec:
//case BreakpointAtVFork:
case BreakpointAtSysCall:
case BreakpointAtJavaScriptThrow:
break;
case BreakpointByAddress:
case WatchpointAtAddress:
......@@ -384,6 +386,7 @@ void BreakpointDialog::typeChanged(int)
case BreakpointAtExec:
//case BreakpointAtVFork:
case BreakpointAtSysCall:
case BreakpointAtJavaScriptThrow:
clearOtherParts(AllConditionParts|ModulePart|TracePointPart);
setPartsEnabled(AllConditionParts|TracePointPart);
break;
......
......@@ -2551,6 +2551,7 @@ bool CdbEngine::acceptsBreakpoint(BreakpointModelId id) const
case WatchpointAtExpression:
case BreakpointAtSysCall:
case BreakpointOnQmlSignalHandler:
case BreakpointAtJavaScriptThrow:
return false;
case WatchpointAtAddress:
case BreakpointByFileAndLine:
......
......@@ -108,6 +108,7 @@ static BreakpointParameters fixWinMSVCBreakpoint(const BreakpointParameters &p)
case BreakpointAtSysCall:
case WatchpointAtAddress:
case BreakpointOnQmlSignalHandler:
case BreakpointAtJavaScriptThrow:
break;
case BreakpointAtExec: { // Emulate by breaking on CreateProcessW().
BreakpointParameters rc(BreakpointByFunction);
......@@ -165,6 +166,7 @@ QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn,
case BreakpointAtThrow:
case BreakpointAtMain:
case BreakpointOnQmlSignalHandler:
case BreakpointAtJavaScriptThrow:
QTC_ASSERT(false, return QByteArray(); )
break;
case BreakpointByAddress:
......
......@@ -1583,6 +1583,11 @@ void DebuggerEngine::showStoppedByExceptionMessageBox(const QString &description
bool DebuggerEngine::isCppBreakpoint(const BreakpointParameters &p)
{
//Qml specific breakpoint types
if (p.type == BreakpointAtJavaScriptThrow
|| p.type == BreakpointOnQmlSignalHandler)
return false;
// Qml is currently only file
if (p.type != BreakpointByFileAndLine)
return true;
......
......@@ -279,10 +279,6 @@ void QmlV8DebuggerClient::interruptInferior()
void QmlV8DebuggerClient::startSession()
{
//Set up Exception Handling first
//TODO: For now we enable breaks for all exceptions
breakOnException(AllExceptions, true);
QByteArray request;
JsonInputStream(request) << '{' << INITIALPARAMS ;
......@@ -315,28 +311,39 @@ void QmlV8DebuggerClient::activateFrame(int index)
bool QmlV8DebuggerClient::acceptsBreakpoint(const BreakpointModelId &id)
{
BreakpointType type = d->engine->breakHandler()->breakpointData(id).type;
return (type == BreakpointOnQmlSignalHandler || type == BreakpointByFunction);
return (type == BreakpointOnQmlSignalHandler
|| type == BreakpointByFunction
|| type == BreakpointAtJavaScriptThrow);
}
void QmlV8DebuggerClient::insertBreakpoint(const BreakpointModelId &id)
{
BreakHandler *handler = d->engine->breakHandler();
const BreakpointParameters &params = handler->breakpointData(id);
if (params.type == BreakpointAtJavaScriptThrow) {
handler->notifyBreakpointInsertOk(id);
return breakOnException(AllExceptions, params.enabled);
}
QByteArray request;
JsonInputStream(request) << '{' << INITIALPARAMS ;
JsonInputStream(request) << ',' << "command" << ':' << "setbreakpoint";
JsonInputStream(request) << ',' << "arguments" << ':' << '{';
if (handler->breakpointData(id).type == BreakpointByFileAndLine) {
if (params.type == BreakpointByFileAndLine) {
JsonInputStream(request) << "type" << ':' << "script";
JsonInputStream(request) << ',' << "target" << ':' << QFileInfo(handler->fileName(id)).fileName().toUtf8();
JsonInputStream(request) << ',' << "line" << ':' << handler->lineNumber(id) - 1;
} else if (handler->breakpointData(id).type == BreakpointByFunction) {
JsonInputStream(request) << ',' << "target" << ':' << QFileInfo(params.fileName).fileName().toUtf8();
JsonInputStream(request) << ',' << "line" << ':' << params.lineNumber - 1;
} else if (params.type == BreakpointByFunction) {
JsonInputStream(request) << "type" << ':' << "function";
JsonInputStream(request) << ',' << "target" << ':' << handler->functionName(id).toUtf8();
} else if (handler->breakpointData(id).type == BreakpointOnQmlSignalHandler) {
JsonInputStream(request) << ',' << "target" << ':' << params.functionName.toUtf8();
} else if (params.type == BreakpointOnQmlSignalHandler) {
JsonInputStream(request) << "type" << ':' << "event";
JsonInputStream(request) << ',' << "target" << ':' << handler->functionName(id).toUtf8();
JsonInputStream(request) << ',' << "target" << ':' << params.functionName.toUtf8();
}
JsonInputStream(request) << ',' << "enabled" << ':' << params.enabled;
JsonInputStream(request) << '}';
JsonInputStream(request) << '}';
......@@ -346,6 +353,12 @@ void QmlV8DebuggerClient::insertBreakpoint(const BreakpointModelId &id)
void QmlV8DebuggerClient::removeBreakpoint(const BreakpointModelId &id)
{
BreakHandler *handler = d->engine->breakHandler();
if (handler->breakpointData(id).type == BreakpointAtJavaScriptThrow) {
return breakOnException(AllExceptions, false);
}
int breakpoint = d->breakpoints.value(id);
d->breakpoints.remove(id);
......@@ -363,8 +376,14 @@ void QmlV8DebuggerClient::removeBreakpoint(const BreakpointModelId &id)
sendMessage(packMessage(request));
}
void QmlV8DebuggerClient::changeBreakpoint(const BreakpointModelId &/*id*/)
void QmlV8DebuggerClient::changeBreakpoint(const BreakpointModelId &id)
{
BreakHandler *handler = d->engine->breakHandler();
const BreakpointParameters &params = handler->breakpointData(id);
if (params.type == BreakpointAtJavaScriptThrow) {
return breakOnException(AllExceptions, params.enabled);
}
}
void QmlV8DebuggerClient::updateBreakpoints()
......@@ -482,8 +501,8 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
if (type == "response") {
if (!value.findChild("success").toVariant().toBool()) {
//TODO:: Error
qDebug() << Q_FUNC_INFO << value.toString(true,2);
//TODO:: have to handle this case for each command
d->engine->logMessage(QmlEngine::LogReceive, QString("V8 Response Error: %1").arg(QString(value.toString(true,2))));
return;
}
......@@ -514,8 +533,7 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
backtrace();
} else {
//TODO::
//qDebug() << Q_FUNC_INFO << value.toString(true,2);
d->engine->logMessage(QmlEngine::LogReceive, value.toString(true,2));
}
} else if (type == "event") {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment