diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2010-07-08 11:40:29 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2010-07-08 11:40:29 (GMT) |
commit | 627d62c17b29cf5a99252aeff965b4f848d4d171 (patch) | |
tree | cd855b8dffcb48a40a776598da491090f55d33a7 /tools/runonphone/symbianutils/tcftrkdevice.h | |
parent | 4f8ec542b123399574d2e509fa99f4bd66a34e25 (diff) | |
download | Qt-627d62c17b29cf5a99252aeff965b4f848d4d171.zip Qt-627d62c17b29cf5a99252aeff965b4f848d4d171.tar.gz Qt-627d62c17b29cf5a99252aeff965b4f848d4d171.tar.bz2 |
Merge tools/runonphone/symbianutils from qtcreator src/shared/symbianutils
commit bca434a706c6eb28fe713ea10c857c35e3835f62
Author: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Wed Jul 7 14:00:54 2010 +0200
Trk/Launcher: Add infrastructure for reporting crashes.
currently used for runonphone only.
Initial-patch-by: Shane Kearns <shane.kearns@accenture.com>
commit 9bb67101c5daa42f879f2fcf884277c5fd23bed4
Author: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Mon Jul 5 17:14:45 2010 +0200
Trk[TCF]: Proper exit handling
commit 52b33a7503866654077b572c1f8005dfc19ed5a6
Author: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Wed Jun 30 17:14:57 2010 +0200
Debugger[Trk]: Prepare thread handling.
Store threads and cache registers per thread in Snapshot.
As Trk does not generate Thread creation/deletion events.
try to add threads on the fly if a stop in a new thread id is reported.
Remove them in continue. Continue all threads in classic Trk.
Pass on state (crash reason) to ThreadData and model.
Factor out common code of both adapters to Snapshot/Symbian classes.
commit 66e01e881d7cb865338a6a7949f9a085883387c9
Author: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Mon Jun 28 16:32:53 2010 +0200
Debugger[TCF-Trk]: Send RemoveExecutables command.
commit beba423a16fd0e6e836cd8c26ca30e5167ca56db
Author: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Fri Jun 25 15:06:30 2010 +0200
Debugger[Trk]: Added TCF experimental adapter.
Added adapter to work with TCF over WLAN.
Factor out common code for Symbian from TrkAdapter.
Improve message logging in TrkGdbAdapter, some cleanup.
Added new TcfTrkGdbAdapter based on TcfTrkDevice
in symbianutils based on JSON, using QTcpSocket.
To be started via special @tcf@ argument.
Rubber-stamped-by: hjk
create mode 100644 src/shared/symbianutils/json.cpp
create mode 100644 src/shared/symbianutils/json.h
create mode 100644 src/shared/symbianutils/tcftrkdevice.cpp
create mode 100644 src/shared/symbianutils/tcftrkdevice.h
create mode 100644 src/shared/symbianutils/tcftrkmessage.cpp
create mode 100644 src/shared/symbianutils/tcftrkmessage.h
commit 5d5f647f3d9b7a28c605af41a23819b7a24a5814
Author: Tobias Hunger <tobias.hunger@nokia.com>
Date: Thu Jun 10 13:12:12 2010 +0200
Fix preprocessor directives
* The standard says all preprocessor directives have to start at column 0.
commit 6972715a397e8e9a495191a459dcf6db4b75f7a7
Author: Robert Loehning <robert.loehning@nokia.com>
Date: Mon Jun 7 14:58:24 2010 +0200
Symbian/trk: Fixed handling of partial frames
Initial-patch-by: Shane Kearns <shane.kearns@accenture.com>
commit a47e06eec946dd2dbb986e614a3c292b91182b95
Author: Robert Loehning <robert.loehning@nokia.com>
Date: Mon Jun 7 14:47:40 2010 +0200
Symbian/trk: Don't try to dereference references
commit b6ee94fb5ff652ba22b272a064c2be541b4bcf56
Author: Robert Loehning <robert.loehning@nokia.com>
Date: Mon Jun 7 11:50:38 2010 +0200
Symbian/Trk: Don't try to download a file without respective flag set.
Task-number: QTCREATORBUG-1567
Reviewed-by: Friedemann Kleint
Diffstat (limited to 'tools/runonphone/symbianutils/tcftrkdevice.h')
-rw-r--r-- | tools/runonphone/symbianutils/tcftrkdevice.h | 283 |
1 files changed, 283 insertions, 0 deletions
diff --git a/tools/runonphone/symbianutils/tcftrkdevice.h b/tools/runonphone/symbianutils/tcftrkdevice.h new file mode 100644 index 0000000..bb4c184 --- /dev/null +++ b/tools/runonphone/symbianutils/tcftrkdevice.h @@ -0,0 +1,283 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef TCFTRKENGINE_H +#define TCFTRKENGINE_H + +#include "symbianutils_global.h" +#include "tcftrkmessage.h" +#include "callback.h" +#include "json.h" + +#include <QtCore/QObject> +#include <QtCore/QSharedPointer> +#include <QtCore/QVector> +#include <QtCore/QVariant> +#include <QtCore/QStringList> + +QT_BEGIN_NAMESPACE +class QIODevice; +class QTextStream; +QT_END_NAMESPACE + +namespace tcftrk { + +struct TcfTrkDevicePrivate; +struct Breakpoint; + +/* Command error handling in TCF: + * 1) 'Severe' errors (JSON format, parameter format): Trk emits a + * nonstandard message (\3\2 error paramaters) and closes the connection. + * 2) Protocol errors: 'N' without error message is returned. + * 3) Errors in command execution: 'R' with a TCF error hash is returned + * (see TcfTrkCommandError). */ + +/* Error code return in 'R' reply to command + * (see top of 'Services' documentation). */ +struct SYMBIANUTILS_EXPORT TcfTrkCommandError { + TcfTrkCommandError(); + void clear(); + operator bool() const { return timeMS != 0; } + QString toString() const; + void write(QTextStream &str) const; + bool parse(const QVector<JsonValue> &values); + + quint64 timeMS; // Since 1.1.1970 + int code; + QByteArray format; // message + // 'Alternative' meaning, like altOrg="POSIX"/altCode=<some errno> + QByteArray alternativeOrganization; + int alternativeCode; +}; + +/* Answer to a Tcf command passed to the callback. */ +struct SYMBIANUTILS_EXPORT TcfTrkCommandResult { + enum Type { + SuccessReply, // 'R' and no error -> all happy. + CommandErrorReply, // 'R' with TcfTrkCommandError received + ProgressReply, // 'P', progress indicator + FailReply // 'N' Protocol NAK, severe error + }; + + explicit TcfTrkCommandResult(Type t = SuccessReply); + explicit TcfTrkCommandResult(char typeChar, Services service, + const QByteArray &request, + const QVector<JsonValue> &values, + const QVariant &cookie); + + QString toString() const; + QString errorString() const; + operator bool() const { return type == SuccessReply || type == ProgressReply; } + + Type type; + Services service; + QByteArray request; + TcfTrkCommandError commandError; + QVector<JsonValue> values; + QVariant cookie; +}; + +typedef trk::Callback<const TcfTrkCommandResult &> TcfTrkCallback; + +/* TcfTrkDevice: TCF communication helper using an asynchronous QIODevice + * implementing the TCF protocol according to: +http://dev.eclipse.org/svnroot/dsdp/org.eclipse.tm.tcf/trunk/docs/TCF%20Specification.html +http://dev.eclipse.org/svnroot/dsdp/org.eclipse.tm.tcf/trunk/docs/TCF%20Services.html + * Commands can be sent along with callbacks that are passed a + * TcfTrkCommandResult and an opaque QVariant cookie. In addition, events are emitted. +*/ + +class SYMBIANUTILS_EXPORT TcfTrkDevice : public QObject +{ + Q_PROPERTY(unsigned verbose READ verbose WRITE setVerbose) + Q_OBJECT +public: + enum MessageType { MessageWithReply, + MessageWithoutReply, /* Non-standard: "Settings:set" command does not reply */ + NoopMessage }; + + typedef QSharedPointer<QIODevice> IODevicePtr; + + explicit TcfTrkDevice(QObject *parent = 0); + virtual ~TcfTrkDevice(); + + unsigned verbose() const; + + // Mapping of register names for indices + QVector<QByteArray> registerNames() const; + void setRegisterNames(const QVector<QByteArray>& n); + + IODevicePtr device() const; + IODevicePtr takeDevice(); + void setDevice(const IODevicePtr &dp); + + void sendTcfTrkMessage(MessageType mt, Services service, + const char *command, + const char *commandParameters, int commandParametersLength, + const TcfTrkCallback &callBack = TcfTrkCallback(), + const QVariant &cookie = QVariant()); + + void sendTcfTrkMessage(MessageType mt, Services service, const char *command, + const QByteArray &commandParameters, + const TcfTrkCallback &callBack = TcfTrkCallback(), + const QVariant &cookie = QVariant()); + + // Convenience messages: Start a process + void sendProcessStartCommand(const TcfTrkCallback &callBack, + const QString &binary, + unsigned uid, + QStringList arguments = QStringList(), + QString workingDirectory = QString(), + bool debugControl = true, + const QStringList &additionalLibraries = QStringList(), + const QVariant &cookie = QVariant()); + + // Preferred over Processes:Terminate by TCF TRK. + void sendRunControlTerminateCommand(const TcfTrkCallback &callBack, + const QByteArray &id, + const QVariant &cookie = QVariant()); + + void sendProcessTerminateCommand(const TcfTrkCallback &callBack, + const QByteArray &id, + const QVariant &cookie = QVariant()); + + // Non-standard: Remove executable from settings. + // Probably needs to be called after stopping. This command has no response. + void sendSettingsRemoveExecutableCommand(const QString &binaryIn, + unsigned uid, + const QStringList &additionalLibraries = QStringList(), + const QVariant &cookie = QVariant()); + + void sendRunControlSuspendCommand(const TcfTrkCallback &callBack, + const QByteArray &id, + const QVariant &cookie = QVariant()); + + // Resume / Step (see RunControlResumeMode). + void sendRunControlResumeCommand(const TcfTrkCallback &callBack, + const QByteArray &id, + RunControlResumeMode mode, + unsigned count /* = 1, currently ignored. */, + quint64 rangeStart, quint64 rangeEnd, + const QVariant &cookie = QVariant()); + + // Convenience to resume a suspended process + void sendRunControlResumeCommand(const TcfTrkCallback &callBack, + const QByteArray &id, + const QVariant &cookie = QVariant()); + + void sendBreakpointsAddCommand(const TcfTrkCallback &callBack, + const Breakpoint &b, + const QVariant &cookie = QVariant()); + + void sendBreakpointsRemoveCommand(const TcfTrkCallback &callBack, + const QByteArray &id, + const QVariant &cookie = QVariant()); + + void sendBreakpointsRemoveCommand(const TcfTrkCallback &callBack, + const QVector<QByteArray> &id, + const QVariant &cookie = QVariant()); + + void sendBreakpointsEnableCommand(const TcfTrkCallback &callBack, + const QByteArray &id, + bool enable, + const QVariant &cookie = QVariant()); + + void sendBreakpointsEnableCommand(const TcfTrkCallback &callBack, + const QVector<QByteArray> &id, + bool enable, + const QVariant &cookie = QVariant()); + + + void sendMemoryGetCommand(const TcfTrkCallback &callBack, + const QByteArray &contextId, + quint64 start, quint64 size, + const QVariant &cookie = QVariant()); + + void sendMemorySetCommand(const TcfTrkCallback &callBack, + const QByteArray &contextId, + quint64 start, const QByteArray& data, + const QVariant &cookie = QVariant()); + + // Reply is an array of hexvalues + void sendRegistersGetMCommand(const TcfTrkCallback &callBack, + const QByteArray &contextId, + const QVector<QByteArray> &ids, + const QVariant &cookie = QVariant()); + + // Convenience to get a range of register "R0" .. "R<n>". + // Cookie will be an int containing "start". + void sendRegistersGetMRangeCommand(const TcfTrkCallback &callBack, + const QByteArray &contextId, + unsigned start, unsigned count); + + // Set register + void sendRegistersSetCommand(const TcfTrkCallback &callBack, + const QByteArray &contextId, + const QByteArray &ids, + unsigned value, + const QVariant &cookie = QVariant()); + // Set register + void sendRegistersSetCommand(const TcfTrkCallback &callBack, + const QByteArray &contextId, + unsigned registerNumber, + unsigned value, + const QVariant &cookie = QVariant()); + + static QByteArray parseMemoryGet(const TcfTrkCommandResult &r); + +signals: + void genericTcfEvent(int service, const QByteArray &name, const QVector<tcftrk::JsonValue> &value); + void tcfEvent(const tcftrk::TcfTrkEvent &knownEvent); + + void logMessage(const QString &); + void error(const QString &); + +public slots: + void setVerbose(unsigned v); + +private slots: + void slotDeviceError(); + void slotDeviceSocketStateChanged(); + void slotDeviceReadyRead(); + +private: + bool checkOpen(); + void checkSendQueue(); + void writeMessage(QByteArray data); + void emitLogMessage(const QString &); + int parseMessage(const QByteArray &); + int parseTcfCommandReply(char type, const QVector<QByteArray> &tokens); + int parseTcfEvent(const QVector<QByteArray> &tokens); + + TcfTrkDevicePrivate *d; +}; + +} // namespace tcftrk + +#endif // TCFTRKENGINE_H |