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
|
/**************************************************************************
**
** 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 TRCFTRKMESSAGE_H
#define TRCFTRKMESSAGE_H
#include "symbianutils_global.h"
#include <QtCore/QStringList>
#include <QtCore/QVector>
QT_BEGIN_NAMESPACE
class QTextStream;
QT_END_NAMESPACE
namespace tcftrk {
class JsonValue;
class JsonInputStream;
enum Services {
LocatorService,
RunControlService,
ProcessesService,
MemoryService,
SettingsService, // non-standard, trk specific
BreakpointsService,
RegistersService,
SimpleRegistersService, // non-standard, trk 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 occuring 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 TcfTrk 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 TcfTrkEvent {
Q_DISABLE_COPY(TcfTrkEvent)
public:
enum Type { None,
LocatorHello,
RunControlContextAdded,
RunControlContextRemoved,
RunControlSuspended,
RunControlBreakpointSuspended,
RunControlModuleLoadSuspended,
RunControlResumed
};
virtual ~TcfTrkEvent();
Type type() const;
virtual QString toString() const;
static TcfTrkEvent *parseEvent(Services s, const QByteArray &name, const QVector<JsonValue> &val);
protected:
explicit TcfTrkEvent(Type type = None);
private:
const Type m_type;
};
// ServiceHello
class SYMBIANUTILS_EXPORT TcfTrkLocatorHelloEvent : public TcfTrkEvent {
public:
explicit TcfTrkLocatorHelloEvent(const QStringList &);
const QStringList &services() { return m_services; }
virtual QString toString() const;
private:
QStringList m_services;
};
// Base for events that just have one id as parameter
// (simple suspend)
class SYMBIANUTILS_EXPORT TcfTrkIdEvent : public TcfTrkEvent {
protected:
explicit TcfTrkIdEvent(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 TcfTrkIdsEvent : public TcfTrkEvent {
protected:
explicit TcfTrkIdsEvent(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 TcfTrkRunControlContextAddedEvent : public TcfTrkEvent {
public:
typedef QVector<RunControlContext> RunControlContexts;
explicit TcfTrkRunControlContextAddedEvent(const RunControlContexts &c);
const RunControlContexts &contexts() const { return m_contexts; }
virtual QString toString() const;
static TcfTrkRunControlContextAddedEvent *parseEvent(const QVector<JsonValue> &val);
private:
const RunControlContexts m_contexts;
};
// RunControlContextRemoved
class SYMBIANUTILS_EXPORT TcfTrkRunControlContextRemovedEvent : public TcfTrkIdsEvent {
public:
explicit TcfTrkRunControlContextRemovedEvent(const QVector<QByteArray> &id);
virtual QString toString() const;
};
// Simple RunControlContextSuspended (process/thread)
class SYMBIANUTILS_EXPORT TcfTrkRunControlContextSuspendedEvent : public TcfTrkIdEvent {
public:
enum Reason { BreakPoint, ModuleLoad, Crash, Other } ;
explicit TcfTrkRunControlContextSuspendedEvent(const QByteArray &id,
const QByteArray &reason,
quint64 pc = 0);
virtual QString toString() const;
quint64 pc() const { return m_pc; }
QByteArray reasonID() const { return m_reason; }
Reason reason() const;
protected:
explicit TcfTrkRunControlContextSuspendedEvent(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;
};
// RunControlContextSuspended due to module load
class SYMBIANUTILS_EXPORT TcfTrkRunControlModuleLoadContextSuspendedEvent : public TcfTrkRunControlContextSuspendedEvent {
public:
explicit TcfTrkRunControlModuleLoadContextSuspendedEvent(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;
};
} // namespace tcftrk
#endif // TRCFTRKMESSAGE_H
|