Changeset 846 for trunk/tools/runonphone/symbianutils/trkutils.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/tools/runonphone/symbianutils/trkutils.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 52 52 53 53 namespace trk { 54 55 Library::Library() : codeseg(0), dataseg(0), pid(0) 56 { 57 } 58 59 Library::Library(const TrkResult &result) : codeseg(0), dataseg(0), pid(0) 60 { 61 if (result.data.size() < 20) { 62 qWarning("Invalid trk creation notification received."); 63 return; 64 } 65 66 const char *data = result.data.constData(); 67 pid = extractInt(data + 2); 68 codeseg = extractInt(data + 10); 69 dataseg = extractInt(data + 14); 70 const uint len = extractShort(data + 18); 71 name = result.data.mid(20, len); 72 } 54 73 55 74 TrkAppVersion::TrkAppVersion() … … 78 97 extended2TypeSize = 0; 79 98 pid = 0; 99 mainTid = 0; 80 100 tid = 0; 81 101 codeseg = 0; 82 102 dataseg = 0; 83 103 84 currentThread = 0;85 104 libraries.clear(); 86 105 trkAppVersion.reset(); … … 144 163 } 145 164 165 QByteArray Session::gdbLibraryList() const 166 { 167 const int count = libraries.size(); 168 QByteArray response = "l<library-list>"; 169 for (int i = 0; i != count; ++i) { 170 const trk::Library &lib = libraries.at(i); 171 response += "<library name=\""; 172 response += lib.name; 173 response += "\">"; 174 response += "<section address=\"0x"; 175 response += trk::hexNumber(lib.codeseg); 176 response += "\"/>"; 177 response += "<section address=\"0x"; 178 response += trk::hexNumber(lib.dataseg); 179 response += "\"/>"; 180 response += "<section address=\"0x"; 181 response += trk::hexNumber(lib.dataseg); 182 response += "\"/>"; 183 response += "</library>"; 184 } 185 response += "</library-list>"; 186 return response; 187 } 188 189 QByteArray Session::gdbQsDllInfo(int start, int count) const 190 { 191 // Happens with gdb 6.4.50.20060226-cvs / CodeSourcery. 192 // Never made it into FSF gdb that got qXfer:libraries:read instead. 193 // http://sourceware.org/ml/gdb/2007-05/msg00038.html 194 // Name=hexname,TextSeg=textaddr[,DataSeg=dataaddr] 195 const int libraryCount = libraries.size(); 196 const int end = count < 0 ? libraryCount : qMin(libraryCount, start + count); 197 QByteArray response(1, end == libraryCount ? 'l' : 'm'); 198 for (int i = start; i < end; ++i) { 199 if (i != start) 200 response += ';'; 201 const Library &lib = libraries.at(i); 202 response += "Name="; 203 response += lib.name.toHex(); 204 response += ",TextSeg="; 205 response += hexNumber(lib.codeseg); 206 response += ",DataSeg="; 207 response += hexNumber(lib.dataseg); 208 } 209 return response; 210 } 211 212 QString Session::toString() const 213 { 214 QString rc; 215 QTextStream str(&rc); 216 str << "Session: " << deviceDescription(false) << '\n' 217 << "pid: " << pid << "main thread: " << mainTid 218 << " current thread: " << tid << ' '; 219 str.setIntegerBase(16); 220 str << " code: 0x" << codeseg << " data: 0x" << dataseg << '\n'; 221 if (const int libCount = libraries.size()) { 222 str << "Libraries:\n"; 223 for (int i = 0; i < libCount; i++) 224 str << " #" << i << ' ' << libraries.at(i).name 225 << " code: 0x" << libraries.at(i).codeseg 226 << " data: 0x" << libraries.at(i).dataseg << '\n'; 227 } 228 if (const int moduleCount = modules.size()) { 229 str << "Modules:\n"; 230 for (int i = 0; i < moduleCount; i++) 231 str << " #" << i << ' ' << modules.at(i) << '\n'; 232 } 233 str.setIntegerBase(10); 234 if (!addressToBP.isEmpty()) { 235 typedef QHash<uint, uint>::const_iterator BP_ConstIterator; 236 str << "Breakpoints:\n"; 237 const BP_ConstIterator cend = addressToBP.constEnd(); 238 for (BP_ConstIterator it = addressToBP.constBegin(); it != cend; ++it) { 239 str.setIntegerBase(16); 240 str << " 0x" << it.key(); 241 str.setIntegerBase(10); 242 str << ' ' << it.value() << '\n'; 243 } 244 } 245 246 return rc; 247 } 248 146 249 // -------------- 147 250 … … 189 292 const int size = maxLen == -1 ? ba.size() : qMin(ba.size(), maxLen); 190 293 for (int i = 0; i < size; ++i) { 191 //if (i == 5 || i == ba.size() - 2) 192 // str += " "; 193 int c = byte(ba.at(i)); 194 str += QString("%1 ").arg(c, 2, 16, QChar('0')); 195 if (i >= 8 && i < ba.size() - 2) 196 ascii += QChar(c).isPrint() ? QChar(c) : QChar('.'); 294 const int c = byte(ba.at(i)); 295 str += QString::fromAscii("%1 ").arg(c, 2, 16, QChar('0')); 296 ascii += QChar(c).isPrint() ? QChar(c) : QChar('.'); 197 297 } 198 298 if (size != ba.size()) { 199 str += "...";200 ascii += "...";201 } 202 return str + " "+ ascii;299 str += QLatin1String("..."); 300 ascii += QLatin1String("..."); 301 } 302 return str + QLatin1String(" ") + ascii; 203 303 } 204 304 … … 277 377 /* returns 0 if array doesn't represent a result, 278 378 otherwise returns the length of the result data */ 279 ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame )379 ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame, ushort& mux) 280 380 { 281 381 if (serialFrame) { … … 283 383 if (buffer.length() < 4) 284 384 return 0; 285 if (buffer.at(0) != 0x01 || byte(buffer.at(1)) != 0x90) 286 return 0; 385 mux = extractShort(buffer.data()); 287 386 const ushort len = extractShort(buffer.data() + 2); 288 387 return (buffer.size() >= len + 4) ? len : ushort(0); … … 293 392 // Regular message delimited by 0x7e..0x7e 294 393 if (firstDelimiterPos == 0) { 394 mux = MuxTrk; 295 395 const int endPos = buffer.indexOf(delimiter, firstDelimiterPos + 1); 296 396 return endPos != -1 ? endPos + 1 - firstDelimiterPos : 0; … … 300 400 } 301 401 302 bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByteArray *rawData)402 bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, bool &linkEstablishmentMode, QByteArray *rawData) 303 403 { 304 404 result->clear(); 305 405 if(rawData) 306 406 rawData->clear(); 307 const ushort len = isValidTrkResult(*buffer, serialFrame); 407 ushort len = isValidTrkResult(*buffer, serialFrame, result->multiplex); 408 // handle receiving application output, which is not a regular command 409 const int delimiterPos = serialFrame ? 4 : 0; 410 if (linkEstablishmentMode) { 411 //when "hot connecting" a device, we can receive partial frames. 412 //this code resyncs by discarding data until a TRK frame is found 413 while (buffer->length() > delimiterPos 414 && result->multiplex != MuxTextTrace 415 && !(result->multiplex == MuxTrk && buffer->at(delimiterPos) == 0x7e)) { 416 buffer->remove(0,1); 417 len = isValidTrkResult(*buffer, serialFrame, result->multiplex); 418 } 419 } 308 420 if (!len) 309 421 return false; 310 // handle receiving application output, which is not a regular command311 const int delimiterPos = serialFrame ? 4 : 0;312 422 if (buffer->at(delimiterPos) != 0x7e) { 313 423 result->isDebugOutput = true; 314 424 result->data = buffer->mid(delimiterPos, len); 315 result->data.replace("\r\n", "\n"); 316 *buffer->remove(0, delimiterPos + len); 425 buffer->remove(0, delimiterPos + len); 317 426 return true; 318 427 } … … 322 431 if(rawData) 323 432 *rawData = data; 324 *buffer->remove(0, delimiterPos + len);433 buffer->remove(0, delimiterPos + len); 325 434 326 435 byte sum = 0; … … 337 446 //QByteArray prefix = "READ BUF: "; 338 447 //logMessage((prefix + "HEADER: " + stringFromArray(header).toLatin1()).data()); 448 linkEstablishmentMode = false; //have received a good TRK packet, therefore in sync 339 449 return true; 340 450 } … … 351 461 res *= 256; res += byte(data[2]); 352 462 res *= 256; res += byte(data[3]); 463 return res; 464 } 465 466 SYMBIANUTILS_EXPORT quint64 extractInt64(const char *data) 467 { 468 quint64 res = byte(data[0]); 469 res <<= 8; res += byte(data[1]); 470 res <<= 8; res += byte(data[2]); 471 res <<= 8; res += byte(data[3]); 472 res <<= 8; res += byte(data[4]); 473 res <<= 8; res += byte(data[5]); 474 res <<= 8; res += byte(data[6]); 475 res <<= 8; res += byte(data[7]); 353 476 return res; 354 477 }
Note:
See TracChangeset
for help on using the changeset viewer.