1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the tools applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef CODAMESSAGE_H
#define CODAMESSAGE_H
#include "symbianutils_global.h"
#include <QtCore/QStringList>
#include <QtCore/QVector>
QT_BEGIN_NAMESPACE
class QTextStream;
QT_END_NAMESPACE
namespace Coda {
class JsonValue;
class JsonInputStream;
enum Services {
LocatorService,
RunControlService,
ProcessesService,
MemoryService,
SettingsService, // non-standard, CODA specific
BreakpointsService,
RegistersService,
LoggingService, // non-standard, CODA specific
FileSystemService,
SymbianInstallService, // non-standard, CODA specific
SymbianOSData, // non-standard, CODA specific
DebugSessionControl, // non-standard, CODA specific
UnknownService
}; // Note: Check string array 'serviceNamesC' of same size when modifying this.
// Modes of RunControl/'Resume' (see EDF documentation).
// As of 24.6.2010, RM_RESUME, RM_STEP_OVER, RM_STEP_INTO,
// RM_STEP_OVER_RANGE, RM_STEP_INTO_RANGE are supported with
// RANG_START/RANGE_END parameters.
enum RunControlResumeMode {
RM_RESUME = 0,
RM_STEP_OVER = 1, RM_STEP_INTO = 2,
RM_STEP_OVER_LINE = 3, RM_STEP_INTO_LINE = 4,
RM_STEP_OUT = 5, RM_REVERSE_RESUME = 6,
RM_REVERSE_STEP_OVER = 7, RM_REVERSE_STEP_INTO = 8,
RM_REVERSE_STEP_OVER_LINE = 9, RM_REVERSE_STEP_INTO_LINE = 10,
RM_REVERSE_STEP_OUT = 11, RM_STEP_OVER_RANGE = 12,
RM_STEP_INTO_RANGE = 13, RM_REVERSE_STEP_OVER_RANGE = 14,
RM_REVERSE_STEP_INTO_RANGE = 15
};
SYMBIANUTILS_EXPORT const char *serviceName(Services s);
SYMBIANUTILS_EXPORT Services serviceFromName(const char *);
// Debug helpers
SYMBIANUTILS_EXPORT QString formatData(const QByteArray &a);
SYMBIANUTILS_EXPORT QString joinByteArrays(const QVector<QByteArray> &a, char sep = ',');
// Context used in 'RunControl contextAdded' events and in reply
// to 'Processes start'. Could be thread or process.
struct SYMBIANUTILS_EXPORT RunControlContext {
enum Flags {
Container = 0x1, HasState = 0x2, CanSuspend = 0x4,
CanTerminate = 0x8
};
enum Type { Process, Thread };
RunControlContext();
Type type() const;
unsigned processId() const;
unsigned threadId() const;
void clear();
bool parse(const JsonValue &v);
void format(QTextStream &str) const;
QString toString() const;
// Helper for converting the TCF ids ("p12" or "p12.t34")
static Type typeFromTcfId(const QByteArray &id);
static unsigned processIdFromTcdfId(const QByteArray &id);
static unsigned threadIdFromTcdfId(const QByteArray &id);
static QByteArray tcfId(unsigned processId, unsigned threadId = 0);
unsigned flags;
unsigned resumeFlags;
QByteArray id; // "p434.t699"
QByteArray osid; // Non-standard: Process or thread id
QByteArray parentId; // Parent process id of a thread.
};
// Module load information occurring with 'RunControl contextSuspended' events
struct SYMBIANUTILS_EXPORT ModuleLoadEventInfo {
ModuleLoadEventInfo();
void clear();
bool parse(const JsonValue &v);
void format(QTextStream &str) const;
QByteArray name;
QByteArray file;
bool loaded;
quint64 codeAddress;
quint64 dataAddress;
bool requireResume;
};
// Breakpoint as supported by Coda source June 2010
// TODO: Add watchpoints,etc once they are implemented
struct SYMBIANUTILS_EXPORT Breakpoint {
enum Type { Software, Hardware, Auto };
explicit Breakpoint(quint64 loc = 0);
void setContextId(unsigned processId, unsigned threadId = 0);
QString toString() const;
static QByteArray idFromLocation(quint64 loc); // Automagically determine from location
Type type;
bool enabled;
int ignoreCount;
QVector<QByteArray> contextIds; // Process or thread ids.
QByteArray id; // Id of the breakpoint;
quint64 location;
unsigned size;
bool thumb;
};
SYMBIANUTILS_EXPORT JsonInputStream &operator<<(JsonInputStream &str, const Breakpoint &b);
// Event hierarchy
class SYMBIANUTILS_EXPORT CodaEvent {
Q_DISABLE_COPY(CodaEvent)
public:
enum Type { None,
LocatorHello,
RunControlContextAdded,
RunControlContextRemoved,
RunControlSuspended,
RunControlBreakpointSuspended,
RunControlModuleLoadSuspended,
RunControlResumed,
LoggingWriteEvent, // Non-standard
ProcessExitedEvent // Non-standard
};
virtual ~CodaEvent();
Type type() const;
virtual QString toString() const;
static CodaEvent *parseEvent(Services s, const QByteArray &name, const QVector<JsonValue> &val);
protected:
explicit CodaEvent(Type type = None);
private:
const Type m_type;
};
// ServiceHello
class SYMBIANUTILS_EXPORT CodaLocatorHelloEvent : public CodaEvent {
public:
explicit CodaLocatorHelloEvent(const QStringList &);
const QStringList &services() const { return m_services; }
virtual QString toString() const;
private:
QStringList m_services;
};
// Logging event (non-standard, CODA specific)
class SYMBIANUTILS_EXPORT CodaLoggingWriteEvent : public CodaEvent {
public:
explicit CodaLoggingWriteEvent(const QByteArray &console, const QByteArray &message);
QByteArray message() const { return m_message; }
QByteArray console() const { return m_console; }
virtual QString toString() const;
private:
const QByteArray m_console;
const QByteArray m_message;
};
// Base for events that just have one id as parameter
// (simple suspend)
class SYMBIANUTILS_EXPORT CodaIdEvent : public CodaEvent {
protected:
explicit CodaIdEvent(Type t, const QByteArray &id);
public:
QByteArray id() const { return m_id; }
QString idString() const { return QString::fromUtf8(m_id); }
private:
const QByteArray m_id;
};
// Base for events that just have some ids as parameter
// (context removed)
class SYMBIANUTILS_EXPORT CodaIdsEvent : public CodaEvent {
protected:
explicit CodaIdsEvent(Type t, const QVector<QByteArray> &ids);
public:
QVector<QByteArray> ids() const { return m_ids; }
QString joinedIdString(const char sep = ',') const;
private:
const QVector<QByteArray> m_ids;
};
// RunControlContextAdded
class SYMBIANUTILS_EXPORT CodaRunControlContextAddedEvent : public CodaEvent {
public:
typedef QVector<RunControlContext> RunControlContexts;
explicit CodaRunControlContextAddedEvent(const RunControlContexts &c);
const RunControlContexts &contexts() const { return m_contexts; }
virtual QString toString() const;
static CodaRunControlContextAddedEvent *parseEvent(const QVector<JsonValue> &val);
private:
const RunControlContexts m_contexts;
};
// RunControlContextRemoved
class SYMBIANUTILS_EXPORT CodaRunControlContextRemovedEvent : public CodaIdsEvent {
public:
explicit CodaRunControlContextRemovedEvent(const QVector<QByteArray> &id);
virtual QString toString() const;
};
// Simple RunControlContextSuspended (process/thread)
class SYMBIANUTILS_EXPORT CodaRunControlContextSuspendedEvent : public CodaIdEvent {
public:
enum Reason { BreakPoint, ModuleLoad, Crash, Other } ;
explicit CodaRunControlContextSuspendedEvent(const QByteArray &id,
const QByteArray &reason,
const QByteArray &message,
quint64 pc = 0);
virtual QString toString() const;
quint64 pc() const { return m_pc; }
QByteArray reasonID() const { return m_reason; }
Reason reason() const;
QByteArray message() const { return m_message; }
protected:
explicit CodaRunControlContextSuspendedEvent(Type t,
const QByteArray &id,
const QByteArray &reason,
quint64 pc = 0);
void format(QTextStream &str) const;
private:
const quint64 m_pc;
const QByteArray m_reason;
const QByteArray m_message;
};
// RunControlContextSuspended due to module load
class SYMBIANUTILS_EXPORT CodaRunControlModuleLoadContextSuspendedEvent : public CodaRunControlContextSuspendedEvent {
public:
explicit CodaRunControlModuleLoadContextSuspendedEvent(const QByteArray &id,
const QByteArray &reason,
quint64 pc,
const ModuleLoadEventInfo &mi);
virtual QString toString() const;
const ModuleLoadEventInfo &info() const { return m_mi; }
private:
const ModuleLoadEventInfo m_mi;
};
// Process exited event
class SYMBIANUTILS_EXPORT CodaProcessExitedEvent : public CodaEvent {
public:
explicit CodaProcessExitedEvent(const QByteArray &id);
QByteArray id() const { return m_id; }
QString idString() const { return QString::fromUtf8(m_id); }
virtual QString toString() const;
private:
const QByteArray m_id;
};
} // namespace Coda
#endif // CODAMESSAGE_H
|