예제 #1
0
void GdbTermEngine::setupEngine()
{
    QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
    showMessage(_("TRYING TO START ADAPTER"));

// Currently, adapters are not re-used
//    // We leave the console open, so recycle it now.
//    m_stubProc.blockSignals(true);
//    m_stubProc.stop();
//    m_stubProc.blockSignals(false);

    if (!prepareCommand())
        return;

    m_stubProc.setWorkingDirectory(runParameters().workingDirectory);
    // Set environment + dumper preload.
    m_stubProc.setEnvironment(runParameters().stubEnvironment);

    connect(&m_stubProc, &ConsoleProcess::processError,
            this, &GdbTermEngine::stubError);
    connect(&m_stubProc, &ConsoleProcess::processStarted,
            this, &GdbTermEngine::stubStarted);
    connect(&m_stubProc, &ConsoleProcess::stubStopped,
            this, &GdbTermEngine::stubExited);
    // FIXME: Starting the stub implies starting the inferior. This is
    // fairly unclean as far as the state machine and error reporting go.

    if (!m_stubProc.start(runParameters().executable,
                         runParameters().processArgs)) {
        // Error message for user is delivered via a signal.
        handleAdapterStartFailed(QString());
        return;
    }
}
예제 #2
0
void GdbAttachEngine::setupEngine()
{
    QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
    showMessage(_("TRYING TO START ADAPTER"));

    if (!runParameters().workingDirectory.isEmpty())
        m_gdbProc.setWorkingDirectory(runParameters().workingDirectory);

    startGdb();
}
예제 #3
0
void GdbPlainEngine::setupInferior()
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    setEnvironmentVariables();
    if (!runParameters().inferior.commandLineArguments.isEmpty()) {
        QString args = runParameters().inferior.commandLineArguments;
        runCommand({"-exec-arguments " + toLocalEncoding(args), NoFlags});
    }
    runCommand({"-file-exec-and-symbols \"" + execFilePath() + '"', NoFlags,
        CB(handleFileExecAndSymbols)});
}
예제 #4
0
void GdbPlainEngine::runEngine()
{
    if (runParameters().useContinueInsteadOfRun)
        runCommand({"-exec-continue", RunRequest, CB(handleExecuteContinue)});
    else
        runCommand({"-exec-run", RunRequest, CB(handleExecRun)});
}
예제 #5
0
void GdbCoreEngine::continueSetupEngine()
{
    bool isCore = true;
    if (m_coreUnpackProcess) {
        isCore = m_coreUnpackProcess->exitCode() == 0;
        m_coreUnpackProcess->deleteLater();
        m_coreUnpackProcess = 0;
        if (m_tempCoreFile.isOpen())
            m_tempCoreFile.close();
    }
    if (isCore && m_executable.isEmpty()) {
        GdbCoreEngine::CoreInfo cinfo = readExecutableNameFromCore(
                                            runParameters().debuggerCommand,
                                            coreFileName());

        if (cinfo.isCore) {
            m_executable = cinfo.foundExecutableName;
            if (m_executable.isEmpty()) {
                Core::AsynchronousMessageBox::warning(
                    tr("Error Loading Symbols"),
                    tr("No executable to load symbols from specified core."));
                notifyEngineSetupFailed();
                return;
            }
        }
    }
    if (isCore) {
        startGdb();
    } else {
        Core::AsynchronousMessageBox::warning(
            tr("Error Loading Core File"),
            tr("The specified file does not appear to be a core file."));
        notifyEngineSetupFailed();
    }
}
예제 #6
0
void GdbAttachEngine::runEngine()
{
    QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
    const qint64 pid = runParameters().attachPID;
    runCommand({"attach " + QByteArray::number(pid), NoFlags,
                [this](const DebuggerResponse &r) { handleAttach(r); }});
    showStatusMessage(tr("Attached to process %1.").arg(inferiorPid()));
}
예제 #7
0
void GdbTermEngine::handleStubAttached(const DebuggerResponse &response)
{
    // InferiorStopOk can happen if the "*stopped" in response to the
    // 'attach' comes in before its '^done'
    QTC_ASSERT(state() == EngineRunRequested || state() == InferiorStopOk,
               qDebug() << state());

    switch (response.resultClass) {
    case ResultDone:
    case ResultRunning:
        if (runParameters().toolChainAbi.os() == ProjectExplorer::Abi::WindowsOS) {
            QString errorMessage;
            // Resume thread that was suspended by console stub process (see stub code).
            const qint64 mainThreadId = m_stubProc.applicationMainThreadID();
            if (winResumeThread(mainThreadId, &errorMessage)) {
                showMessage(QString::fromLatin1("Inferior attached, thread %1 resumed").
                            arg(mainThreadId), LogMisc);
            } else {
                showMessage(QString::fromLatin1("Inferior attached, unable to resume thread %1: %2").
                            arg(mainThreadId).arg(errorMessage),
                            LogWarning);
            }
            notifyEngineRunAndInferiorStopOk();
            continueInferiorInternal();
        } else {
            showMessage(_("INFERIOR ATTACHED AND RUNNING"));
            //notifyEngineRunAndInferiorRunOk();
            // Wait for the upcoming *stopped and handle it there.
        }
        break;
    case ResultError:
        if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
            showMessage(msgPtraceError(runParameters().startMode));
            notifyEngineRunFailed();
            break;
        }
        showMessage(QString::fromLocal8Bit(response.data["msg"].data()));
        notifyEngineIll();
        break;
    default:
        showMessage(QString::fromLatin1("Invalid response %1").arg(response.resultClass));
        notifyEngineIll();
        break;
    }
}
예제 #8
0
void QmlCppEngine::setupEngine()
{
    EDEBUG("\nMASTER SETUP ENGINE");
    setActiveEngine(m_cppEngine);
    m_qmlEngine->setupSlaveEngine();
    m_cppEngine->setupSlaveEngine();

    if (runParameters().remoteSetupNeeded)
        notifyEngineRequestRemoteSetup();
}
예제 #9
0
void GdbCoreEngine::setupEngine()
{
    QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
    showMessage(_("TRYING TO START ADAPTER"));

    const DebuggerRunParameters &rp = runParameters();
    m_executable = rp.executable;
    QFileInfo fi(rp.coreFile);
    m_coreName = fi.absoluteFilePath();

    unpackCoreIfNeeded();
}
예제 #10
0
void GdbPlainEngine::setupEngine()
{
    QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
    showMessage(_("TRYING TO START ADAPTER"));

    if (!prepareCommand())
        return;

    QStringList gdbArgs;

    if (!m_outputCollector.listen()) {
        handleAdapterStartFailed(tr("Cannot set up communication with child process: %1")
                .arg(m_outputCollector.errorString()));
        return;
    }
    gdbArgs.append(_("--tty=") + m_outputCollector.serverName());

    if (!runParameters().inferior.workingDirectory.isEmpty())
        m_gdbProc.setWorkingDirectory(runParameters().inferior.workingDirectory);

    startGdb(gdbArgs);
}
예제 #11
0
void GdbAttachEngine::handleAttach(const DebuggerResponse &response)
{
    QTC_ASSERT(state() == EngineRunRequested || state() == InferiorStopOk,
               qDebug() << state());
    switch (response.resultClass) {
    case ResultDone:
    case ResultRunning:
        showMessage(_("INFERIOR ATTACHED"));
        if (state() == EngineRunRequested) {
            // Happens e.g. for "Attach to unstarted application"
            // We will get a '*stopped' later that we'll interpret as 'spontaneous'
            // So acknowledge the current state and put a delayed 'continue' in the pipe.
            showMessage(tr("Attached to running application"), StatusBar);
            notifyEngineRunAndInferiorRunOk();
        } else {
            // InferiorStopOk, e.g. for "Attach to running application".
            // The *stopped came in between sending the 'attach' and
            // receiving its '^done'.
            if (runParameters().continueAfterAttach)
                continueInferiorInternal();
        }
        break;
    case ResultError:
        if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
            QString msg = msgPtraceError(runParameters().startMode);
            showStatusMessage(tr("Failed to attach to application: %1").arg(msg));
            Core::AsynchronousMessageBox::warning(tr("Debugger Error"), msg);
            notifyEngineIll();
            break;
        }
        // if msg != "ptrace: ..." fall through
    default:
        showStatusMessage(tr("Failed to attach to application: %1")
                          .arg(QString::fromLocal8Bit(response.data["msg"].data())));
        notifyEngineIll();
    }
}
예제 #12
0
void GdbCoreEngine::handleTargetCore(const DebuggerResponse &response)
{
    CHECK_STATE(EngineRunRequested);
    notifyEngineRunOkAndInferiorUnrunnable();
    if (response.resultClass == ResultDone) {
        showMessage(tr("Attached to core."), StatusBar);
        // Due to the auto-solib-add off setting, we don't have any
        // symbols yet. Load them in order of importance.
        reloadStack();
        reloadModulesInternal();
        postCommand("p 5", NoFlags, CB(handleRoundTrip));
        return;
    }
    showStatusMessage(tr("Attach to core \"%1\" failed:").arg(runParameters().coreFile)
        + QLatin1Char('\n') + QString::fromLocal8Bit(response.data["msg"].data()));
    notifyEngineIll();
}
예제 #13
0
void GdbCoreEngine::handleTargetCore(const DebuggerResponse &response)
{
    CHECK_STATE(EngineRunRequested);
    notifyEngineRunOkAndInferiorUnrunnable();
    showMessage(tr("Attached to core."), StatusBar);
    if (response.resultClass == ResultError) {
        // We'll accept any kind of error e.g. &"Cannot access memory at address 0x2abc2a24\n"
        // Even without the stack, the user can find interesting stuff by exploring
        // the memory, globals etc.
        showStatusMessage(tr("Attach to core \"%1\" failed:").arg(runParameters().coreFile)
                          + QLatin1Char('\n') + QString::fromLocal8Bit(response.data["msg"].data())
                          + QLatin1Char('\n') + tr("Continuing nevertheless."));
    }
    // Due to the auto-solib-add off setting, we don't have any
    // symbols yet. Load them in order of importance.
    reloadStack();
    reloadModulesInternal();
    runCommand({"p 5", NoFlags, CB(handleRoundTrip)});
}
예제 #14
0
void GdbAttachEngine::interruptInferior2()
{
    interruptLocalInferior(runParameters().attachPID);
}
예제 #15
0
QByteArray GdbPlainEngine::execFilePath() const
{
    return QFileInfo(runParameters().inferior.executable)
            .absoluteFilePath().toLocal8Bit();
}