| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2010 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 | #include <QtCore/QByteArray>
|
|---|
| 47 | #include <QtCore/QHash>
|
|---|
| 48 | #include <QtCore/QStringList>
|
|---|
| 49 | #include <QtCore/QVariant>
|
|---|
| 50 |
|
|---|
| 51 | QT_BEGIN_NAMESPACE
|
|---|
| 52 | class QDateTime;
|
|---|
| 53 | QT_END_NAMESPACE
|
|---|
| 54 |
|
|---|
| 55 | namespace trk {
|
|---|
| 56 |
|
|---|
| 57 | typedef unsigned char byte;
|
|---|
| 58 |
|
|---|
| 59 | enum Command {
|
|---|
| 60 | TrkPing = 0x00,
|
|---|
| 61 | TrkConnect = 0x01,
|
|---|
| 62 | TrkDisconnect = 0x02,
|
|---|
| 63 | TrkVersions = 0x04,
|
|---|
| 64 | TrkSupported = 0x05,
|
|---|
| 65 | TrkCpuType = 0x06,
|
|---|
| 66 | TrkHostVersions = 0x09,
|
|---|
| 67 | TrkContinue = 0x18,
|
|---|
| 68 | TrkCreateItem = 0x40,
|
|---|
| 69 | TrkDeleteItem = 0x41,
|
|---|
| 70 |
|
|---|
| 71 | TrkWriteFile = 0x48,
|
|---|
| 72 | TrkOpenFile = 0x4a,
|
|---|
| 73 | TrkCloseFile = 0x4b,
|
|---|
| 74 | TrkInstallFile = 0x4d,
|
|---|
| 75 | TrkInstallFile2 = 0x4e,
|
|---|
| 76 |
|
|---|
| 77 | TrkNotifyAck = 0x80,
|
|---|
| 78 | TrkNotifyNak = 0xff,
|
|---|
| 79 | TrkNotifyStopped = 0x90,
|
|---|
| 80 | TrkNotifyException = 0x91,
|
|---|
| 81 | TrkNotifyInternalError = 0x92,
|
|---|
| 82 | TrkNotifyCreated = 0xa0,
|
|---|
| 83 | TrkNotifyDeleted = 0xa1,
|
|---|
| 84 | TrkNotifyProcessorStarted = 0xa2,
|
|---|
| 85 | TrkNotifyProcessorStandBy = 0xa6,
|
|---|
| 86 | TrkNotifyProcessorReset = 0xa7
|
|---|
| 87 | };
|
|---|
| 88 |
|
|---|
| 89 | inline byte extractByte(const char *data) { return *data; }
|
|---|
| 90 | SYMBIANUTILS_EXPORT ushort extractShort(const char *data);
|
|---|
| 91 | SYMBIANUTILS_EXPORT uint extractInt(const char *data);
|
|---|
| 92 |
|
|---|
| 93 | SYMBIANUTILS_EXPORT QString quoteUnprintableLatin1(const QByteArray &ba);
|
|---|
| 94 |
|
|---|
| 95 | // produces "xx xx xx "
|
|---|
| 96 | SYMBIANUTILS_EXPORT QString stringFromArray(const QByteArray &ba, int maxLen = - 1);
|
|---|
| 97 |
|
|---|
| 98 | enum Endianness
|
|---|
| 99 | {
|
|---|
| 100 | LittleEndian,
|
|---|
| 101 | BigEndian,
|
|---|
| 102 | TargetByteOrder = BigEndian,
|
|---|
| 103 | };
|
|---|
| 104 |
|
|---|
| 105 | SYMBIANUTILS_EXPORT void appendShort(QByteArray *ba, ushort s, Endianness = TargetByteOrder);
|
|---|
| 106 | SYMBIANUTILS_EXPORT void appendInt(QByteArray *ba, uint i, Endianness = TargetByteOrder);
|
|---|
| 107 | SYMBIANUTILS_EXPORT void appendString(QByteArray *ba, const QByteArray &str, Endianness = TargetByteOrder, bool appendNullTerminator = true);
|
|---|
| 108 |
|
|---|
| 109 | struct SYMBIANUTILS_EXPORT Library
|
|---|
| 110 | {
|
|---|
| 111 | Library() {}
|
|---|
| 112 |
|
|---|
| 113 | QByteArray name;
|
|---|
| 114 | uint codeseg;
|
|---|
| 115 | uint dataseg;
|
|---|
| 116 | };
|
|---|
| 117 |
|
|---|
| 118 | struct SYMBIANUTILS_EXPORT TrkAppVersion
|
|---|
| 119 | {
|
|---|
| 120 | TrkAppVersion();
|
|---|
| 121 | void reset();
|
|---|
| 122 |
|
|---|
| 123 | int trkMajor;
|
|---|
| 124 | int trkMinor;
|
|---|
| 125 | int protocolMajor;
|
|---|
| 126 | int protocolMinor;
|
|---|
| 127 | };
|
|---|
| 128 |
|
|---|
| 129 | struct SYMBIANUTILS_EXPORT Session
|
|---|
| 130 | {
|
|---|
| 131 | Session();
|
|---|
| 132 | void reset();
|
|---|
| 133 | QString deviceDescription(unsigned verbose) const;
|
|---|
| 134 |
|
|---|
| 135 | // Trk feedback
|
|---|
| 136 | byte cpuMajor;
|
|---|
| 137 | byte cpuMinor;
|
|---|
| 138 | byte bigEndian;
|
|---|
| 139 | byte defaultTypeSize;
|
|---|
| 140 | byte fpTypeSize;
|
|---|
| 141 | byte extended1TypeSize;
|
|---|
| 142 | byte extended2TypeSize;
|
|---|
| 143 | TrkAppVersion trkAppVersion;
|
|---|
| 144 | uint pid;
|
|---|
| 145 | uint tid;
|
|---|
| 146 | uint codeseg;
|
|---|
| 147 | uint dataseg;
|
|---|
| 148 | QHash<uint, uint> addressToBP;
|
|---|
| 149 |
|
|---|
| 150 | typedef QList<Library> Libraries;
|
|---|
| 151 | Libraries libraries;
|
|---|
| 152 |
|
|---|
| 153 | typedef uint Thread;
|
|---|
| 154 | typedef QList<Thread> Threads;
|
|---|
| 155 | Threads threads;
|
|---|
| 156 |
|
|---|
| 157 | // Gdb request
|
|---|
| 158 | uint currentThread;
|
|---|
| 159 | QStringList modules;
|
|---|
| 160 | };
|
|---|
| 161 |
|
|---|
| 162 | struct SYMBIANUTILS_EXPORT TrkResult
|
|---|
| 163 | {
|
|---|
| 164 | TrkResult();
|
|---|
| 165 | void clear();
|
|---|
| 166 | QString toString() const;
|
|---|
| 167 | // 0 for no error.
|
|---|
| 168 | int errorCode() const;
|
|---|
| 169 | QString errorString() const;
|
|---|
| 170 |
|
|---|
| 171 | byte code;
|
|---|
| 172 | byte token;
|
|---|
| 173 | QByteArray data;
|
|---|
| 174 | QVariant cookie;
|
|---|
| 175 | bool isDebugOutput;
|
|---|
| 176 | };
|
|---|
| 177 |
|
|---|
| 178 | SYMBIANUTILS_EXPORT QByteArray errorMessage(byte code);
|
|---|
| 179 | SYMBIANUTILS_EXPORT QByteArray hexNumber(uint n, int digits = 0);
|
|---|
| 180 | SYMBIANUTILS_EXPORT QByteArray hexxNumber(uint n, int digits = 0); // prepends '0x', too
|
|---|
| 181 | SYMBIANUTILS_EXPORT uint swapEndian(uint in);
|
|---|
| 182 |
|
|---|
| 183 | } // namespace trk
|
|---|
| 184 |
|
|---|
| 185 | #endif // DEBUGGER_TRK_UTILS
|
|---|