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:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • 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;
Note: See TracChangeset for help on using the changeset viewer.