tools/runonphone/main.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    60             << "-f, --portfriendlyname <substring>       specify COM port to use by friendly name" << endl
    60             << "-f, --portfriendlyname <substring>       specify COM port to use by friendly name" << endl
    61             << "-t, --timeout <milliseconds>             terminate test if timeout occurs" << endl
    61             << "-t, --timeout <milliseconds>             terminate test if timeout occurs" << endl
    62             << "-v, --verbose                            show debugging output" << endl
    62             << "-v, --verbose                            show debugging output" << endl
    63             << "-q, --quiet                              hide progress messages" << endl
    63             << "-q, --quiet                              hide progress messages" << endl
    64             << "-d, --download <remote file> <local file> copy file from phone to PC after running test" << endl
    64             << "-d, --download <remote file> <local file> copy file from phone to PC after running test" << endl
       
    65             << "--nocrashlog                             Don't capture call stack if test crashes" << endl
       
    66             << "--crashlogpath <dir>                     Path to save crash logs (default=working dir)" << endl
    65             << endl
    67             << endl
    66             << "USB COM ports can usually be autodetected, use -p or -f to force a specific port." << endl
    68             << "USB COM ports can usually be autodetected, use -p or -f to force a specific port." << endl
    67             << "If using System TRK, it is possible to copy the program directly to sys/bin on the phone." << endl
    69             << "If using System TRK, it is possible to copy the program directly to sys/bin on the phone." << endl
    68             << "-s can be used with both System and Application TRK to install the program" << endl;
    70             << "-s can be used with both System and Application TRK to install the program" << endl;
    69 }
    71 }
    83     QTextStream errstream(stderr);
    85     QTextStream errstream(stderr);
    84     QString downloadRemoteFile;
    86     QString downloadRemoteFile;
    85     QString downloadLocalFile;
    87     QString downloadLocalFile;
    86     int loglevel=1;
    88     int loglevel=1;
    87     int timeout=0;
    89     int timeout=0;
       
    90     bool crashlog = true;
       
    91     QString crashlogpath;
    88     QListIterator<QString> it(args);
    92     QListIterator<QString> it(args);
    89     it.next(); //skip name of program
    93     it.next(); //skip name of program
    90     while (it.hasNext()) {
    94     while (it.hasNext()) {
    91         QString arg = it.next();
    95         QString arg = it.next();
    92 
    96 
   124             }
   128             }
   125             else if (arg == "--verbose" || arg == "-v")
   129             else if (arg == "--verbose" || arg == "-v")
   126                 loglevel=2;
   130                 loglevel=2;
   127             else if (arg == "--quiet" || arg == "-q")
   131             else if (arg == "--quiet" || arg == "-q")
   128                 loglevel=0;
   132                 loglevel=0;
       
   133             else if (arg == "--nocrashlog")
       
   134                 crashlog = false;
       
   135             else if (arg == "--crashlogpath") {
       
   136                 CHECK_PARAMETER_EXISTS
       
   137                 crashlogpath = it.next();
       
   138             }
   129             else
   139             else
   130                 errstream << "unknown command line option " << arg << endl;
   140                 errstream << "unknown command line option " << arg << endl;
   131         } else {
   141         } else {
   132             exeFile = arg;
   142             exeFile = arg;
   133             while(it.hasNext()) {
   143             while(it.hasNext()) {
   143     }
   153     }
   144 
   154 
   145     if (serialPortName.isEmpty()) {
   155     if (serialPortName.isEmpty()) {
   146         if (loglevel > 0)
   156         if (loglevel > 0)
   147             outstream << "Detecting serial ports" << endl;
   157             outstream << "Detecting serial ports" << endl;
   148         foreach (const SerialPortId &id, enumerateSerialPorts()) {
   158         foreach (const SerialPortId &id, enumerateSerialPorts(loglevel)) {
   149             if (loglevel > 0)
   159             if (loglevel > 0)
   150                 outstream << "Port Name: " << id.portName << ", "
   160                 outstream << "Port Name: " << id.portName << ", "
   151                      << "Friendly Name:" << id.friendlyName << endl;
   161                      << "Friendly Name:" << id.friendlyName << endl;
   152             if (!id.friendlyName.isEmpty()
   162             if (!id.friendlyName.isEmpty()
   153                     && serialPortFriendlyName.isEmpty()
   163                     && serialPortFriendlyName.isEmpty()
   197     if (loglevel > 1)
   207     if (loglevel > 1)
   198         launcher->setVerbose(1);
   208         launcher->setVerbose(1);
   199 
   209 
   200     TrkSignalHandler handler;
   210     TrkSignalHandler handler;
   201     handler.setLogLevel(loglevel);
   211     handler.setLogLevel(loglevel);
       
   212     handler.setCrashLogging(crashlog);
       
   213     handler.setCrashLogPath(crashlogpath);
   202 
   214 
   203     QObject::connect(launcher.data(), SIGNAL(copyingStarted()), &handler, SLOT(copyingStarted()));
   215     QObject::connect(launcher.data(), SIGNAL(copyingStarted()), &handler, SLOT(copyingStarted()));
   204     QObject::connect(launcher.data(), SIGNAL(canNotConnect(const QString &)), &handler, SLOT(canNotConnect(const QString &)));
   216     QObject::connect(launcher.data(), SIGNAL(canNotConnect(const QString &)), &handler, SLOT(canNotConnect(const QString &)));
   205     QObject::connect(launcher.data(), SIGNAL(canNotCreateFile(const QString &, const QString &)), &handler, SLOT(canNotCreateFile(const QString &, const QString &)));
   217     QObject::connect(launcher.data(), SIGNAL(canNotCreateFile(const QString &, const QString &)), &handler, SLOT(canNotCreateFile(const QString &, const QString &)));
   206     QObject::connect(launcher.data(), SIGNAL(canNotWriteFile(const QString &, const QString &)), &handler, SLOT(canNotWriteFile(const QString &, const QString &)));
   218     QObject::connect(launcher.data(), SIGNAL(canNotWriteFile(const QString &, const QString &)), &handler, SLOT(canNotWriteFile(const QString &, const QString &)));
   213     QObject::connect(launcher.data(), SIGNAL(canNotRun(const QString &)), &handler, SLOT(canNotRun(const QString &)));
   225     QObject::connect(launcher.data(), SIGNAL(canNotRun(const QString &)), &handler, SLOT(canNotRun(const QString &)));
   214     QObject::connect(launcher.data(), SIGNAL(applicationOutputReceived(const QString &)), &handler, SLOT(applicationOutputReceived(const QString &)));
   226     QObject::connect(launcher.data(), SIGNAL(applicationOutputReceived(const QString &)), &handler, SLOT(applicationOutputReceived(const QString &)));
   215     QObject::connect(launcher.data(), SIGNAL(copyProgress(int)), &handler, SLOT(copyProgress(int)));
   227     QObject::connect(launcher.data(), SIGNAL(copyProgress(int)), &handler, SLOT(copyProgress(int)));
   216     QObject::connect(launcher.data(), SIGNAL(stateChanged(int)), &handler, SLOT(stateChanged(int)));
   228     QObject::connect(launcher.data(), SIGNAL(stateChanged(int)), &handler, SLOT(stateChanged(int)));
   217     QObject::connect(launcher.data(), SIGNAL(processStopped(uint,uint,uint,QString)), &handler, SLOT(stopped(uint,uint,uint,QString)));
   229     QObject::connect(launcher.data(), SIGNAL(processStopped(uint,uint,uint,QString)), &handler, SLOT(stopped(uint,uint,uint,QString)));
       
   230     QObject::connect(launcher.data(), SIGNAL(libraryLoaded(trk::Library)), &handler, SLOT(libraryLoaded(trk::Library)));
       
   231     QObject::connect(launcher.data(), SIGNAL(libraryUnloaded(trk::Library)), &handler, SLOT(libraryUnloaded(trk::Library)));
       
   232     QObject::connect(launcher.data(), SIGNAL(registersAndCallStackReadComplete(const QList<uint> &,const QByteArray &)), &handler, SLOT(registersAndCallStackReadComplete(const QList<uint> &,const QByteArray &)));
   218     QObject::connect(&handler, SIGNAL(resume(uint,uint)), launcher.data(), SLOT(resumeProcess(uint,uint)));
   233     QObject::connect(&handler, SIGNAL(resume(uint,uint)), launcher.data(), SLOT(resumeProcess(uint,uint)));
   219     QObject::connect(&handler, SIGNAL(terminate()), launcher.data(), SLOT(terminate()));
   234     QObject::connect(&handler, SIGNAL(terminate()), launcher.data(), SLOT(terminate()));
       
   235     QObject::connect(&handler, SIGNAL(getRegistersAndCallStack(uint,uint)), launcher.data(), SLOT(getRegistersAndCallStack(uint,uint)));
   220     QObject::connect(launcher.data(), SIGNAL(finished()), &handler, SLOT(finished()));
   236     QObject::connect(launcher.data(), SIGNAL(finished()), &handler, SLOT(finished()));
   221 
   237 
   222     QTimer timer;
   238     QTimer timer;
   223     timer.setSingleShot(true);
   239     timer.setSingleShot(true);
   224     QObject::connect(&timer, SIGNAL(timeout()), &handler, SLOT(timeout()));
   240     QObject::connect(&timer, SIGNAL(timeout()), &handler, SLOT(timeout()));