1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at info@qt.nokia.com.
31 **************************************************************************/
36 #include "symbianutils_global.h"
38 #include <QtCore/QStringList>
39 #include <QtCore/QVector>
48 class JsonInputStream;
55 SettingsService, // non-standard, CODA specific
58 LoggingService, // non-standard, CODA specific
60 SymbianInstallService, // non-standard, CODA specific
61 SymbianOSData, // non-standard, CODA specific
62 DebugSessionControl, // non-standard, CODA specific
64 }; // Note: Check string array 'serviceNamesC' of same size when modifying this.
66 // Modes of RunControl/'Resume' (see EDF documentation).
67 // As of 24.6.2010, RM_RESUME, RM_STEP_OVER, RM_STEP_INTO,
68 // RM_STEP_OVER_RANGE, RM_STEP_INTO_RANGE are supported with
69 // RANG_START/RANGE_END parameters.
70 enum RunControlResumeMode {
72 RM_STEP_OVER = 1, RM_STEP_INTO = 2,
73 RM_STEP_OVER_LINE = 3, RM_STEP_INTO_LINE = 4,
74 RM_STEP_OUT = 5, RM_REVERSE_RESUME = 6,
75 RM_REVERSE_STEP_OVER = 7, RM_REVERSE_STEP_INTO = 8,
76 RM_REVERSE_STEP_OVER_LINE = 9, RM_REVERSE_STEP_INTO_LINE = 10,
77 RM_REVERSE_STEP_OUT = 11, RM_STEP_OVER_RANGE = 12,
78 RM_STEP_INTO_RANGE = 13, RM_REVERSE_STEP_OVER_RANGE = 14,
79 RM_REVERSE_STEP_INTO_RANGE = 15
82 SYMBIANUTILS_EXPORT const char *serviceName(Services s);
83 SYMBIANUTILS_EXPORT Services serviceFromName(const char *);
86 SYMBIANUTILS_EXPORT QString formatData(const QByteArray &a);
87 SYMBIANUTILS_EXPORT QString joinByteArrays(const QVector<QByteArray> &a, char sep = ',');
89 // Context used in 'RunControl contextAdded' events and in reply
90 // to 'Processes start'. Could be thread or process.
91 struct SYMBIANUTILS_EXPORT RunControlContext {
93 Container = 0x1, HasState = 0x2, CanSuspend = 0x4,
96 enum Type { Process, Thread };
100 unsigned processId() const;
101 unsigned threadId() const;
104 bool parse(const JsonValue &v);
105 void format(QTextStream &str) const;
106 QString toString() const;
108 // Helper for converting the CODA ids ("p12" or "p12.t34")
109 static Type typeFromCodaId(const QByteArray &id);
110 static unsigned processIdFromTcdfId(const QByteArray &id);
111 static unsigned threadIdFromTcdfId(const QByteArray &id);
112 static QByteArray codaId(unsigned processId, unsigned threadId = 0);
115 unsigned resumeFlags;
116 QByteArray id; // "p434.t699"
117 QByteArray osid; // Non-standard: Process or thread id
118 QByteArray parentId; // Parent process id of a thread.
121 // Module load information occurring with 'RunControl contextSuspended' events
122 struct SYMBIANUTILS_EXPORT ModuleLoadEventInfo {
123 ModuleLoadEventInfo();
125 bool parse(const JsonValue &v);
126 void format(QTextStream &str) const;
136 // Breakpoint as supported by Coda source June 2010
137 // TODO: Add watchpoints,etc once they are implemented
138 struct SYMBIANUTILS_EXPORT Breakpoint {
139 enum Type { Software, Hardware, Auto };
141 explicit Breakpoint(quint64 loc = 0);
142 void setContextId(unsigned processId, unsigned threadId = 0);
143 QString toString() const;
145 static QByteArray idFromLocation(quint64 loc); // Automagically determine from location
150 QVector<QByteArray> contextIds; // Process or thread ids.
151 QByteArray id; // Id of the breakpoint;
157 SYMBIANUTILS_EXPORT JsonInputStream &operator<<(JsonInputStream &str, const Breakpoint &b);
160 class SYMBIANUTILS_EXPORT CodaEvent
162 Q_DISABLE_COPY(CodaEvent)
167 RunControlContextAdded,
168 RunControlContextRemoved,
170 RunControlBreakpointSuspended,
171 RunControlModuleLoadSuspended,
173 LoggingWriteEvent, // Non-standard
174 ProcessExitedEvent // Non-standard
177 virtual ~CodaEvent();
180 virtual QString toString() const;
182 static CodaEvent *parseEvent(Services s, const QByteArray &name, const QVector<JsonValue> &val);
185 explicit CodaEvent(Type type = None);
192 class SYMBIANUTILS_EXPORT CodaLocatorHelloEvent : public CodaEvent {
194 explicit CodaLocatorHelloEvent(const QStringList &);
196 const QStringList &services() const { return m_services; }
197 virtual QString toString() const;
200 QStringList m_services;
203 // Logging event (non-standard, CODA specific)
204 class SYMBIANUTILS_EXPORT CodaLoggingWriteEvent : public CodaEvent {
206 explicit CodaLoggingWriteEvent(const QByteArray &console, const QByteArray &message);
208 QByteArray message() const { return m_message; }
209 QByteArray console() const { return m_console; }
211 virtual QString toString() const;
214 const QByteArray m_console;
215 const QByteArray m_message;
218 // Base for events that just have one id as parameter
220 class SYMBIANUTILS_EXPORT CodaIdEvent : public CodaEvent {
222 explicit CodaIdEvent(Type t, const QByteArray &id);
224 QByteArray id() const { return m_id; }
225 QString idString() const { return QString::fromUtf8(m_id); }
228 const QByteArray m_id;
231 // Base for events that just have some ids as parameter
233 class SYMBIANUTILS_EXPORT CodaIdsEvent : public CodaEvent {
235 explicit CodaIdsEvent(Type t, const QVector<QByteArray> &ids);
238 QVector<QByteArray> ids() const { return m_ids; }
239 QString joinedIdString(const char sep = ',') const;
242 const QVector<QByteArray> m_ids;
245 // RunControlContextAdded
246 class SYMBIANUTILS_EXPORT CodaRunControlContextAddedEvent : public CodaEvent {
248 typedef QVector<RunControlContext> RunControlContexts;
250 explicit CodaRunControlContextAddedEvent(const RunControlContexts &c);
252 const RunControlContexts &contexts() const { return m_contexts; }
253 virtual QString toString() const;
255 static CodaRunControlContextAddedEvent *parseEvent(const QVector<JsonValue> &val);
258 const RunControlContexts m_contexts;
261 // RunControlContextRemoved
262 class SYMBIANUTILS_EXPORT CodaRunControlContextRemovedEvent : public CodaIdsEvent {
264 explicit CodaRunControlContextRemovedEvent(const QVector<QByteArray> &id);
265 virtual QString toString() const;
268 // Simple RunControlContextSuspended (process/thread)
269 class SYMBIANUTILS_EXPORT CodaRunControlContextSuspendedEvent : public CodaIdEvent {
271 enum Reason { BreakPoint, ModuleLoad, Crash, Other } ;
273 explicit CodaRunControlContextSuspendedEvent(const QByteArray &id,
274 const QByteArray &reason,
275 const QByteArray &message,
277 virtual QString toString() const;
279 quint64 pc() const { return m_pc; }
280 QByteArray reasonID() const { return m_reason; }
281 Reason reason() const;
282 QByteArray message() const { return m_message; }
285 explicit CodaRunControlContextSuspendedEvent(Type t,
286 const QByteArray &id,
287 const QByteArray &reason,
289 void format(QTextStream &str) const;
293 const QByteArray m_reason;
294 const QByteArray m_message;
297 // RunControlContextSuspended due to module load
298 class SYMBIANUTILS_EXPORT CodaRunControlModuleLoadContextSuspendedEvent : public CodaRunControlContextSuspendedEvent {
300 explicit CodaRunControlModuleLoadContextSuspendedEvent(const QByteArray &id,
301 const QByteArray &reason,
303 const ModuleLoadEventInfo &mi);
305 virtual QString toString() const;
306 const ModuleLoadEventInfo &info() const { return m_mi; }
309 const ModuleLoadEventInfo m_mi;
312 // Process exited event
313 class SYMBIANUTILS_EXPORT CodaProcessExitedEvent : public CodaEvent {
315 explicit CodaProcessExitedEvent(const QByteArray &id);
317 QByteArray id() const { return m_id; }
318 QString idString() const { return QString::fromUtf8(m_id); }
319 virtual QString toString() const;
322 const QByteArray m_id;
326 #endif // CODAMESSAGE_H