QmlV8DebuggerClient: Relocate breakpoints

Walk the AST to find probable "breakable" code positions
and relocate breakpoints.

Change-Id: I3033bb85b21436face8265661aa8779c63dcf960
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Aurindam Jana
2012-02-28 17:30:15 +01:00
parent 39164fd08c
commit fd82e54a5b
7 changed files with 307 additions and 69 deletions

View File

@@ -105,8 +105,8 @@ public:
bool includeSource = false, const QVariant filter = QVariant());
void source(int frame = -1, int fromLine = -1, int toLine = -1);
void setBreakpoint(const QString type, const QString target, int line = -1,
int column = -1, bool enabled = true,
void setBreakpoint(const QString type, const QString target,
bool enabled = true,int line = 0, int column = 0,
const QString condition = QString(), int ignoreCount = -1);
void changeBreakpoint(int breakpoint, bool enabled = true,
const QString condition = QString(), int ignoreCount = -1);
@@ -513,7 +513,7 @@ void QmlV8DebuggerClientPrivate::source(int frame, int fromLine, int toLine)
}
void QmlV8DebuggerClientPrivate::setBreakpoint(const QString type, const QString target,
int line, int column, bool enabled,
bool enabled, int line, int column,
const QString condition, int ignoreCount)
{
// { "seq" : <number>,
@@ -542,13 +542,17 @@ void QmlV8DebuggerClientPrivate::setBreakpoint(const QString type, const QString
QScriptValue args = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT)));
args.setProperty(_(TYPE), QScriptValue(type));
args.setProperty(_(TARGET), QScriptValue(target));
if (type == _(SCRIPTREGEXP))
args.setProperty(_(TARGET),
QScriptValue(QFileInfo(target).fileName()));
else
args.setProperty(_(TARGET), QScriptValue(target));
if (line != -1)
args.setProperty(_(LINE), QScriptValue(line));
if (line)
args.setProperty(_(LINE), QScriptValue(line - 1));
if (column != -1)
args.setProperty(_(COLUMN), QScriptValue(column));
if (column)
args.setProperty(_(COLUMN), QScriptValue(column - 1));
args.setProperty(_(ENABLED), QScriptValue(enabled));
@@ -959,7 +963,7 @@ void QmlV8DebuggerClientPrivate::reformatRequest(QByteArray &request)
bool enabled;
rs >> signalHandler >> enabled;
setBreakpoint(_(EVENT), QString::fromUtf8(signalHandler), -1, -1, enabled);
setBreakpoint(_(EVENT), QString::fromUtf8(signalHandler), enabled);
}
}
}
@@ -1050,8 +1054,8 @@ void QmlV8DebuggerClient::executeStepI()
void QmlV8DebuggerClient::executeRunToLine(const ContextData &data)
{
d->setBreakpoint(QString(_(SCRIPTREGEXP)), QFileInfo(data.fileName).fileName(),
data.lineNumber - 1);
d->setBreakpoint(QString(_(SCRIPTREGEXP)), data.fileName,
data.lineNumber);
clearExceptionSelection();
d->continueDebugging(Continue);
}
@@ -1082,7 +1086,9 @@ bool QmlV8DebuggerClient::acceptsBreakpoint(const BreakpointModelId &id)
|| type == BreakpointAtJavaScriptThrow);
}
void QmlV8DebuggerClient::insertBreakpoint(const BreakpointModelId &id)
void QmlV8DebuggerClient::insertBreakpoint(const BreakpointModelId &id,
int adjustedLine,
int adjustedColumn)
{
BreakHandler *handler = d->engine->breakHandler();
const BreakpointParameters &params = handler->breakpointData(id);
@@ -1092,14 +1098,12 @@ void QmlV8DebuggerClient::insertBreakpoint(const BreakpointModelId &id)
d->setExceptionBreak(AllExceptions, params.enabled);
} else if (params.type == BreakpointByFileAndLine) {
d->setBreakpoint(QString(_(SCRIPTREGEXP)),
QFileInfo(params.fileName).fileName(),
params.lineNumber - 1, -1, params.enabled,
d->setBreakpoint(QString(_(SCRIPTREGEXP)), params.fileName,
params.enabled, adjustedLine, adjustedColumn,
QLatin1String(params.condition), params.ignoreCount);
} else if (params.type == BreakpointOnQmlSignalHandler) {
d->setBreakpoint(QString(_(EVENT)), params.functionName,
-1, -1, params.enabled);
d->setBreakpoint(QString(_(EVENT)), params.functionName, params.enabled);
d->engine->breakHandler()->notifyBreakpointInsertOk(id);
}
@@ -1109,20 +1113,17 @@ void QmlV8DebuggerClient::insertBreakpoint(const BreakpointModelId &id)
void QmlV8DebuggerClient::removeBreakpoint(const BreakpointModelId &id)
{
BreakHandler *handler = d->engine->breakHandler();
const BreakpointParameters &params = handler->breakpointData(id);
int breakpoint = d->breakpoints.value(id);
d->breakpoints.remove(id);
if (handler->breakpointData(id).type == BreakpointAtJavaScriptThrow) {
if (params.type == BreakpointAtJavaScriptThrow)
d->setExceptionBreak(AllExceptions);
} else if (handler->breakpointData(id).type == BreakpointOnQmlSignalHandler) {
d->setBreakpoint(QString(_(EVENT)), handler->breakpointData(id).functionName,
-1, -1, false);
} else {
else if (params.type == BreakpointOnQmlSignalHandler)
d->setBreakpoint(QString(_(EVENT)), params.functionName, false);
else
d->clearBreakpoint(breakpoint);
}
}
void QmlV8DebuggerClient::changeBreakpoint(const BreakpointModelId &id)
@@ -1133,9 +1134,8 @@ void QmlV8DebuggerClient::changeBreakpoint(const BreakpointModelId &id)
if (params.type == BreakpointAtJavaScriptThrow) {
d->setExceptionBreak(AllExceptions, params.enabled);
} else if (handler->breakpointData(id).type == BreakpointOnQmlSignalHandler) {
d->setBreakpoint(QString(_(EVENT)), params.functionName,
-1, -1, params.enabled);
} else if (params.type == BreakpointOnQmlSignalHandler) {
d->setBreakpoint(QString(_(EVENT)), params.functionName, params.enabled);
} else {
int breakpoint = d->breakpoints.value(id);
@@ -1311,8 +1311,15 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
BreakpointModelId id = d->breakpointsSync.take(seq);
d->breakpoints.insert(id, index);
if (d->engine->breakHandler()->state(id) != BreakpointInserted)
d->engine->breakHandler()->notifyBreakpointInsertOk(id);
BreakHandler *handler = d->engine->breakHandler();
if (handler->state(id) != BreakpointInserted) {
BreakpointResponse br = handler->response(id);
br.lineNumber = breakpointData.value(_("line")
).toInt() + 1;
handler->setResponse(id, br);
handler->notifyBreakpointInsertOk(id);
}
} else {
d->breakpointsTemp.append(index);
@@ -1450,14 +1457,13 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
const BreakpointParameters &params = handler->breakpointData(internalId);
d->clearBreakpoint(v8Id);
d->setBreakpoint(
QString(_(SCRIPTREGEXP)),
QFileInfo(params.fileName).fileName(),
params.lineNumber - 1,
newColumn,
params.enabled,
QString(params.condition),
params.ignoreCount);
d->setBreakpoint(QString(_(SCRIPTREGEXP)),
params.fileName,
params.enabled,
params.lineNumber,
newColumn,
QString(params.condition),
params.ignoreCount);
d->breakpointsSync.insert(d->sequence, internalId);
}
}