source: trunk/tools/runonphone/symbianutils/trkutils.h@ 1147

Last change on this file since 1147 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 7.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the tools applications of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef DEBUGGER_TRK_UTILS
43#define DEBUGGER_TRK_UTILS
44
45#include "symbianutils_global.h"
46
47#include <QtCore/QByteArray>
48#include <QtCore/QHash>
49#include <QtCore/QStringList>
50#include <QtCore/QVariant>
51
52QT_BEGIN_NAMESPACE
53class QDateTime;
54QT_END_NAMESPACE
55
56namespace trk {
57
58typedef unsigned char byte;
59struct TrkResult;
60
61enum Command {
62 //meta commands
63 TrkPing = 0x00,
64 TrkConnect = 0x01,
65 TrkDisconnect = 0x02,
66 TrkReset = 0x03,
67 TrkVersions = 0x04,
68 TrkSupported = 0x05,
69 TrkCpuType = 0x06,
70 TrkConfigTransport = 0x07,
71 TrkVersions2 = 0x08,
72 TrkHostVersions = 0x09,
73
74 //state commands
75 TrkReadMemory = 0x10,
76 TrkWriteMemory = 0x11,
77 TrkReadRegisters = 0x12,
78 TrkWriteRegisters = 0x13,
79 TrkFillMemory = 0x14,
80 TrkCopyMemory = 0x15,
81 TrkFlushCache = 0x16,
82
83 //execution commands
84 TrkContinue = 0x18,
85 TrkStep = 0x19,
86 TrkStop = 0x1a,
87 TrkSetBreak = 0x1b,
88 TrkClearBreak = 0x1c,
89 TrkDownload = 0x1d,
90 TrkModifyBreakThread = 0x1e,
91
92 //host -> target IO management
93 TrkNotifyFileInput = 0x20,
94 TrkBlockFileIo = 0x21,
95
96 //host -> target os commands
97 TrkCreateItem = 0x40,
98 TrkDeleteItem = 0x41,
99 TrkReadInfo = 0x42,
100 TrkWriteInfo = 0x43,
101
102 TrkWriteFile = 0x48,
103 TrkReadFile = 0x49,
104 TrkOpenFile = 0x4a,
105 TrkCloseFile = 0x4b,
106 TrkPositionFile = 0x4c,
107 TrkInstallFile = 0x4d,
108 TrkInstallFile2 = 0x4e,
109
110 TrkPhoneSwVersion = 0x4f,
111 TrkPhoneName = 0x50,
112 TrkVersions3 = 0x51,
113
114 //replies
115 TrkNotifyAck = 0x80,
116 TrkNotifyNak = 0xff,
117
118 //target -> host notification
119 TrkNotifyStopped = 0x90,
120 TrkNotifyException = 0x91,
121 TrkNotifyInternalError = 0x92,
122 TrkNotifyStopped2 = 0x94,
123
124 //target -> host OS notification
125 TrkNotifyCreated = 0xa0,
126 TrkNotifyDeleted = 0xa1,
127 TrkNotifyProcessorStarted = 0xa2,
128 TrkNotifyProcessorStandBy = 0xa6,
129 TrkNotifyProcessorReset = 0xa7,
130
131 //target -> host support commands (these are defined but not implemented in TRK)
132 TrkDSWriteFile = 0xd0,
133 TrkDSReadFile = 0xd1,
134 TrkDSOpenFile = 0xd2,
135 TrkDSCloseFile = 0xd3,
136 TrkDSPositionFile = 0xd4
137};
138
139enum DSOSItemTypes {
140 kDSOSProcessItem = 0x0000,
141 kDSOSThreadItem = 0x0001,
142 kDSOSDLLItem = 0x0002,
143 kDSOSAppItem = 0x0003,
144 kDSOSMemBlockItem = 0x0004,
145 kDSOSProcAttachItem = 0x0005,
146 kDSOSThreadAttachItem = 0x0006,
147 kDSOSProcAttach2Item = 0x0007,
148 kDSOSProcRunItem = 0x0008,
149 /* 0x0009 - 0x00ff reserved for general expansion */
150 /* 0x0100 - 0xffff available for target-specific use */
151};
152
153enum SerialMultiplexor {
154 MuxRaw = 0,
155 MuxTextTrace = 0x0102,
156 MuxTrk = 0x0190
157};
158
159inline byte extractByte(const char *data) { return *data; }
160SYMBIANUTILS_EXPORT ushort extractShort(const char *data);
161SYMBIANUTILS_EXPORT uint extractInt(const char *data);
162SYMBIANUTILS_EXPORT quint64 extractInt64(const char *data);
163
164SYMBIANUTILS_EXPORT QString quoteUnprintableLatin1(const QByteArray &ba);
165
166// produces "xx xx xx "
167SYMBIANUTILS_EXPORT QString stringFromArray(const QByteArray &ba, int maxLen = - 1);
168
169enum Endianness
170{
171 LittleEndian,
172 BigEndian,
173 TargetByteOrder = BigEndian,
174};
175
176SYMBIANUTILS_EXPORT void appendShort(QByteArray *ba, ushort s, Endianness = TargetByteOrder);
177SYMBIANUTILS_EXPORT void appendInt(QByteArray *ba, uint i, Endianness = TargetByteOrder);
178SYMBIANUTILS_EXPORT void appendString(QByteArray *ba, const QByteArray &str, Endianness = TargetByteOrder, bool appendNullTerminator = true);
179
180struct SYMBIANUTILS_EXPORT Library
181{
182 Library();
183 explicit Library(const TrkResult &r);
184
185 QByteArray name;
186 uint codeseg;
187 uint dataseg;
188 //library addresses are valid for a given process (depending on memory model, they might be loaded at the same address in all processes or not)
189 uint pid;
190};
191
192struct SYMBIANUTILS_EXPORT TrkAppVersion
193{
194 TrkAppVersion();
195 void reset();
196
197 int trkMajor;
198 int trkMinor;
199 int protocolMajor;
200 int protocolMinor;
201};
202
203struct SYMBIANUTILS_EXPORT Session
204{
205 Session();
206 void reset();
207 QString deviceDescription(unsigned verbose) const;
208 QString toString() const;
209 // Answer to qXfer::libraries
210 QByteArray gdbLibraryList() const;
211 // Answer to qsDllInfo, can be sent chunk-wise.
212 QByteArray gdbQsDllInfo(int start = 0, int count = -1) const;
213
214 // Trk feedback
215 byte cpuMajor;
216 byte cpuMinor;
217 byte bigEndian;
218 byte defaultTypeSize;
219 byte fpTypeSize;
220 byte extended1TypeSize;
221 byte extended2TypeSize;
222 TrkAppVersion trkAppVersion;
223 uint pid;
224 uint mainTid;
225 uint tid;
226 uint codeseg;
227 uint dataseg;
228 QHash<uint, uint> addressToBP;
229
230 typedef QList<Library> Libraries;
231 Libraries libraries;
232
233 // Gdb request
234 QStringList modules;
235};
236
237struct SYMBIANUTILS_EXPORT TrkResult
238{
239 TrkResult();
240 void clear();
241 QString toString() const;
242 // 0 for no error.
243 int errorCode() const;
244 QString errorString() const;
245
246 ushort multiplex;
247 byte code;
248 byte token;
249 QByteArray data;
250 QVariant cookie;
251 bool isDebugOutput;
252};
253
254SYMBIANUTILS_EXPORT QByteArray errorMessage(byte code);
255SYMBIANUTILS_EXPORT QByteArray hexNumber(uint n, int digits = 0);
256SYMBIANUTILS_EXPORT QByteArray hexxNumber(uint n, int digits = 0); // prepends '0x', too
257SYMBIANUTILS_EXPORT uint swapEndian(uint in);
258
259} // namespace trk
260
261#endif // DEBUGGER_TRK_UTILS
Note: See TracBrowser for help on using the repository browser.