Changeset 846 for trunk/tools/runonphone/symbianutils
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
- 6 copied
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/bluetoothlistener.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) -
trunk/tools/runonphone/symbianutils/bluetoothlistener.h
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) -
trunk/tools/runonphone/symbianutils/bluetoothlistener_gui.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) -
trunk/tools/runonphone/symbianutils/bluetoothlistener_gui.h
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) -
trunk/tools/runonphone/symbianutils/callback.h
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) -
trunk/tools/runonphone/symbianutils/communicationstarter.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) -
trunk/tools/runonphone/symbianutils/communicationstarter.h
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) -
trunk/tools/runonphone/symbianutils/launcher.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) … … 45 45 #include "trkdevice.h" 46 46 #include "bluetoothlistener.h" 47 #include "symbiandevicemanager.h" 47 48 48 49 #include <QtCore/QTimer> … … 54 55 #include <QtCore/QScopedPointer> 55 56 57 #include <cstdio> 58 56 59 namespace trk { 60 61 struct CrashReportState { 62 CrashReportState(); 63 void clear(); 64 65 typedef uint Thread; 66 typedef QList<Thread> Threads; 67 Threads threads; 68 69 QList<uint> registers; 70 QByteArray stack; 71 uint sp; 72 uint fetchingStackPID; 73 uint fetchingStackTID; 74 }; 75 76 CrashReportState::CrashReportState() 77 { 78 clear(); 79 } 80 81 void CrashReportState::clear() 82 { 83 threads.clear(); 84 stack.clear(); 85 sp = fetchingStackPID = fetchingStackTID = 0; 86 } 57 87 58 88 struct LauncherPrivate { … … 62 92 uint copyFileHandle; 63 93 QScopedPointer<QByteArray> data; 64 int position; 94 qint64 position; 95 QScopedPointer<QFile> localFile; 65 96 }; 66 97 … … 76 107 77 108 CopyState m_copyState; 109 CopyState m_downloadState; 78 110 QString m_fileName; 79 111 QStringList m_commandLineArgs; … … 82 114 Launcher::Actions m_startupActions; 83 115 bool m_closeDevice; 116 CrashReportState m_crashReportState; 84 117 }; 85 118 … … 101 134 { 102 135 d->m_startupActions = startupActions; 103 connect(d->m_device.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult))); 104 connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close())); 136 connect(d->m_device.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult))); 105 137 } 106 138 107 139 Launcher::~Launcher() 108 140 { 141 // Destroyed before protocol was through: Close 142 if (d->m_closeDevice && d->m_device->isOpen()) 143 d->m_device->close(); 144 emit destroyed(d->m_device->port()); 109 145 logMessage("Shutting down.\n"); 110 146 delete d; … … 155 191 } 156 192 193 void Launcher::setDownloadFileName(const QString &srcName, const QString &dstName) 194 { 195 d->m_downloadState.sourceFileName = srcName; 196 d->m_downloadState.destinationFileName = dstName; 197 } 198 157 199 void Launcher::setInstallFileName(const QString &name) 158 200 { … … 189 231 { 190 232 errorMessage->clear(); 233 d->m_crashReportState.clear(); 191 234 if (d->m_verbose) { 192 const QString msg = QString::fromLatin1("Port=%1 Executable=%2 Arguments=%3 Package=%4 Remote Package=%5 Install file=%6") 193 .arg(trkServerName(), d->m_fileName, 194 d->m_commandLineArgs.join(QString(QLatin1Char(' '))), 195 d->m_copyState.sourceFileName, d->m_copyState.destinationFileName, d->m_installFileName); 235 QString msg; 236 QTextStream str(&msg); 237 str.setIntegerBase(16); 238 str << "Actions=0x" << d->m_startupActions; 239 str.setIntegerBase(10); 240 str << " Port=" << trkServerName(); 241 if (!d->m_fileName.isEmpty()) 242 str << " Executable=" << d->m_fileName; 243 if (!d->m_commandLineArgs.isEmpty()) 244 str << " Arguments= " << d->m_commandLineArgs.join(QString(QLatin1Char(' '))); 245 if (!d->m_copyState.sourceFileName.isEmpty()) 246 str << " Package/Source=" << d->m_copyState.sourceFileName; 247 if (!d->m_copyState.destinationFileName.isEmpty()) 248 str << " Remote Package/Destination=" << d->m_copyState.destinationFileName; 249 if (!d->m_downloadState.sourceFileName.isEmpty()) 250 str << " Source=" << d->m_downloadState.sourceFileName; 251 if (!d->m_downloadState.destinationFileName.isEmpty()) 252 str << " Destination=" << d->m_downloadState.destinationFileName; 253 if (!d->m_installFileName.isEmpty()) 254 str << " Install file=" << d->m_installFileName; 196 255 logMessage(msg); 197 256 } … … 215 274 if (!d->m_device->isOpen() && !d->m_device->open(errorMessage)) 216 275 return false; 217 if (d->m_closeDevice) {218 connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close()));219 } else {220 disconnect(this, SIGNAL(finished()), d->m_device.data(), 0);221 }222 276 setState(Connecting); 223 277 // Set up the temporary 'waiting' state if we do not get immediate connection … … 253 307 else if (d->m_startupActions & ActionRun) 254 308 startInferiorIfNeeded(); 309 else if (d->m_startupActions & ActionDownload) 310 copyFileFromRemote(); 255 311 } 256 312 … … 265 321 if (d->m_verbose) 266 322 qDebug() << "LAUNCHER: " << qPrintable(msg); 323 } 324 325 void Launcher::handleFinished() 326 { 327 if (d->m_closeDevice) 328 d->m_device->close(); 329 emit finished(); 267 330 } 268 331 … … 288 351 case WaitingForTrk: 289 352 setState(Disconnected); 290 emit finished();353 handleFinished(); 291 354 break; 292 355 } … … 332 395 QByteArray str = result.toString().toUtf8(); 333 396 if (result.isDebugOutput) { // handle application output 334 logMessage("APPLICATION OUTPUT: " + result.data); 335 emit applicationOutputReceived(result.data); 397 QString msg; 398 if (result.multiplex == MuxTextTrace) { 399 if (result.data.length() > 8) { 400 quint64 timestamp = extractInt64(result.data) & 0x0FFFFFFFFFFFFFFFULL; 401 quint64 secs = timestamp / 1000000000; 402 quint64 ns = timestamp % 1000000000; 403 msg = QString("[%1.%2] %3").arg(secs).arg(ns).arg(QString(result.data.mid(8))); 404 logMessage("TEXT TRACE: " + msg); 405 } 406 } else { 407 logMessage("APPLICATION OUTPUT: " + stringFromArray(result.data)); 408 msg = result.data; 409 } 410 msg.replace("\r\n", "\n"); 411 if(!msg.endsWith('\n')) msg.append('\n'); 412 emit applicationOutputReceived(msg); 336 413 return; 337 414 } … … 369 446 // target->host OS notification 370 447 case TrkNotifyCreated: { // Notify Created 371 /*372 const char *data = result.data.data();373 byte error = result.data.at(0);374 byte type = result.data.at(1); // type: 1 byte; for dll item, this value is 2.375 uint pid = extractInt(data + 2); // ProcessID: 4 bytes;376 uint tid = extractInt(data + 6); //threadID: 4 bytes377 uint codeseg = extractInt(data + 10); //code address: 4 bytes; code base address for the library378 uint dataseg = extractInt(data + 14); //data address: 4 bytes; data base address for the library379 uint len = extractShort(data + 18); //length: 2 bytes; length of the library name string to follow380 QByteArray name = result.data.mid(20, len); // name: library name381 382 logMessage(prefix + "NOTE: LIBRARY LOAD: " + str);383 logMessage(prefix + "TOKEN: " + result.token);384 logMessage(prefix + "ERROR: " + int(error));385 logMessage(prefix + "TYPE: " + int(type));386 logMessage(prefix + "PID: " + pid);387 logMessage(prefix + "TID: " + tid);388 logMessage(prefix + "CODE: " + codeseg);389 logMessage(prefix + "DATA: " + dataseg);390 logMessage(prefix + "LEN: " + len);391 logMessage(prefix + "NAME: " + name);392 */393 448 394 449 if (result.data.size() < 10) 395 450 break; 451 const char *data = result.data.constData(); 452 const byte error = result.data.at(0); 453 Q_UNUSED(error) 454 const byte type = result.data.at(1); // type: 1 byte; for dll item, this value is 2. 455 const uint tid = extractInt(data + 6); //threadID: 4 bytes 456 Q_UNUSED(tid) 457 if (type == kDSOSDLLItem && result.data.size() >=20) { 458 const Library lib = Library(result); 459 d->m_session.libraries.push_back(lib); 460 emit libraryLoaded(lib); 461 } 396 462 QByteArray ba; 397 463 ba.append(result.data.mid(2, 8)); 398 464 d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE"); 399 //d->m_device->sendTrkAck(result.token)400 465 break; 401 466 } 402 467 case TrkNotifyDeleted: { // NotifyDeleted 403 468 const ushort itemType = (unsigned char)result.data.at(1); 404 const ushort len = result.data.size() > 12 ? extractShort(result.data.data() + 10) : ushort(0); 469 const uint pid = result.data.size() >= 6 ? extractShort(result.data.constData() + 2) : 0; 470 const uint tid = result.data.size() >= 10 ? extractShort(result.data.constData() + 6) : 0; 471 Q_UNUSED(tid) 472 const ushort len = result.data.size() > 12 ? extractShort(result.data.constData() + 10) : ushort(0); 405 473 const QString name = len ? QString::fromAscii(result.data.mid(12, len)) : QString(); 406 474 logMessage(QString::fromLatin1("%1 %2 UNLOAD: %3"). … … 408 476 arg(name)); 409 477 d->m_device->sendTrkAck(result.token); 410 if (itemType == 0// process478 if (itemType == kDSOSProcessItem // process 411 479 && result.data.size() >= 10 412 480 && d->m_session.pid == extractInt(result.data.data() + 6)) { 413 disconnectTrk(); 481 if (d->m_startupActions & ActionDownload) 482 copyFileFromRemote(); 483 else 484 disconnectTrk(); 485 } 486 else if (itemType == kDSOSDLLItem && len) { 487 // Remove libraries of process. 488 for (QList<Library>::iterator it = d->m_session.libraries.begin(); it != d->m_session.libraries.end(); ) { 489 if ((*it).pid == pid && (*it).name == name) { 490 emit libraryUnloaded(*it); 491 it = d->m_session.libraries.erase(it); 492 } else { 493 ++it; 494 } 495 } 414 496 } 415 497 break; … … 447 529 if (d->m_startupActions == ActionPingOnly) { 448 530 setState(Disconnected); 449 emit finished();531 handleFinished(); 450 532 } 451 533 return; … … 456 538 d->m_session.trkAppVersion.protocolMinor = result.data.at(4); 457 539 setState(DeviceDescriptionReceived); 540 const QString msg = deviceDescription(); 541 emit deviceDescriptionReceived(trkServerName(), msg); 458 542 // Ping mode: Log & Terminate 459 543 if (d->m_startupActions == ActionPingOnly) { 460 qWarning("%s", qPrintable( deviceDescription()));544 qWarning("%s", qPrintable(msg)); 461 545 setState(Disconnected); 462 emit finished(); 463 } 546 handleFinished(); 547 } 548 } 549 550 static inline QString msgCannotOpenRemoteFile(const QString &fileName, const QString &message) 551 { 552 return Launcher::tr("Cannot open remote file '%1': %2").arg(fileName, message); 553 } 554 555 static inline QString msgCannotOpenLocalFile(const QString &fileName, const QString &message) 556 { 557 return Launcher::tr("Cannot open '%1': %2").arg(fileName, message); 464 558 } 465 559 … … 467 561 { 468 562 if (result.errorCode() || result.data.size() < 6) { 469 emit canNotCreateFile(d->m_copyState.destinationFileName, result.errorString()); 563 const QString msg = msgCannotOpenRemoteFile(d->m_copyState.destinationFileName, result.errorString()); 564 logMessage(msg); 565 emit canNotCreateFile(d->m_copyState.destinationFileName, msg); 470 566 disconnectTrk(); 471 567 return; … … 473 569 const char *data = result.data.data(); 474 570 d->m_copyState.copyFileHandle = extractInt(data + 2); 475 QFile file(d->m_copyState.sourceFileName); 476 file.open(QIODevice::ReadOnly); 571 const QString localFileName = d->m_copyState.sourceFileName; 572 QFile file(localFileName); 573 d->m_copyState.position = 0; 574 if (!file.open(QIODevice::ReadOnly)) { 575 const QString msg = msgCannotOpenLocalFile(localFileName, file.errorString()); 576 logMessage(msg); 577 emit canNotOpenLocalFile(localFileName, msg); 578 closeRemoteFile(true); 579 disconnectTrk(); 580 return; 581 } 477 582 d->m_copyState.data.reset(new QByteArray(file.readAll())); 478 d->m_copyState.position = 0;479 583 file.close(); 480 584 continueCopying(); 585 } 586 587 void Launcher::handleFileOpened(const TrkResult &result) 588 { 589 if (result.errorCode() || result.data.size() < 6) { 590 const QString msg = msgCannotOpenRemoteFile(d->m_downloadState.sourceFileName, result.errorString()); 591 logMessage(msg); 592 emit canNotOpenFile(d->m_downloadState.sourceFileName, msg); 593 disconnectTrk(); 594 return; 595 } 596 d->m_downloadState.position = 0; 597 const QString localFileName = d->m_downloadState.destinationFileName; 598 bool opened = false; 599 if (localFileName == QLatin1String("-")) { 600 d->m_downloadState.localFile.reset(new QFile); 601 opened = d->m_downloadState.localFile->open(stdout, QFile::WriteOnly); 602 } else { 603 d->m_downloadState.localFile.reset(new QFile(localFileName)); 604 opened = d->m_downloadState.localFile->open(QFile::WriteOnly | QFile::Truncate); 605 } 606 if (!opened) { 607 const QString msg = msgCannotOpenLocalFile(localFileName, d->m_downloadState.localFile->errorString()); 608 logMessage(msg); 609 emit canNotOpenLocalFile(localFileName, msg); 610 closeRemoteFile(true); 611 disconnectTrk(); 612 } 613 continueReading(); 614 } 615 616 void Launcher::continueReading() 617 { 618 QByteArray ba; 619 appendInt(&ba, d->m_downloadState.copyFileHandle, TargetByteOrder); 620 appendShort(&ba, 2048, TargetByteOrder); 621 d->m_device->sendTrkMessage(TrkReadFile, TrkCallback(this, &Launcher::handleRead), ba); 622 } 623 624 void Launcher::handleRead(const TrkResult &result) 625 { 626 if (result.errorCode() || result.data.size() < 4) { 627 d->m_downloadState.localFile->close(); 628 closeRemoteFile(true); 629 disconnectTrk(); 630 } else { 631 int length = extractShort(result.data.data() + 2); 632 //TRK doesn't tell us the file length, so we need to keep reading until it returns 0 length 633 if (length > 0) { 634 d->m_downloadState.localFile->write(result.data.data() + 4, length); 635 continueReading(); 636 } else { 637 closeRemoteFile(true); 638 disconnectTrk(); 639 } 640 } 481 641 } 482 642 … … 494 654 void Launcher::continueCopying(uint lastCopiedBlockSize) 495 655 { 496 intsize = d->m_copyState.data->length();656 qint64 size = d->m_copyState.data->length(); 497 657 d->m_copyState.position += lastCopiedBlockSize; 498 658 if (size == 0) 499 659 emit copyProgress(100); 500 660 else { 501 int percent = qMin((d->m_copyState.position*100)/size, 100); 502 emit copyProgress(percent); 661 const qint64 hundred = 100; 662 const qint64 percent = qMin( (d->m_copyState.position * hundred) / size, hundred); 663 emit copyProgress(static_cast<int>(percent)); 503 664 } 504 665 if (d->m_copyState.position < size) { … … 533 694 else if (d->m_startupActions & ActionRun) 534 695 startInferiorIfNeeded(); 696 else if (d->m_startupActions & ActionDownload) 697 copyFileFromRemote(); 535 698 else 536 699 disconnectTrk(); … … 577 740 } 578 741 emit applicationRunning(d->m_session.pid); 742 //create a "library" entry for the executable which launched the process 743 Library lib; 744 lib.pid = d->m_session.pid; 745 lib.codeseg = d->m_session.codeseg; 746 lib.dataseg = d->m_session.dataseg; 747 lib.name = d->m_fileName.toUtf8(); 748 d->m_session.libraries << lib; 749 emit libraryLoaded(lib); 750 579 751 QByteArray ba; 580 752 appendInt(&ba, d->m_session.pid); … … 587 759 logMessage(" FINISHED: " + stringFromArray(result.data)); 588 760 setState(Disconnected); 589 emit finished();761 handleFinished(); 590 762 } 591 763 … … 596 768 const char *data = result.data.data() + 1; 597 769 598 QString str = QLatin1String("SUPPORTED: "); 599 for (int i = 0; i < 32; ++i) { 600 //str.append(" [" + formatByte(data[i]) + "]: "); 601 for (int j = 0; j < 8; ++j) { 602 if (data[i] & (1 << j)) { 603 str.append(QString::number(i * 8 + j, 16)); 604 str.append(QLatin1Char(' ')); 770 if (d->m_verbose > 1) { 771 QString str = QLatin1String("SUPPORTED: "); 772 for (int i = 0; i < 32; ++i) { 773 for (int j = 0; j < 8; ++j) { 774 if (data[i] & (1 << j)) { 775 str.append(QString::number(i * 8 + j, 16)); 776 str.append(QLatin1Char(' ')); 777 } 605 778 } 606 779 } 607 }608 logMessage(str);780 logMessage(str); 781 } 609 782 } 610 783 … … 670 843 emit copyingStarted(); 671 844 QByteArray ba; 672 ba.append(char(10)); 845 ba.append(char(10)); //kDSFileOpenWrite | kDSFileOpenBinary 673 846 appendString(&ba, d->m_copyState.destinationFileName.toLocal8Bit(), TargetByteOrder, false); 674 847 d->m_device->sendTrkMessage(TrkOpenFile, TrkCallback(this, &Launcher::handleFileCreation), ba); 848 } 849 850 void Launcher::copyFileFromRemote() 851 { 852 emit copyingStarted(); 853 QByteArray ba; 854 ba.append(char(9)); //kDSFileOpenRead | kDSFileOpenBinary 855 appendString(&ba, d->m_downloadState.sourceFileName.toLocal8Bit(), TargetByteOrder, false); 856 d->m_device->sendTrkMessage(TrkOpenFile, TrkCallback(this, &Launcher::handleFileOpened), ba); 675 857 } 676 858 … … 695 877 if (d->m_startupActions & ActionRun) { 696 878 startInferiorIfNeeded(); 879 } else if (d->m_startupActions & ActionDownload) { 880 copyFileFromRemote(); 697 881 } else { 698 882 disconnectTrk(); … … 705 889 // It's not started yet 706 890 QByteArray ba; 707 appendShort(&ba, 0, TargetByteOrder); // create new process 891 appendShort(&ba, 0, TargetByteOrder); // create new process (kDSOSProcessItem) 708 892 ba.append(char(0)); // options - currently unused 709 if(arguments.isEmpty()) { 710 appendString(&ba, executable.toLocal8Bit(), TargetByteOrder); 711 return ba; 712 } 713 // Append full command line as one string (leading length information). 714 QByteArray commandLineBa; 715 commandLineBa.append(executable.toLocal8Bit()); 716 commandLineBa.append('\0'); 717 commandLineBa.append(arguments.join(QString(QLatin1Char(' '))).toLocal8Bit()); 718 appendString(&ba, commandLineBa, TargetByteOrder); 893 // One string consisting of binary terminated by '\0' and arguments terminated by '\0' 894 QByteArray commandLineBa = executable.toLocal8Bit(); 895 commandLineBa.append(char(0)); 896 if (!arguments.isEmpty()) 897 commandLineBa.append(arguments.join(QString(QLatin1Char(' '))).toLocal8Bit()); 898 appendString(&ba, commandLineBa, TargetByteOrder, true); 899 return ba; 900 } 901 902 QByteArray Launcher::readMemoryMessage(uint pid, uint tid, uint from, uint len) 903 { 904 QByteArray ba; 905 ba.reserve(11); 906 ba.append(char(0x8)); // Options, FIXME: why? 907 appendShort(&ba, len); 908 appendInt(&ba, from); 909 appendInt(&ba, pid); 910 appendInt(&ba, tid); 911 return ba; 912 } 913 914 QByteArray Launcher::readRegistersMessage(uint pid, uint tid) 915 { 916 QByteArray ba; 917 ba.reserve(15); 918 ba.append(char(0)); // Register set, only 0 supported 919 appendShort(&ba, 0); //R0 920 appendShort(&ba, 16); // last register CPSR 921 appendInt(&ba, pid); 922 appendInt(&ba, tid); 719 923 return ba; 720 924 } … … 738 942 d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE"); 739 943 } 944 945 // Acquire a device from SymbianDeviceManager, return 0 if not available. 946 Launcher *Launcher::acquireFromDeviceManager(const QString &serverName, 947 QObject *parent, 948 QString *errorMessage) 949 { 950 SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance(); 951 const QSharedPointer<trk::TrkDevice> device = sdm->acquireDevice(serverName); 952 if (device.isNull()) { 953 *errorMessage = tr("Unable to acquire a device for port '%1'. It appears to be in use.").arg(serverName); 954 return 0; 955 } 956 // Wire release signal. 957 Launcher *rc = new Launcher(trk::Launcher::ActionPingOnly, device, parent); 958 connect(rc, SIGNAL(deviceDescriptionReceived(QString,QString)), 959 sdm, SLOT(setAdditionalInformation(QString,QString))); 960 connect(rc, SIGNAL(destroyed(QString)), sdm, SLOT(releaseDevice(QString))); 961 return rc; 962 } 963 964 // Preliminary release of device, disconnecting the signal. 965 void Launcher::releaseToDeviceManager(Launcher *launcher) 966 { 967 SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance(); 968 // Disentangle launcher and its device, remove connection from destroyed 969 launcher->setCloseDevice(false); 970 TrkDevice *device = launcher->trkDevice().data(); 971 launcher->disconnect(device); 972 device->disconnect(launcher); 973 launcher->disconnect(sdm); 974 sdm->releaseDevice(launcher->trkServerName()); 975 } 976 977 void Launcher::getRegistersAndCallStack(uint pid, uint tid) 978 { 979 d->m_device->sendTrkMessage(TrkReadRegisters, 980 TrkCallback(this, &Launcher::handleReadRegisters), 981 Launcher::readRegistersMessage(pid, tid)); 982 d->m_crashReportState.fetchingStackPID = pid; 983 d->m_crashReportState.fetchingStackTID = tid; 984 } 985 986 void Launcher::handleReadRegisters(const TrkResult &result) 987 { 988 if(result.errorCode() || result.data.size() < (17*4)) { 989 terminate(); 990 return; 991 } 992 const char* data = result.data.constData() + 1; 993 d->m_crashReportState.registers.clear(); 994 d->m_crashReportState.stack.clear(); 995 for (int i=0;i<17;i++) { 996 uint r = extractInt(data); 997 data += 4; 998 d->m_crashReportState.registers.append(r); 999 } 1000 d->m_crashReportState.sp = d->m_crashReportState.registers.at(13); 1001 1002 const ushort len = 1024 - (d->m_crashReportState.sp % 1024); //read to 1k boundary first 1003 const QByteArray ba = Launcher::readMemoryMessage(d->m_crashReportState.fetchingStackPID, 1004 d->m_crashReportState.fetchingStackTID, 1005 d->m_crashReportState.sp, 1006 len); 1007 d->m_device->sendTrkMessage(TrkReadMemory, TrkCallback(this, &Launcher::handleReadStack), ba); 1008 d->m_crashReportState.sp += len; 1009 } 1010 1011 void Launcher::handleReadStack(const TrkResult &result) 1012 { 1013 if (result.errorCode()) { 1014 //error implies memory fault when reaching end of stack 1015 emit registersAndCallStackReadComplete(d->m_crashReportState.registers, d->m_crashReportState.stack); 1016 return; 1017 } 1018 1019 const uint len = extractShort(result.data.constData() + 1); 1020 d->m_crashReportState.stack.append(result.data.mid(3, len)); 1021 1022 if (d->m_crashReportState.sp - d->m_crashReportState.registers.at(13) > 0x10000) { 1023 //read enough stack, stop here 1024 emit registersAndCallStackReadComplete(d->m_crashReportState.registers, d->m_crashReportState.stack); 1025 return; 1026 } 1027 //read 1k more 1028 const QByteArray ba = Launcher::readMemoryMessage(d->m_crashReportState.fetchingStackPID, 1029 d->m_crashReportState.fetchingStackTID, 1030 d->m_crashReportState.sp, 1031 1024); 1032 d->m_device->sendTrkMessage(TrkReadMemory, TrkCallback(this, &Launcher::handleReadStack), ba); 1033 d->m_crashReportState.sp += 1024; 1034 } 1035 740 1036 } // namespace trk -
trunk/tools/runonphone/symbianutils/launcher.h
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) … … 44 44 45 45 #include "trkdevice.h" 46 #include "trkutils.h" 46 47 47 48 #include <QtCore/QObject> … … 70 71 ActionCopyInstall = ActionCopy | ActionInstall, 71 72 ActionRun = 0x4, 73 ActionDownload = 0x8, 72 74 ActionCopyRun = ActionCopy | ActionRun, 73 75 ActionInstallRun = ActionInstall | ActionRun, … … 95 97 void setFileName(const QString &name); 96 98 void setCopyFileName(const QString &srcName, const QString &dstName); 99 void setDownloadFileName(const QString &srcName, const QString &dstName); 97 100 void setInstallFileName(const QString &name); 98 101 void setCommandLineArgs(const QStringList &args); 99 102 bool startServer(QString *errorMessage); 100 void setVerbose(int v); 103 void setVerbose(int v); 101 104 void setSerialFrame(bool b); 102 105 bool serialFrame() const; … … 110 113 QString deviceDescription(unsigned verbose = 0u) const; 111 114 115 // Acquire a device from SymbianDeviceManager, return 0 if not available. 116 // The device will be released on destruction. 117 static Launcher *acquireFromDeviceManager(const QString &serverName, 118 QObject *parent, 119 QString *errorMessage); 120 // Preliminary release of device, disconnecting the signal. 121 static void releaseToDeviceManager(Launcher *l); 122 123 // Create Trk message to start a process. 112 124 static QByteArray startProcessMessage(const QString &executable, 113 125 const QStringList &arguments); 126 // Create Trk message to read memory 127 static QByteArray readMemoryMessage(uint pid, uint tid, uint from, uint len); 128 static QByteArray readRegistersMessage(uint pid, uint tid); 114 129 // Parse a TrkNotifyStopped message 115 130 static bool parseNotifyStopped(const QByteArray &a, … … 120 135 121 136 signals: 137 void deviceDescriptionReceived(const QString &port, const QString &description); 122 138 void copyingStarted(); 123 139 void canNotConnect(const QString &errorMessage); 124 140 void canNotCreateFile(const QString &filename, const QString &errorMessage); 141 void canNotOpenFile(const QString &filename, const QString &errorMessage); 142 void canNotOpenLocalFile(const QString &filename, const QString &errorMessage); 125 143 void canNotWriteFile(const QString &filename, const QString &errorMessage); 126 144 void canNotCloseFile(const QString &filename, const QString &errorMessage); … … 136 154 void stateChanged(int); 137 155 void processStopped(uint pc, uint pid, uint tid, const QString& reason); 156 void processResumed(uint pid, uint tid); 157 void libraryLoaded(const trk::Library &lib); 158 void libraryUnloaded(const trk::Library &lib); 159 void registersAndCallStackReadComplete(const QList<uint>& registers, const QByteArray& stack); 160 // Emitted by the destructor, for releasing devices of SymbianDeviceManager by name 161 void destroyed(const QString &serverName); 138 162 139 163 public slots: 140 164 void terminate(); 141 165 void resumeProcess(uint pid, uint tid); 166 //can be used to obtain traceback after a breakpoint / exception 167 void getRegistersAndCallStack(uint pid, uint tid); 142 168 143 169 private slots: … … 153 179 void handleConnect(const TrkResult &result); 154 180 void handleFileCreation(const TrkResult &result); 181 void handleFileOpened(const TrkResult &result); 155 182 void handleCopy(const TrkResult &result); 183 void handleRead(const TrkResult &result); 156 184 void continueCopying(uint lastCopiedBlockSize = 0); 185 void continueReading(); 157 186 void closeRemoteFile(bool failed = false); 158 187 void handleFileCopied(const TrkResult &result); … … 164 193 void handleSupportMask(const TrkResult &result); 165 194 void handleTrkVersion(const TrkResult &result); 195 void handleReadRegisters(const TrkResult &result); 196 void handleReadStack(const TrkResult &result); 166 197 167 198 void copyFileToRemote(); 199 void copyFileFromRemote(); 168 200 void installRemotePackageSilently(); 169 201 void startInferiorIfNeeded(); 202 void handleFinished(); 170 203 171 204 void logMessage(const QString &msg); -
trunk/tools/runonphone/symbianutils/symbiandevicemanager.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) … … 41 41 42 42 #include "symbiandevicemanager.h" 43 #include "trkdevice.h" 43 44 44 45 #include <QtCore/QSettings> … … 49 50 #include <QtCore/QSharedData> 50 51 #include <QtCore/QScopedPointer> 52 #include <QtCore/QSignalMapper> 51 53 52 54 namespace SymbianUtils { … … 62 64 class SymbianDeviceData : public QSharedData { 63 65 public: 64 SymbianDeviceData() : type(SerialPortCommunication) {} 66 SymbianDeviceData(); 67 ~SymbianDeviceData(); 68 69 inline bool isOpen() const { return !device.isNull() && device->isOpen(); } 70 void forcedClose(); 65 71 66 72 QString portName; … … 68 74 QString deviceDesc; 69 75 QString manufacturer; 76 QString additionalInformation; 77 70 78 DeviceCommunicationType type; 79 QSharedPointer<trk::TrkDevice> device; 80 bool deviceAcquired; 71 81 }; 82 83 SymbianDeviceData::SymbianDeviceData() : 84 type(SerialPortCommunication), 85 deviceAcquired(false) 86 { 87 } 88 89 SymbianDeviceData::~SymbianDeviceData() 90 { 91 forcedClose(); 92 } 93 94 void SymbianDeviceData::forcedClose() 95 { 96 // Close the device when unplugging. Should devices be in 'acquired' state, 97 // their owners should hit on write failures. 98 // Apart from the <shared item> destructor, also called by the devicemanager 99 // to ensure it also happens if other shared instances are still around. 100 if (isOpen()) { 101 if (deviceAcquired) 102 qWarning("Device on '%s' unplugged while an operation is in progress.", 103 qPrintable(portName)); 104 device->close(); 105 } 106 } 72 107 73 108 SymbianDevice::SymbianDevice(SymbianDeviceData *data) : 74 109 m_data(data) 75 110 { 76 77 111 } 78 112 … … 97 131 } 98 132 133 void SymbianDevice::forcedClose() 134 { 135 m_data->forcedClose(); 136 } 137 99 138 QString SymbianDevice::portName() const 100 139 { … … 107 146 } 108 147 148 QString SymbianDevice::additionalInformation() const 149 { 150 return m_data->additionalInformation; 151 } 152 153 void SymbianDevice::setAdditionalInformation(const QString &a) 154 { 155 m_data->additionalInformation = a; 156 } 157 158 SymbianDevice::TrkDevicePtr SymbianDevice::acquireDevice() 159 { 160 if (debug) 161 qDebug() << "SymbianDevice::acquireDevice" << m_data->portName 162 << "acquired: " << m_data->deviceAcquired << " open: " << isOpen(); 163 if (isNull() || m_data->deviceAcquired) 164 return TrkDevicePtr(); 165 if (m_data->device.isNull()) { 166 m_data->device = TrkDevicePtr(new trk::TrkDevice); 167 m_data->device->setPort(m_data->portName); 168 m_data->device->setSerialFrame(m_data->type == SerialPortCommunication); 169 } 170 m_data->deviceAcquired = true; 171 return m_data->device; 172 } 173 174 void SymbianDevice::releaseDevice(TrkDevicePtr *ptr /* = 0 */) 175 { 176 if (debug) 177 qDebug() << "SymbianDevice::releaseDevice" << m_data->portName 178 << " open: " << isOpen(); 179 if (m_data->deviceAcquired) { 180 if (m_data->device->isOpen()) 181 m_data->device->clearWriteQueue(); 182 // Release if a valid pointer was passed in. 183 if (ptr && !ptr->isNull()) { 184 ptr->data()->disconnect(); 185 *ptr = TrkDevicePtr(); 186 } 187 m_data->deviceAcquired = false; 188 } else { 189 qWarning("Internal error: Attempt to release device that is not acquired."); 190 } 191 } 192 109 193 QString SymbianDevice::deviceDesc() const 110 194 { … … 124 208 bool SymbianDevice::isNull() const 125 209 { 126 return !m_data->portName.isEmpty(); 210 return m_data->portName.isEmpty(); 211 } 212 213 bool SymbianDevice::isOpen() const 214 { 215 return m_data->isOpen(); 127 216 } 128 217 … … 159 248 } 160 249 161 QDebug operator<<(QDebug d, const SymbianDevice &cd)250 SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDevice &cd) 162 251 { 163 252 d.nospace() << cd.toString(); … … 167 256 // ------------- SymbianDeviceManagerPrivate 168 257 struct SymbianDeviceManagerPrivate { 169 SymbianDeviceManagerPrivate() : m_initialized(false) {}258 SymbianDeviceManagerPrivate() : m_initialized(false), m_destroyReleaseMapper(0) {} 170 259 171 260 bool m_initialized; 172 261 SymbianDeviceManager::SymbianDeviceList m_devices; 262 QSignalMapper *m_destroyReleaseMapper; 173 263 }; 174 264 … … 186 276 SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::devices() const 187 277 { 188 if (!d->m_initialized) 189 const_cast<SymbianDeviceManager*>(this)->update(false); 278 ensureInitialized(); 190 279 return d->m_devices; 191 280 } … … 195 284 QString rc; 196 285 QTextStream str(&rc); 286 str << d->m_devices.size() << " devices:\n"; 197 287 const int count = d->m_devices.size(); 198 288 for (int i = 0; i < count; i++) { … … 204 294 } 205 295 296 int SymbianDeviceManager::findByPortName(const QString &p) const 297 { 298 ensureInitialized(); 299 const int count = d->m_devices.size(); 300 for (int i = 0; i < count; i++) 301 if (d->m_devices.at(i).portName() == p) 302 return i; 303 return -1; 304 } 305 206 306 QString SymbianDeviceManager::friendlyNameForPort(const QString &port) const 207 307 { 208 foreach (const SymbianDevice &device, d->m_devices) { 209 if (device.portName() == port) 210 return device.friendlyName(); 211 } 212 return QString(); 308 const int idx = findByPortName(port); 309 return idx == -1 ? QString() : d->m_devices.at(idx).friendlyName(); 310 } 311 312 SymbianDeviceManager::TrkDevicePtr 313 SymbianDeviceManager::acquireDevice(const QString &port) 314 { 315 ensureInitialized(); 316 const int idx = findByPortName(port); 317 if (idx == -1) { 318 qWarning("Attempt to acquire device '%s' that does not exist.", qPrintable(port)); 319 if (debug) 320 qDebug() << *this; 321 return TrkDevicePtr(); 322 } 323 const TrkDevicePtr rc = d->m_devices[idx].acquireDevice(); 324 if (debug) 325 qDebug() << "SymbianDeviceManager::acquireDevice" << port << " returns " << !rc.isNull(); 326 return rc; 213 327 } 214 328 … … 218 332 } 219 333 334 void SymbianDeviceManager::releaseDevice(const QString &port) 335 { 336 const int idx = findByPortName(port); 337 if (debug) 338 qDebug() << "SymbianDeviceManager::releaseDevice" << port << idx << sender(); 339 if (idx != -1) { 340 d->m_devices[idx].releaseDevice(); 341 } else { 342 qWarning("Attempt to release non-existing device %s.", qPrintable(port)); 343 } 344 } 345 346 void SymbianDeviceManager::setAdditionalInformation(const QString &port, const QString &ai) 347 { 348 const int idx = findByPortName(port); 349 if (idx != -1) 350 d->m_devices[idx].setAdditionalInformation(ai); 351 } 352 353 void SymbianDeviceManager::ensureInitialized() const 354 { 355 if (!d->m_initialized) // Flag is set in update() 356 const_cast<SymbianDeviceManager*>(this)->update(false); 357 } 358 220 359 void SymbianDeviceManager::update(bool emitSignals) 221 360 { 361 static int n = 0; 222 362 typedef SymbianDeviceList::iterator SymbianDeviceListIterator; 223 363 224 364 if (debug) 225 qDebug(">SerialDeviceLister::update( %d)\n%s", int(emitSignals),365 qDebug(">SerialDeviceLister::update(#%d, signals=%d)\n%s", n++, int(emitSignals), 226 366 qPrintable(toString())); 227 367 … … 231 371 if (newDevices.size() > 1) 232 372 qStableSort(newDevices.begin(), newDevices.end()); 233 if (d->m_devices == newDevices) // Happy, nothing changed. 373 if (d->m_devices == newDevices) { // Happy, nothing changed. 374 if (debug) 375 qDebug("<SerialDeviceLister::update: unchanged\n"); 234 376 return; 377 } 235 378 // Merge the lists and emit the respective added/removed signals, assuming 236 379 // no one can plug a different device on the same port at the speed of lightning … … 241 384 ++oldIt; 242 385 } else { 243 const SymbianDevice toBeDeleted = *oldIt; 386 SymbianDevice toBeDeleted = *oldIt; 387 toBeDeleted.forcedClose(); 244 388 oldIt = d->m_devices.erase(oldIt); 245 389 if (emitSignals) … … 302 446 // or at least the first one. 303 447 const QString prefix = QLatin1String(linuxBlueToothDeviceRootC); 304 const QString friendlyFormat = QLatin1String("Bluetooth device (%1)");448 const QString blueToothfriendlyFormat = QLatin1String("Bluetooth device (%1)"); 305 449 for (int d = 0; d < 4; d++) { 306 450 QScopedPointer<SymbianDeviceData> device(new SymbianDeviceData); … … 308 452 device->portName = prefix + QString::number(d); 309 453 if (d == 0 || QFileInfo(device->portName).exists()) { 310 device->friendlyName = friendlyFormat.arg(device->portName);454 device->friendlyName = blueToothfriendlyFormat.arg(device->portName); 311 455 rc.push_back(SymbianDevice(device.take())); 456 } 457 } 458 // New kernel versions support /dev/ttyUSB0, /dev/ttyUSB1. Trk responds 459 // on the latter (usually), try first. 460 static const char *usbTtyDevices[] = { "/dev/ttyUSB1", "/dev/ttyUSB0" }; 461 const int usbTtyCount = sizeof(usbTtyDevices)/sizeof(const char *); 462 for (int d = 0; d < usbTtyCount; d++) { 463 const QString ttyUSBDevice = QLatin1String(usbTtyDevices[d]); 464 if (QFileInfo(ttyUSBDevice).exists()) { 465 SymbianDeviceData *device = new SymbianDeviceData; 466 device->type = SerialPortCommunication; 467 device->portName = ttyUSBDevice; 468 device->friendlyName = QString::fromLatin1("USB/Serial device (%1)").arg(device->portName); 469 rc.push_back(SymbianDevice(device)); 312 470 } 313 471 } … … 323 481 } 324 482 325 QDebug operator<<(QDebug d, const SymbianDeviceManager &sdm)483 SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDeviceManager &sdm) 326 484 { 327 485 d.nospace() << sdm.toString(); -
trunk/tools/runonphone/symbianutils/symbiandevicemanager.h
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) … … 47 47 #include <QtCore/QObject> 48 48 #include <QtCore/QExplicitlySharedDataPointer> 49 #include <QtCore/QSharedPointer> 49 50 50 51 QT_BEGIN_NAMESPACE … … 52 53 class QTextStream; 53 54 QT_END_NAMESPACE 55 56 namespace trk { 57 class TrkDevice; 58 } 54 59 55 60 namespace SymbianUtils { … … 63 68 }; 64 69 65 // SymbianDevice, explicitly shared. 70 // SymbianDevice: Explicitly shared device data and a TrkDevice 71 // instance that can be acquired (exclusively) for use. 72 // A device removal from the manager will result in the 73 // device being closed. 66 74 class SYMBIANUTILS_EXPORT SymbianDevice { 67 75 explicit SymbianDevice(SymbianDeviceData *data); 68 76 friend class SymbianDeviceManager; 69 77 public: 78 typedef QSharedPointer<trk::TrkDevice> TrkDevicePtr; 79 70 80 SymbianDevice(); 71 81 SymbianDevice(const SymbianDevice &rhs); … … 78 88 QString portName() const; 79 89 QString friendlyName() const; 90 QString additionalInformation() const; 91 void setAdditionalInformation(const QString &); 92 93 // Acquire: Mark the device as 'out' and return a shared pointer 94 // unless it is already in use by another owner. The result should not 95 // be passed on further. 96 TrkDevicePtr acquireDevice(); 97 // Give back a device and mark it as 'free'. 98 void releaseDevice(TrkDevicePtr *ptr = 0); 99 100 bool isOpen() const; 80 101 81 102 // Windows only. … … 87 108 88 109 private: 110 void forcedClose(); 111 89 112 QExplicitlySharedDataPointer<SymbianDeviceData> m_data; 90 113 }; 91 114 92 QDebug operator<<(QDebug d, const SymbianDevice &);115 SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDevice &); 93 116 94 117 inline bool operator==(const SymbianDevice &d1, const SymbianDevice &d2) … … 101 124 /* SymbianDeviceManager: Singleton that maintains a list of Symbian devices. 102 125 * and emits change signals. 103 * On Windows, the update slot must be connected to a signal 104 * emitted from an event handler listening for WM_DEVICECHANGE. */ 126 * On Windows, the update slot must be connected to a [delayed] signal 127 * emitted from an event handler listening for WM_DEVICECHANGE. 128 * Device removal will result in the device being closed. */ 105 129 class SYMBIANUTILS_EXPORT SymbianDeviceManager : public QObject 106 130 { … … 108 132 public: 109 133 typedef QList<SymbianDevice> SymbianDeviceList; 134 typedef QSharedPointer<trk::TrkDevice> TrkDevicePtr; 110 135 111 136 static const char *linuxBlueToothDeviceRootC; … … 121 146 QString toString() const; 122 147 148 // Acquire a device for use. See releaseDevice(). 149 TrkDevicePtr acquireDevice(const QString &port); 150 151 int findByPortName(const QString &p) const; 123 152 QString friendlyNameForPort(const QString &port) const; 124 153 125 154 public slots: 126 155 void update(); 156 // Relase a device, make it available for further use. 157 void releaseDevice(const QString &port); 158 void setAdditionalInformation(const QString &port, const QString &ai); 127 159 128 160 signals: 129 void deviceRemoved(const Symbian Device &d);130 void deviceAdded(const Symbian Device &d);161 void deviceRemoved(const SymbianUtils::SymbianDevice &d); 162 void deviceAdded(const SymbianUtils::SymbianDevice &d); 131 163 void updated(); 132 164 133 165 private: 166 void ensureInitialized() const; 134 167 void update(bool emitSignals); 135 168 SymbianDeviceList serialPorts() const; … … 139 172 }; 140 173 141 QDebug operator<<(QDebug d, const SymbianDeviceManager &);174 SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDeviceManager &); 142 175 143 176 } // namespace SymbianUtils -
trunk/tools/runonphone/symbianutils/symbianutils.pri
r769 r846 1 1 INCLUDEPATH *= $$PWD 2 3 QT += network 2 4 3 5 # Input … … 10 12 $$PWD/bluetoothlistener.h \ 11 13 $$PWD/communicationstarter.h \ 12 $$PWD/symbiandevicemanager.h 14 $$PWD/symbiandevicemanager.h \ 15 $$PWD/tcftrkdevice.h \ 16 $$PWD/tcftrkmessage.h \ 17 $$PWD/json.h 13 18 14 19 SOURCES += $$PWD/trkutils.cpp \ … … 17 22 $$PWD/bluetoothlistener.cpp \ 18 23 $$PWD/communicationstarter.cpp \ 19 $$PWD/symbiandevicemanager.cpp 24 $$PWD/symbiandevicemanager.cpp \ 25 $$PWD/tcftrkdevice.cpp \ 26 $$PWD/tcftrkmessage.cpp \ 27 $$PWD/json.cpp 20 28 21 29 # Tests/trklauncher is a console application -
trunk/tools/runonphone/symbianutils/symbianutils_global.h
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) -
trunk/tools/runonphone/symbianutils/trkdevice.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) … … 53 53 #include <QtCore/QWaitCondition> 54 54 #include <QtCore/QSharedPointer> 55 #include <QtCore/QScopedPointer> 55 56 #include <QtCore/QMetaType> 56 57 … … 103 104 enum { verboseTrk = 0 }; 104 105 106 static inline QString msgAccessingClosedDevice(const QString &msg) 107 { 108 return QString::fromLatin1("Error: Attempt to access device '%1', which is closed.").arg(msg); 109 } 110 105 111 namespace trk { 106 112 … … 156 162 157 163 class TrkWriteQueue 158 { 164 { 159 165 Q_DISABLE_COPY(TrkWriteQueue) 160 166 public: 161 167 explicit TrkWriteQueue(); 168 void clear(); 162 169 163 170 // Enqueue messages. … … 209 216 } 210 217 218 void TrkWriteQueue::clear() 219 { 220 m_trkWriteToken = 0; 221 m_trkWriteBusy = false; 222 m_trkWriteQueue.clear(); 223 const int discarded = m_writtenTrkMessages.size(); 224 m_writtenTrkMessages.clear(); 225 if (verboseTrk) 226 qDebug() << "TrkWriteQueue::clear: discarded " << discarded; 227 } 228 211 229 byte TrkWriteQueue::nextTrkWriteToken() 212 230 { … … 215 233 ++m_trkWriteToken; 216 234 if (verboseTrk) 217 qDebug() << " Write token:" << m_trkWriteToken;235 qDebug() << "nextTrkWriteToken:" << m_trkWriteToken; 218 236 return m_trkWriteToken; 219 237 } … … 350 368 Q_OBJECT 351 369 Q_DISABLE_COPY(WriterThread) 352 public: 370 public: 353 371 explicit WriterThread(const QSharedPointer<DeviceContext> &context); 354 372 … … 358 376 void queueTrkInitialPing(); 359 377 378 void clearWriteQueue(); 379 360 380 // Call this from the device read notification with the results. 361 381 void slotHandleResult(const TrkResult &result); … … 375 395 void invokeNoopMessage(const trk::TrkMessage &); 376 396 377 private: 397 private: 378 398 bool write(const QByteArray &data, QString *errorMessage); 379 399 inline int writePendingMessage(); … … 463 483 wait(); 464 484 m_terminate = false; 485 m_queue.clear(); 465 486 } 466 487 … … 562 583 } 563 584 585 void WriterThread::clearWriteQueue() 586 { 587 m_dataMutex.lock(); 588 m_queue.clear(); 589 m_dataMutex.unlock(); 590 } 591 564 592 void WriterThread::queueTrkInitialPing() 565 593 { … … 593 621 public: 594 622 623 int bytesPending() const { return m_trkReadBuffer.size(); } 624 595 625 signals: 596 626 void messageReceived(const trk::TrkResult &result, const QByteArray &rawData); … … 607 637 608 638 QByteArray m_trkReadBuffer; 639 bool linkEstablishmentMode; 609 640 }; 610 641 611 642 ReaderThreadBase::ReaderThreadBase(const QSharedPointer<DeviceContext> &context) : 612 m_context(context) 643 m_context(context), linkEstablishmentMode(true) 613 644 { 614 645 static const int trkResultMetaId = qRegisterMetaType<trk::TrkResult>(); … … 633 664 TrkResult r; 634 665 QByteArray rawData; 635 while (extractResult(&m_trkReadBuffer, m_context->serialFrame, &r, &rawData)) {666 while (extractResult(&m_trkReadBuffer, m_context->serialFrame, &r, linkEstablishmentMode, &rawData)) { 636 667 emit messageReceived(r, rawData); 637 668 } … … 693 724 emit error(QString::fromLatin1("ClearCommError failed: %1").arg(winErrorMessage(GetLastError()))); 694 725 return -7; 695 } 726 } 696 727 const DWORD bytesToRead = qMax(DWORD(1), qMin(comStat.cbInQue, DWORD(BufSize))); 697 728 // Trigger read … … 709 740 emit error(QString::fromLatin1("Read error: %1").arg(winErrorMessage(readError))); 710 741 return -1; 711 } 742 } 712 743 // Wait for either termination or data 713 744 const DWORD wr = WaitForMultipleObjects(HandleCount, m_handles, false, INFINITE); … … 784 815 }; 785 816 786 UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) : 817 UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) : 787 818 ReaderThreadBase(context) 788 819 { … … 878 909 879 910 QSharedPointer<DeviceContext> deviceContext; 880 QS haredPointer<WriterThread> writerThread;881 QS haredPointer<ReaderThread> readerThread;911 QScopedPointer<WriterThread> writerThread; 912 QScopedPointer<ReaderThread> readerThread; 882 913 883 914 QByteArray trkReadBuffer; … … 918 949 bool TrkDevice::open(QString *errorMessage) 919 950 { 920 if (d->verbose )951 if (d->verbose || verboseTrk) 921 952 qDebug() << "Opening" << port() << "is open: " << isOpen() << " serialFrame=" << serialFrame(); 953 if (isOpen()) 954 return true; 922 955 if (d->port.isEmpty()) { 923 956 *errorMessage = QLatin1String("Internal error: No port set on TrkDevice"); 924 957 return false; 925 958 } 926 927 close();928 959 #ifdef Q_OS_WIN 929 960 const QString fullPort = QLatin1String("\\\\.\\") + d->port; … … 976 1007 } 977 1008 #endif 978 d->readerThread = QSharedPointer<ReaderThread>(new ReaderThread(d->deviceContext));1009 d->readerThread.reset(new ReaderThread(d->deviceContext)); 979 1010 connect(d->readerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)), 980 1011 Qt::QueuedConnection); … … 984 1015 d->readerThread->start(); 985 1016 986 d->writerThread = QSharedPointer<WriterThread>(new WriterThread(d->deviceContext));1017 d->writerThread.reset(new WriterThread(d->deviceContext)); 987 1018 connect(d->writerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)), 988 Qt::QueuedConnection); 989 d->writerThread->start(); 990 991 if (d->verbose )992 qDebug() << "Opened" << d->port ;1019 Qt::QueuedConnection); 1020 d->writerThread->start(); 1021 1022 if (d->verbose || verboseTrk) 1023 qDebug() << "Opened" << d->port << d->readerThread.data() << d->writerThread.data(); 993 1024 return true; 994 1025 } … … 996 1027 void TrkDevice::close() 997 1028 { 1029 if (verboseTrk) 1030 qDebug() << "close" << d->port << " is open: " << isOpen() 1031 << " read pending " << (d->readerThread.isNull() ? 0 : d->readerThread->bytesPending()) 1032 << sender(); 998 1033 if (!isOpen()) 999 1034 return; … … 1011 1046 d->deviceContext->file.close(); 1012 1047 #endif 1048 1013 1049 if (d->verbose) 1014 1050 emitLogMessage("Close"); … … 1031 1067 void TrkDevice::setPort(const QString &p) 1032 1068 { 1069 if (verboseTrk) 1070 qDebug() << "setPort" << p; 1033 1071 d->port = p; 1034 1072 } … … 1046 1084 void TrkDevice::setSerialFrame(bool f) 1047 1085 { 1086 if (verboseTrk) 1087 qDebug() << "setSerialFrame" << f; 1048 1088 d->deviceContext->serialFrame = f; 1049 1089 } … … 1061 1101 void TrkDevice::slotMessageReceived(const trk::TrkResult &result, const QByteArray &rawData) 1062 1102 { 1063 d->writerThread->slotHandleResult(result); 1064 if (d->verbose > 1) 1065 qDebug() << "Received: " << result.toString(); 1066 emit messageReceived(result); 1067 if (!rawData.isEmpty()) 1068 emit rawDataReceived(rawData); 1103 if (isOpen()) { // Might receive bytes after closing due to queued connections. 1104 d->writerThread->slotHandleResult(result); 1105 if (d->verbose > 1) 1106 qDebug() << "Received: " << result.toString(); 1107 emit messageReceived(result); 1108 if (!rawData.isEmpty()) 1109 emit rawDataReceived(rawData); 1110 } 1069 1111 } 1070 1112 … … 1076 1118 } 1077 1119 1120 void TrkDevice::clearWriteQueue() 1121 { 1122 if (isOpen()) 1123 d->writerThread->clearWriteQueue(); 1124 } 1125 1078 1126 void TrkDevice::sendTrkMessage(byte code, TrkCallback callback, 1079 1127 const QByteArray &data, const QVariant &cookie) 1080 1128 { 1129 if (!isOpen()) { 1130 emitError(msgAccessingClosedDevice(d->port)); 1131 return; 1132 } 1081 1133 if (!d->writerThread.isNull()) { 1082 1134 if (d->verbose > 1) { 1083 QByteArray msg = "Sending: ";1135 QByteArray msg = "Sending: 0x"; 1084 1136 msg += QByteArray::number(code, 16); 1085 1137 msg += ": "; 1086 1138 msg += stringFromArray(data).toLatin1(); 1139 if (cookie.isValid()) 1140 msg += " Cookie: " + cookie.toString().toLatin1(); 1087 1141 qDebug("%s", msg.data()); 1088 1142 } … … 1093 1147 void TrkDevice::sendTrkInitialPing() 1094 1148 { 1149 if (!isOpen()) { 1150 emitError(msgAccessingClosedDevice(d->port)); 1151 return; 1152 } 1095 1153 if (!d->writerThread.isNull()) 1096 1154 d->writerThread->queueTrkInitialPing(); … … 1099 1157 bool TrkDevice::sendTrkAck(byte token) 1100 1158 { 1159 if (!isOpen()) { 1160 emitError(msgAccessingClosedDevice(d->port)); 1161 return false; 1162 } 1101 1163 if (d->writerThread.isNull()) 1102 1164 return false; -
trunk/tools/runonphone/symbianutils/trkdevice.h
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) … … 65 65 * read operation. 66 66 * The serialFrames property specifies whether packets are encapsulated in 67 * "0x90 <length>" frames, which is currently the case for serial ports. 67 * "0x90 <length>" frames, which is currently the case for serial ports. 68 68 * Contains a write message queue allowing 69 69 * for queueing messages with a notification callback. If the message receives 70 70 * an ACK, the callback is invoked. 71 * The special message TRK_WRITE_QUEUE_NOOP_CODE code can be used for synchronisation. 72 * The respective message will not be sent, the callback is just invoked. */ 71 * The special message TRK_WRITE_QUEUE_NOOP_CODE code can be used for synchronization. 72 * The respective message will not be sent, the callback is just invoked. 73 * Note that calling open/close in quick succession can cause crashes 74 * due to the use of queused signals. */ 73 75 74 76 enum { TRK_WRITE_QUEUE_NOOP_CODE = 0x7f }; … … 112 114 bool sendTrkAck(unsigned char token); 113 115 116 public slots: 117 void clearWriteQueue(); 118 114 119 signals: 115 120 void messageReceived(const trk::TrkResult &result); -
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 } -
trunk/tools/runonphone/symbianutils/trkutils.h
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) … … 44 44 45 45 #include "symbianutils_global.h" 46 46 47 #include <QtCore/QByteArray> 47 48 #include <QtCore/QHash> … … 56 57 57 58 typedef unsigned char byte; 59 struct TrkResult; 58 60 59 61 enum Command { 62 //meta commands 60 63 TrkPing = 0x00, 61 64 TrkConnect = 0x01, 62 65 TrkDisconnect = 0x02, 66 TrkReset = 0x03, 63 67 TrkVersions = 0x04, 64 68 TrkSupported = 0x05, 65 69 TrkCpuType = 0x06, 70 TrkConfigTransport = 0x07, 71 TrkVersions2 = 0x08, 66 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 67 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 68 97 TrkCreateItem = 0x40, 69 98 TrkDeleteItem = 0x41, 99 TrkReadInfo = 0x42, 100 TrkWriteInfo = 0x43, 70 101 71 102 TrkWriteFile = 0x48, 103 TrkReadFile = 0x49, 72 104 TrkOpenFile = 0x4a, 73 105 TrkCloseFile = 0x4b, 106 TrkPositionFile = 0x4c, 74 107 TrkInstallFile = 0x4d, 75 108 TrkInstallFile2 = 0x4e, 76 109 110 TrkPhoneSwVersion = 0x4f, 111 TrkPhoneName = 0x50, 112 TrkVersions3 = 0x51, 113 114 //replies 77 115 TrkNotifyAck = 0x80, 78 116 TrkNotifyNak = 0xff, 117 118 //target -> host notification 79 119 TrkNotifyStopped = 0x90, 80 120 TrkNotifyException = 0x91, 81 121 TrkNotifyInternalError = 0x92, 122 TrkNotifyStopped2 = 0x94, 123 124 //target -> host OS notification 82 125 TrkNotifyCreated = 0xa0, 83 126 TrkNotifyDeleted = 0xa1, 84 127 TrkNotifyProcessorStarted = 0xa2, 85 128 TrkNotifyProcessorStandBy = 0xa6, 86 TrkNotifyProcessorReset = 0xa7 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 139 enum 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 153 enum SerialMultiplexor { 154 MuxRaw = 0, 155 MuxTextTrace = 0x0102, 156 MuxTrk = 0x0190 87 157 }; 88 158 … … 90 160 SYMBIANUTILS_EXPORT ushort extractShort(const char *data); 91 161 SYMBIANUTILS_EXPORT uint extractInt(const char *data); 162 SYMBIANUTILS_EXPORT quint64 extractInt64(const char *data); 92 163 93 164 SYMBIANUTILS_EXPORT QString quoteUnprintableLatin1(const QByteArray &ba); … … 109 180 struct SYMBIANUTILS_EXPORT Library 110 181 { 111 Library() {} 182 Library(); 183 explicit Library(const TrkResult &r); 112 184 113 185 QByteArray name; 114 186 uint codeseg; 115 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; 116 190 }; 117 191 … … 119 193 { 120 194 TrkAppVersion(); 121 void reset(); 195 void reset(); 122 196 123 197 int trkMajor; … … 132 206 void reset(); 133 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; 134 213 135 214 // Trk feedback … … 143 222 TrkAppVersion trkAppVersion; 144 223 uint pid; 224 uint mainTid; 145 225 uint tid; 146 226 uint codeseg; … … 151 231 Libraries libraries; 152 232 153 typedef uint Thread;154 typedef QList<Thread> Threads;155 Threads threads;156 157 233 // Gdb request 158 uint currentThread;159 234 QStringList modules; 160 235 }; … … 169 244 QString errorString() const; 170 245 246 ushort multiplex; 171 247 byte code; 172 248 byte token; -
trunk/tools/runonphone/symbianutils/trkutils_p.h
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) … … 56 56 // the serial frame [0x01 0x90 <len>] and 0x7e encoded7d(ba) 0x7e 57 57 QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool serialFrame); 58 bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *r, QByteArray *rawData = 0);58 bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *r, bool& linkEstablishmentMode, QByteArray *rawData = 0); 59 59 60 60 } // namespace trk
Note:
See TracChangeset
for help on using the changeset viewer.