Changeset 651 for trunk/tools/runonphone


Ignore:
Timestamp:
Mar 8, 2010, 12:52:58 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.2 sources.

Location:
trunk
Files:
20 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/runonphone/main.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7373    QString sisFile;
    7474    QString exeFile;
    75     QString cmdLine;
     75    QStringList cmdLine;
    7676    QStringList args = QCoreApplication::arguments();
    7777    QTextStream outstream(stdout);
     
    125125            for(;i<args.size();i++) {
    126126                cmdLine.append(args.at(i));
    127                 if(i + 1 < args.size()) cmdLine.append(' ');
    128127            }
    129128        }
     
    176175    if(loglevel > 0)
    177176        outstream << "Connecting to target via " << serialPortName << endl;
     177#ifdef Q_OS_WIN
    178178    launcher->setTrkServerName(QString("\\\\.\\") + serialPortName);
     179#else
     180    launcher->setTrkServerName(serialPortName);
     181#endif
    179182
    180183    launcher->setFileName(QString("c:\\sys\\bin\\") + exeFile);
     
    201204    QObject::connect(launcher.data(), SIGNAL(copyProgress(int)), &handler, SLOT(copyProgress(int)));
    202205    QObject::connect(launcher.data(), SIGNAL(stateChanged(int)), &handler, SLOT(stateChanged(int)));
    203     QObject::connect(launcher.data(), SIGNAL(stopped(uint,uint,uint,QString)), &handler, SLOT(stopped(uint,uint,uint,QString)));
    204     QObject::connect(&handler, SIGNAL(resume(uint,uint)), launcher.data(), SLOT(resume(uint,uint)));
     206    QObject::connect(launcher.data(), SIGNAL(processStopped(uint,uint,uint,QString)), &handler, SLOT(stopped(uint,uint,uint,QString)));
     207    QObject::connect(&handler, SIGNAL(resume(uint,uint)), launcher.data(), SLOT(resumeProcess(uint,uint)));
    205208    QObject::connect(&handler, SIGNAL(terminate()), launcher.data(), SLOT(terminate()));
    206209    QObject::connect(launcher.data(), SIGNAL(finished()), &handler, SLOT(finished()));
  • trunk/tools/runonphone/runonphone.pro

    r561 r651  
    1919        -ladvapi32
    2020}
     21else:unix:!symbian {
     22    SOURCES += serenum_unix.cpp
     23}
     24else {
     25    SOURCES += serenum_stub.cpp
     26}
  • trunk/tools/runonphone/serenum.h

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/serenum_win.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/trk/bluetoothlistener.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/trk/bluetoothlistener.h

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/trk/bluetoothlistener_gui.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/trk/bluetoothlistener_gui.h

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/trk/callback.h

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/trk/communicationstarter.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/trk/communicationstarter.h

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/trk/launcher.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7777    CopyState m_copyState;
    7878    QString m_fileName;
    79     QString m_commandLineArgs;
     79    QStringList m_commandLineArgs;
    8080    QString m_installFileName;
    8181    int m_verbose;
     
    160160}
    161161
    162 void Launcher::setCommandLineArgs(const QString &args)
     162void Launcher::setCommandLineArgs(const QStringList &args)
    163163{
    164164    d->m_commandLineArgs = args;
     
    190190    errorMessage->clear();
    191191    if (d->m_verbose) {
    192         const QString msg = QString::fromLatin1("Port=%1 Executable=%2 Package=%3 Remote Package=%4 Install file=%5")
    193                             .arg(d->m_trkServerName, d->m_fileName, d->m_copyState.sourceFileName, d->m_copyState.destinationFileName, d->m_installFileName);
     192        const QString msg = QString::fromLatin1("Port=%1 Executable=%2 Arguments=%3 Package=%4 Remote Package=%5 Install file=%6")
     193                            .arg(d->m_trkServerName, d->m_fileName,
     194                                 d->m_commandLineArgs.join(QString(QLatin1Char(' '))),
     195                                 d->m_copyState.sourceFileName, d->m_copyState.destinationFileName, d->m_installFileName);
    194196        logMessage(msg);
    195197    }
     
    297299}
    298300
     301QString Launcher::msgStopped(uint pid, uint tid, uint address, const QString &why)
     302{
     303    return QString::fromLatin1("Process %1, thread %2 stopped at 0x%3: %4").
     304            arg(pid).arg(tid).arg(address, 0, 16).
     305            arg(why.isEmpty() ? QString::fromLatin1("<Unknown reason>") : why);
     306}
     307
     308bool Launcher::parseNotifyStopped(const QByteArray &dataBA,
     309                                  uint *pid, uint *tid, uint *address,
     310                                  QString *why /* = 0 */)
     311{
     312    if (why)
     313        why->clear();
     314    *address = *pid = *tid = 0;
     315    if (dataBA.size() < 12)
     316        return false;
     317    const char *data = dataBA.data();
     318    *address = extractInt(data);
     319    *pid = extractInt(data + 4);
     320    *tid = extractInt(data + 8);
     321    if (why && dataBA.size() >= 14) {
     322        const unsigned short len = extractShort(data + 12);
     323        if (len > 0)
     324            *why = QString::fromLatin1(data + 14, len);
     325    }
     326    return true;
     327}
     328
    299329void Launcher::handleResult(const TrkResult &result)
    300330{
     
    316346        }
    317347        case TrkNotifyStopped: { // Notified Stopped
    318             logMessage(prefix + "NOTE: STOPPED  " + str);
    319             // 90 01   78 6a 40 40   00 00 07 23   00 00 07 24  00 00
    320348            QString reason;
    321             if (result.data.size() >= 14) {
    322                 uint pc = extractInt(result.data.mid(0,4).constData());
    323                 uint pid = extractInt(result.data.mid(4,4).constData());
    324                 uint tid = extractInt(result.data.mid(8,4).constData());
    325                 ushort len = extractShort(result.data.mid(12,2).constData());
    326                 if(len > 0)
    327                     reason = result.data.mid(14, len);
    328                 emit(stopped(pc, pid, tid, reason));
    329             } else {
    330                 emit(stopped(0, 0, 0, reason));
    331             }
    332             //const char *data = result.data.data();
    333 //            uint addr = extractInt(data); //code address: 4 bytes; code base address for the library
    334 //            uint pid = extractInt(data + 4); // ProcessID: 4 bytes;
    335 //            uint tid = extractInt(data + 8); // ThreadID: 4 bytes
    336             //logMessage(prefix << "      ADDR: " << addr << " PID: " << pid << " TID: " << tid);
     349            uint pc;
     350            uint pid;
     351            uint tid;
     352            parseNotifyStopped(result.data, &pid, &tid, &pc, &reason);
     353            logMessage(prefix + msgStopped(pid, tid, pc, reason));
     354            emit(processStopped(pc, pid, tid, reason));
    337355            d->m_device->sendTrkAck(result.token);
    338356            break;
     
    682700}
    683701
    684 void Launcher::startInferiorIfNeeded()
    685 {
    686     emit startingApplication();
    687     if (d->m_session.pid != 0) {
    688         logMessage("Process already 'started'");
    689         return;
    690     }
     702QByteArray Launcher::startProcessMessage(const QString &executable,
     703                                         const QStringList &arguments)
     704{
    691705    // It's not started yet
    692706    QByteArray ba;
    693707    appendShort(&ba, 0, TargetByteOrder); // create new process
    694708    appendByte(&ba, 0); // options - currently unused
    695 
    696     if(d->m_commandLineArgs.isEmpty()) {
    697         appendString(&ba, d->m_fileName.toLocal8Bit(), TargetByteOrder);
    698     } else {
    699         QByteArray ba2;
    700         ba2.append(d->m_fileName.toLocal8Bit());
    701         ba2.append('\0');
    702         ba2.append(d->m_commandLineArgs.toLocal8Bit());
    703         appendString(&ba, ba2, TargetByteOrder);
    704     }
    705     d->m_device->sendTrkMessage(TrkCreateItem, TrkCallback(this, &Launcher::handleCreateProcess), ba); // Create Item
    706 }
    707 
    708 void Launcher::resume(uint pid, uint tid)
     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);
     719    return ba;
     720}
     721
     722void Launcher::startInferiorIfNeeded()
     723{
     724    emit startingApplication();
     725    if (d->m_session.pid != 0) {
     726        logMessage("Process already 'started'");
     727        return;
     728    }
     729    d->m_device->sendTrkMessage(TrkCreateItem, TrkCallback(this, &Launcher::handleCreateProcess),
     730                                startProcessMessage(d->m_fileName, d->m_commandLineArgs)); // Create Item
     731}
     732
     733void Launcher::resumeProcess(uint pid, uint tid)
    709734{
    710735    QByteArray ba;
  • trunk/tools/runonphone/trk/launcher.h

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    9696    void setCopyFileName(const QString &srcName, const QString &dstName);
    9797    void setInstallFileName(const QString &name);
    98     void setCommandLineArgs(const QString &args);
     98    void setCommandLineArgs(const QStringList &args);
    9999    bool startServer(QString *errorMessage);
    100100    void setVerbose(int v);   
     
    109109    // becomes valid after successful execution of ActionPingOnly
    110110    QString deviceDescription(unsigned verbose = 0u) const;
     111
     112    static QByteArray startProcessMessage(const QString &executable,
     113                                          const QStringList &arguments);
     114    // Parse a TrkNotifyStopped message
     115    static bool parseNotifyStopped(const QByteArray &a,
     116                                   uint *pid, uint *tid, uint *address,
     117                                   QString *why = 0);
     118    // Helper message
     119    static QString msgStopped(uint pid, uint tid, uint address, const QString &why);
    111120
    112121signals:
     
    126135    void copyProgress(int percent);
    127136    void stateChanged(int);
    128     void stopped(uint pc, uint pid, uint tid, const QString& reason);
     137    void processStopped(uint pc, uint pid, uint tid, const QString& reason);
    129138
    130139public slots:
    131140    void terminate();
    132     void resume(uint pid, uint tid);
     141    void resumeProcess(uint pid, uint tid);
    133142
    134143private slots:
  • trunk/tools/runonphone/trk/trkdevice.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    100100#endif
    101101
     102enum { verboseTrk = 0 };
     103
    102104namespace trk {
    103105
     
    127129    callback(cb)
    128130{
     131}
     132
     133QDebug operator<<(QDebug d, const TrkMessage &msg)
     134{
     135    return d << "Message: Code: " << msg.code
     136        << " Token: " << msg.token << " " << msg.data.toHex();
    129137}
    130138
     
    205213    if (m_trkWriteToken == 0)
    206214        ++m_trkWriteToken;
     215    if (verboseTrk)
     216        qDebug() << "Write token: " << m_trkWriteToken;
    207217    return m_trkWriteToken;
    208218}
     
    335345///////////////////////////////////////////////////////////////////////
    336346
    337 class WriterThread : public QThread {
     347class WriterThread : public QThread
     348{
    338349    Q_OBJECT
    339350    Q_DISABLE_COPY(WriterThread)
     
    401412    if (m_terminate)
    402413        return 1;
     414
    403415    // Send off message
    404416    m_dataMutex.lock();
     
    406418    const TrkWriteQueue::PendingMessageResult pr = m_queue.pendingMessage(&message);
    407419    m_dataMutex.unlock();
     420
    408421    switch (pr) {
    409422    case TrkWriteQueue::NoMessage:
    410423        break;
    411424    case TrkWriteQueue::PendingMessage: {
     425            //qDebug() << "Write pending message " << message;
    412426            // Untested: try to re-send a few times
    413427            bool success = false;
     
    429443    case TrkWriteQueue::NoopMessageDequeued:
    430444        // Sync with thread that owns us via a blocking signal
     445        if (verboseTrk)
     446            qDebug() << "Noop message dequeued" << message;
    431447        emit internalNoopMessageDequeued(message);
    432448        break;
     
    500516bool WriterThread::write(const QByteArray &data, QString *errorMessage)
    501517{
     518    if (verboseTrk)
     519        qDebug() << "Write raw data: " << data.toHex();
    502520    QMutexLocker locker(&m_context->mutex);
    503521#ifdef Q_OS_WIN
     
    558576}
    559577
     578
    560579///////////////////////////////////////////////////////////////////////
    561580//
     
    567586///////////////////////////////////////////////////////////////////////
    568587
    569 class ReaderThreadBase : public QThread {
     588class ReaderThreadBase : public QThread
     589{
    570590    Q_OBJECT
    571591    Q_DISABLE_COPY(ReaderThreadBase)
     
    626646///////////////////////////////////////////////////////////////////////
    627647
    628 class WinReaderThread : public ReaderThreadBase {
     648class WinReaderThread : public ReaderThreadBase
     649{
    629650    Q_OBJECT
    630651    Q_DISABLE_COPY(WinReaderThread)
     
    836857    // Trigger select() by writing to the pipe
    837858    char c = 0;
    838     write(m_terminatePipeFileDescriptors[1], &c, 1);
     859    int written = write(m_terminatePipeFileDescriptors[1], &c, 1);
     860    // FIXME: Use result.
    839861    wait();
    840862}
     
    10221044{
    10231045    d->writerThread->slotHandleResult(result);
     1046    if (d->verbose > 1)
     1047        qDebug() << "Received: " << result.toString();
    10241048    emit messageReceived(result);   
    10251049    if (!rawData.isEmpty())
     
    10581082    msg.token = token;
    10591083    msg.data.append('\0');
     1084    if (verboseTrk)
     1085        qDebug() << "Write synchroneous message: " << msg;
    10601086    return d->writerThread->trkWriteRawMessage(msg);
    10611087    // 01 90 00 07 7e 80 01 00 7d 5e 7e
  • trunk/tools/runonphone/trk/trkdevice.h

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/trk/trkutils.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/trk/trkutils.h

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    120120};
    121121
    122 struct TrkAppVersion {
     122struct TrkAppVersion
     123{
    123124    TrkAppVersion();
    124125    void reset();   
     
    153154    typedef QList<Library> Libraries;
    154155    Libraries libraries;
     156
     157    typedef uint Thread;
     158    typedef QList<Thread> Threads;
     159    Threads threads;
    155160
    156161    // Gdb request
  • trunk/tools/runonphone/trksignalhandler.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/tools/runonphone/trksignalhandler.h

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
Note: See TracChangeset for help on using the changeset viewer.