QmlV8DebuggerClient: Refactored code

Change List:
a) Refactored code: Shifted JSON message creation to
QmlV8DebuggerClientPrivate.
b) QScriptEngine is used for JSON instead of JsonValue and
JsonInputStream.
c) Locals Window displays all variables accessible in the current
context.

Change-Id: I82e73f6c57482408f5fc501c908aa96297d3d754
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Aurindam Jana
2011-10-26 10:02:37 +02:00
parent e9620aa3b1
commit f3c047a33c
10 changed files with 1474 additions and 580 deletions

View File

@@ -1,2 +1,2 @@
INCLUDEPATH *= $$PWD/../../shared/symbianutils INCLUDEPATH *= $$PWD/../../shared/symbianutils $$PWD/../../shared/json
LIBS *= -l$$qtLibraryName(symbianutils) LIBS *= -l$$qtLibraryName(symbianutils)

View File

@@ -1,6 +1,6 @@
TEMPLATE = lib TEMPLATE = lib
CONFIG+=dll CONFIG+=dll
TARGET = symbianutils TARGET = symbianutils
DEFINES += SYMBIANUTILS_BUILD_LIB DEFINES += SYMBIANUTILS_BUILD_LIB JSON_BUILD_LIB
include(../../qtcreatorlibrary.pri) include(../../qtcreatorlibrary.pri)
include(../../shared/symbianutils/symbianutils.pri) include(../../shared/symbianutils/symbianutils.pri)

View File

@@ -1,6 +1,4 @@
include($$PWD/../../../libs/qmljsdebugclient/qmljsdebugclient.pri) include($$PWD/../../../libs/qmljsdebugclient/qmljsdebugclient.pri)
include($$PWD/../../../shared/json/json.pri)
DEFINES += JSON_INCLUDE_PRI
HEADERS += \ HEADERS += \
$$PWD/qmlengine.h \ $$PWD/qmlengine.h \
@@ -11,7 +9,8 @@ HEADERS += \
$$PWD/qmljsscriptconsole.h \ $$PWD/qmljsscriptconsole.h \
$$PWD/qscriptdebuggerclient.h \ $$PWD/qscriptdebuggerclient.h \
$$PWD/qmlv8debuggerclient.h \ $$PWD/qmlv8debuggerclient.h \
$$PWD/interactiveinterpreter.h $$PWD/interactiveinterpreter.h \
$$PWD/qmlv8debuggerclientconstants.h
SOURCES += \ SOURCES += \
$$PWD/qmlengine.cpp \ $$PWD/qmlengine.cpp \

View File

@@ -69,12 +69,12 @@ public:
virtual void insertBreakpoint(const BreakpointModelId &id) = 0; virtual void insertBreakpoint(const BreakpointModelId &id) = 0;
virtual void removeBreakpoint(const BreakpointModelId &id) = 0; virtual void removeBreakpoint(const BreakpointModelId &id) = 0;
virtual void changeBreakpoint(const BreakpointModelId &id) = 0; virtual void changeBreakpoint(const BreakpointModelId &id) = 0;
virtual void updateBreakpoints() = 0; virtual void synchronizeBreakpoints() = 0;
virtual void assignValueInDebugger(const QByteArray expr, const quint64 &id, virtual void assignValueInDebugger(const QByteArray expr, const quint64 &id,
const QString &property, const QString &value) = 0; const QString &property, const QString &value) = 0;
virtual void updateWatchData(const WatchData *data) = 0; virtual void updateWatchData(const WatchData &data) = 0;
virtual void executeDebuggerCommand(const QString &command) = 0; virtual void executeDebuggerCommand(const QString &command) = 0;
virtual void synchronizeWatchers(const QStringList &watchers) = 0; virtual void synchronizeWatchers(const QStringList &watchers) = 0;

View File

@@ -629,10 +629,10 @@ void QmlEngine::attemptBreakpointSynchronization()
DebuggerEngine::attemptBreakpointSynchronization(); DebuggerEngine::attemptBreakpointSynchronization();
if (d->m_adapter.activeDebuggerClient()) { if (d->m_adapter.activeDebuggerClient()) {
d->m_adapter.activeDebuggerClient()->updateBreakpoints(); d->m_adapter.activeDebuggerClient()->synchronizeBreakpoints();
} else { } else {
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) { foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
client->updateBreakpoints(); client->synchronizeBreakpoints();
} }
} }
} }
@@ -715,7 +715,7 @@ void QmlEngine::updateWatchData(const WatchData &data,
if (data.isValueNeeded()) { if (data.isValueNeeded()) {
logMessage(LogSend, QString("%1 %2 %3").arg(QString("EXEC"), QString(data.iname), logMessage(LogSend, QString("%1 %2 %3").arg(QString("EXEC"), QString(data.iname),
QString(data.name))); QString(data.name)));
d->m_adapter.activeDebuggerClient()->updateWatchData(&data); d->m_adapter.activeDebuggerClient()->updateWatchData(data);
} }
if (data.isChildrenNeeded() if (data.isChildrenNeeded()
&& watchHandler()->isExpandedIName(data.iname)) { && watchHandler()->isExpandedIName(data.iname)) {

File diff suppressed because it is too large Load Diff

View File

@@ -36,8 +36,6 @@
#include "qmldebuggerclient.h" #include "qmldebuggerclient.h"
#include "stackframe.h" #include "stackframe.h"
#include "watchdata.h" #include "watchdata.h"
#include "qmlengine.h"
#include "json.h"
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
@@ -84,12 +82,12 @@ public:
void insertBreakpoint(const BreakpointModelId &id); void insertBreakpoint(const BreakpointModelId &id);
void removeBreakpoint(const BreakpointModelId &id); void removeBreakpoint(const BreakpointModelId &id);
void changeBreakpoint(const BreakpointModelId &id); void changeBreakpoint(const BreakpointModelId &id);
void updateBreakpoints(); void synchronizeBreakpoints();
void assignValueInDebugger(const QByteArray expr, const quint64 &id, void assignValueInDebugger(const QByteArray expr, const quint64 &id,
const QString &property, const QString &value); const QString &property, const QString &value);
void updateWatchData(const WatchData *data); void updateWatchData(const WatchData &data);
void executeDebuggerCommand(const QString &command); void executeDebuggerCommand(const QString &command);
void synchronizeWatchers(const QStringList &watchers); void synchronizeWatchers(const QStringList &watchers);
@@ -98,30 +96,27 @@ public:
void setEngine(QmlEngine *engine); void setEngine(QmlEngine *engine);
signals:
void notifyDebuggerStopped();
protected: protected:
void messageReceived(const QByteArray &data); void messageReceived(const QByteArray &data);
private: private:
void listBreakpoints(); void updateStack(const QVariant &bodyVal, const QVariant &refsVal);
void backtrace(); StackFrame createStackFrame(const QVariant &bodyVal, const QVariant &refsVal);
void setStackFrames(const QByteArray &message); void updateLocals(const QVariant &localsVal, const QVariant &refsVal);
void setLocals(int frameIndex);
void setExpression(const QByteArray &message);
void updateBreakpoints(const QByteArray &message);
void expandLocal(const QByteArray &message);
void setPropertyValue(const Json::JsonValue &refs, const Json::JsonValue &property, const QByteArray &prepend);
int indexInRef(const Json::JsonValue &refs, int refIndex);
QByteArray packMessage(const QByteArray &message);
void breakOnException(Exceptions exceptionsType, bool enabled); void updateEvaluationResult(int sequence, const QVariant &bodyVal,
void storeExceptionInformation(const QByteArray &message); const QVariant &refsVal);
void handleException(); void updateBreakpoints(const QVariant &bodyVal);
QVariant valueFromRef(int handle, const QVariant &refsVal);
void expandLocal(const QVariant &bodyVal, const QVariant &refsVal);
void highlightExceptionCode(int lineNumber, const QString &filePath,
const QString &errorMessage);
void clearExceptionSelection(); void clearExceptionSelection();
void continueDebugging(StepAction type); void reset();
private: private:
QmlV8DebuggerClientPrivate *d; QmlV8DebuggerClientPrivate *d;

View File

@@ -0,0 +1,121 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#ifndef QMLV8DEBUGGERCLIENTCONSTANTS_H
#define QMLV8DEBUGGERCLIENTCONSTANTS_H
namespace Debugger {
namespace Internal {
const char V8DEBUG[] = "V8DEBUG";
const char SEQ[] = "seq";
const char TYPE[] = "type";
const char COMMAND[] = "command";
const char ARGUMENTS[] = "arguments";
const char STEPACTION[] = "stepaction";
const char STEPCOUNT[] = "stepcount";
const char EXPRESSION[] = "expression";
const char FRAME[] = "frame";
const char GLOBAL[] = "global";
const char DISABLE_BREAK[] = "disable_break";
const char ADDITIONAL_CONTEXT[] = "additional_context";
const char HANDLES[] = "handles";
const char INCLUDESOURCE[] = "includeSource";
const char FROMFRAME[] = "fromFrame";
const char TOFRAME[] = "toFrame";
const char BOTTOM[] = "bottom";
const char NUMBER[] = "number";
const char FRAMENUMBER[] = "frameNumber";
const char TYPES[] = "types";
const char IDS[] = "ids";
const char FILTER[] = "filter";
const char FROMLINE[] = "fromLine";
const char TOLINE[] = "toLine";
const char TARGET[] = "target";
const char LINE[] = "line";
const char COLUMN[] = "column";
const char ENABLED[] = "enabled";
const char CONDITION[] = "condition";
const char IGNORECOUNT[] = "ignoreCount";
const char BREAKPOINT[] = "breakpoint";
const char FLAGS[] = "flags";
const char CONTINEDEBUGGING[] = "continue";
const char EVALUATE[] = "evaluate";
const char LOOKUP[] = "lookup";
const char BACKTRACE[] = "backtrace";
const char SCOPE[] = "scope";
const char SCOPES[] = "scopes";
const char SCRIPTS[] = "scripts";
const char SOURCE[] = "source";
const char SETBREAKPOINT[] = "setbreakpoint";
const char CHANGEBREAKPOINT[] = "changebreakpoint";
const char CLEARBREAKPOINT[] = "clearbreakpoint";
const char SETEXCEPTIONBREAK[] = "setexceptionbreak";
const char V8FLAGS[] = "v8flags";
const char VERSION[] = "version";
const char DISCONNECT[] = "disconnect";
const char LISTBREAKPOINTS[] = "listbreakpoints";
const char GARBAGECOLLECTOR[] = "gc";
//const char PROFILE[] = "profile";
const char CONNECT[] = "connect";
const char INTERRUPT[] = "interrupt";
const char REQUEST[] = "request";
const char IN[] = "in";
const char NEXT[] = "next";
const char OUT[] = "out";
const char FUNCTION[] = "function";
const char SCRIPT[] = "script";
const char EVENT[] = "event";
const char ALL[] = "all";
const char UNCAUGHT[] = "uncaught";
//const char PAUSE[] = "pause";
//const char RESUME[] = "resume";
const char HANDLE[] = "handle";
const char REF[] = "ref";
const char REFS[] = "refs";
const char BODY[] = "body";
const char NAME[] = "name";
const char VALUE[] = "value";
const char OBJECT[] = "{}";
const char ARRAY[] = "[]";
} //Internal
} //Debugger
#endif // QMLV8DEBUGGERCLIENTCONSTANTS_H

View File

@@ -240,7 +240,7 @@ void QScriptDebuggerClient::changeBreakpoint(const BreakpointModelId &/*id*/)
{ {
} }
void QScriptDebuggerClient::updateBreakpoints() void QScriptDebuggerClient::synchronizeBreakpoints()
{ {
QByteArray reply; QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly); QDataStream rs(&reply, QIODevice::WriteOnly);
@@ -261,13 +261,13 @@ void QScriptDebuggerClient::assignValueInDebugger(const QByteArray expr, const q
sendMessage(reply); sendMessage(reply);
} }
void QScriptDebuggerClient::updateWatchData(const WatchData *data) void QScriptDebuggerClient::updateWatchData(const WatchData &data)
{ {
QByteArray reply; QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly); QDataStream rs(&reply, QIODevice::WriteOnly);
QByteArray cmd = "EXEC"; QByteArray cmd = "EXEC";
rs << cmd; rs << cmd;
rs << data->iname << data->name; rs << data.iname << data.name;
sendMessage(reply); sendMessage(reply);
} }

View File

@@ -67,12 +67,12 @@ public:
void insertBreakpoint(const BreakpointModelId &id); void insertBreakpoint(const BreakpointModelId &id);
void removeBreakpoint(const BreakpointModelId &id); void removeBreakpoint(const BreakpointModelId &id);
void changeBreakpoint(const BreakpointModelId &id); void changeBreakpoint(const BreakpointModelId &id);
void updateBreakpoints(); void synchronizeBreakpoints();
void assignValueInDebugger(const QByteArray expr, const quint64 &id, void assignValueInDebugger(const QByteArray expr, const quint64 &id,
const QString &property, const QString &value); const QString &property, const QString &value);
void updateWatchData(const WatchData *data); void updateWatchData(const WatchData &data);
void executeDebuggerCommand(const QString &command); void executeDebuggerCommand(const QString &command);
void synchronizeWatchers(const QStringList &watchers); void synchronizeWatchers(const QStringList &watchers);
@@ -81,9 +81,6 @@ public:
void setEngine(QmlEngine *engine); void setEngine(QmlEngine *engine);
signals:
void notifyDebuggerStopped();
protected: protected:
void messageReceived(const QByteArray &data); void messageReceived(const QByteArray &data);