void GdbRemoteServerEngine::callTargetRemote()
{
    //m_breakHandler->clearBreakMarkers();

    // "target remote" does three things:
    //     (1) connects to the gdb server
    //     (2) starts the remote application
    //     (3) stops the remote application (early, e.g. in the dynamic linker)
    QByteArray channel = startParameters().remoteChannel.toLatin1();

    // Don't touch channels with explicitly set protocols.
    if (!channel.startsWith("tcp:") && !channel.startsWith("udp:")
            && !channel.startsWith("file:") && channel.contains(':'))
    {
        // "Fix" the IPv6 case with host names without '['...']'
        if (!channel.startsWith('[') && channel.count(':') >= 2) {
            channel.insert(0, '[');
            channel.insert(channel.lastIndexOf(':'), ']');
        }
        channel = "tcp:" + channel;
    }

    if (m_isQnxGdb)
        postCommand("target qnx " + channel, CB(handleTargetQnx));
    else
        postCommand("target remote " + channel, CB(handleTargetRemote));
}
void GdbRemoteServerEngine::callTargetRemote()
{
    QByteArray rawChannel = startParameters().remoteChannel.toLatin1();
    QByteArray channel = rawChannel;

    // Don't touch channels with explicitly set protocols.
    if (!channel.startsWith("tcp:") && !channel.startsWith("udp:")
            && !channel.startsWith("file:") && channel.contains(':')
            && !channel.startsWith('|'))
    {
        // "Fix" the IPv6 case with host names without '['...']'
        if (!channel.startsWith('[') && channel.count(':') >= 2) {
            channel.insert(0, '[');
            channel.insert(channel.lastIndexOf(':'), ']');
        }
        channel = "tcp:" + channel;
    }

    if (m_isQnxGdb)
        postCommand("target qnx " + channel, CB(handleTargetQnx));
    else if (startParameters().multiProcess)
        postCommand("target extended-remote " + channel, CB(handleTargetExtendedRemote));
    else
        postCommand("target remote " + channel, CB(handleTargetRemote), 10);
}
Esempio n. 3
0
void GdbPlainEngine::runEngine()
{
    if (startParameters().useContinueInsteadOfRun)
        postCommand("-exec-continue", GdbEngine::RunRequest, CB(handleExecuteContinue));
    else
        postCommand("-exec-run", GdbEngine::RunRequest, CB(handleExecRun));
}
void GdbRemoteServerEngine::setupInferior()
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    const DebuggerStartParameters &sp = startParameters();
    QString executableFileName;
    if (!sp.executable.isEmpty()) {
        QFileInfo fi(sp.executable);
        executableFileName = fi.absoluteFilePath();
    }

    //const QByteArray sysroot = sp.sysroot.toLocal8Bit();
    //const QByteArray remoteArch = sp.remoteArchitecture.toLatin1();
    const QString args = isMasterEngine() ? startParameters().processArgs : masterEngine()->startParameters().processArgs;

//    if (!remoteArch.isEmpty())
//        postCommand("set architecture " + remoteArch);
    const QString solibSearchPath
            = sp.solibSearchPath.join(Utils::HostOsInfo::pathListSeparator());
    if (!solibSearchPath.isEmpty())
        postCommand("set solib-search-path " + solibSearchPath.toLocal8Bit());

    if (!args.isEmpty())
        postCommand("-exec-arguments " + args.toLocal8Bit());

    // This has to be issued before 'target remote'. On pre-7.0 the
    // command is not present and will result in ' No symbol table is
    // loaded.  Use the "file" command.' as gdb tries to set the
    // value of a variable with name 'target-async'.
    //
    // Testing with -list-target-features which was introduced at
    // the same time would not work either, as this need an existing
    // target.
    //
    // Using it even without a target and having it fail might still
    // be better as:
    // Some external comment: '[but] "set target-async on" with a native
    // windows gdb will work, but then fail when you actually do
    // "run"/"attach", I think..


    // gdb/mi/mi-main.c:1958: internal-error:
    // mi_execute_async_cli_command: Assertion `is_running (inferior_ptid)'
    // failed.\nA problem internal to GDB has been detected,[...]
    if (boolSetting(TargetAsync))
        postCommand("set target-async on", CB(handleSetTargetAsync));

    if (executableFileName.isEmpty()) {
        showMessage(tr("No symbol file given."), StatusBar);
        callTargetRemote();
        return;
    }

    if (!executableFileName.isEmpty()) {
        postCommand("-file-exec-and-symbols \"" + executableFileName.toLocal8Bit() + '"',
            CB(handleFileExecAndSymbols));
    }
}
Esempio n. 5
0
void GdbPlainEngine::setupInferior()
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    if (!startParameters().processArgs.isEmpty()) {
        QString args = startParameters().processArgs;
        postCommand("-exec-arguments " + toLocalEncoding(args));
    }
    postCommand("-file-exec-and-symbols \"" + execFilePath() + '"',
        CB(handleFileExecAndSymbols));
}
Esempio n. 6
0
void PlotViewWrapper::update()
{
    _queue[_numQueue].control = PLOT_CMD_UPDATE;
    ++_numQueue;

    postCommand();
}
Esempio n. 7
0
void PlotViewWrapper::close()
{
    _queue[_numQueue].control = PLOT_CMD_CLOSE;
    ++_numQueue;

    postCommand();
}
Esempio n. 8
0
void PdbEngine::executeNextI()
{
    resetLocation();
    notifyInferiorRunRequested();
    notifyInferiorRunOk();
    postCommand("next", CB(handleUpdateAll));
}
Esempio n. 9
0
void PdbEngine::executeStepOut()
{
    resetLocation();
    notifyInferiorRunRequested();
    notifyInferiorRunOk();
    postCommand("finish", CB(handleUpdateAll));
}
Esempio n. 10
0
void PlotViewWrapper::resetData()
{
    _queue[_numQueue].control = PLOT_CMD_RESET_DATA;
    ++_numQueue;

    postCommand();
}
Esempio n. 11
0
void PdbEngine::continueInferior()
{
    resetLocation();
    notifyInferiorRunRequested();
    notifyInferiorRunOk();
    // Callback will be triggered e.g. when breakpoint is hit.
    postCommand("continue", CB(handleUpdateAll));
}
Esempio n. 12
0
void GdbAttachEngine::setupInferior()
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    const qint64 pid = startParameters().attachPID;
    postCommand("attach " + QByteArray::number(pid), CB(handleAttach));
    // Task 254674 does not want to remove them
    //qq->breakHandler()->removeAllBreakpoints();
}
Esempio n. 13
0
void GdbCoreEngine::setupInferior()
{
    CHECK_STATE(InferiorSetupRequested);
    // Do that first, otherwise no symbols are loaded.
    QFileInfo fi(m_executable);
    QByteArray path = fi.absoluteFilePath().toLocal8Bit();
    postCommand("-file-exec-and-symbols \"" + path + '"', NoFlags,
         CB(handleFileExecAndSymbols));
}
void GdbCoreEngine::setupInferior()
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    // Do that first, otherwise no symbols are loaded.
    QFileInfo fi(m_executable);
    QByteArray path = fi.absoluteFilePath().toLocal8Bit();
    postCommand("-file-exec-and-symbols \"" + path + '"',
         CB(handleFileExecAndSymbols));
}
Esempio n. 15
0
void PlotViewWrapper::setPos(const int x, const int y)
{
    _queue[_numQueue].control = PLOT_CMD_SET_POS;
    _queue[_numQueue].data.asInt[0] = x;
    _queue[_numQueue].data.asInt[1] = y;
    ++_numQueue;

    postCommand();
}
Esempio n. 16
0
void PlotViewWrapper::setSize(const int width, const int height)
{
    _queue[_numQueue].control = PLOT_CMD_SET_SIZE;
    _queue[_numQueue].data.asInt[0] = width;
    _queue[_numQueue].data.asInt[1] = height;
    ++_numQueue;

    postCommand();
}
Esempio n. 17
0
void PlotViewWrapper::postCommand()
{
    if(pControl[_idx].control != PLOT_STATE_OK)
    {
        QTimer::singleShot(100, this, SLOT(postCommand()));
        return;
    }

    if(_numQueue)
    {
        --_numQueue;
        memcpy(pControl[_idx].data.asBytes, _queue[_numQueue].data.asBytes, PLOT_BUFFER_SIZE);
        pControl[_idx].control = _queue[_numQueue].control;
    }

    if(_numQueue)
        QTimer::singleShot(100, this, SLOT(postCommand()));
}
Esempio n. 18
0
void PlotViewWrapper::setTitle(const QString title)
{
    QByteArray arr = title.toUtf8();

    _queue[_numQueue].control = PLOT_CMD_SET_TITLE;
    memcpy(_queue[_numQueue].data.asBytes, arr.constData(), arr.size());
    ++_numQueue;

    postCommand();
}
Esempio n. 19
0
void GdbRemoteServerEngine::handleTargetRemote(const GdbResponse &response)
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    if (response.resultClass == GdbResultDone) {
        // gdb server will stop the remote application itself.
        showMessage(_("INFERIOR STARTED"));
        showMessage(msgAttachedToStoppedInferior(), StatusBar);
        QString postAttachCommands = debuggerCore()->stringSetting(GdbPostAttachCommands);
        if (!postAttachCommands.isEmpty()) {
            foreach (const QString &cmd, postAttachCommands.split(QLatin1Char('\n')))
                postCommand(cmd.toLatin1());
        }
Esempio n. 20
0
void PdbEngine::removeBreakpoint(BreakpointModelId id)
{
    BreakHandler *handler = breakHandler();
    QTC_CHECK(handler->state(id) == BreakpointRemoveRequested);
    handler->notifyBreakpointRemoveProceeding(id);
    BreakpointResponse br = handler->response(id);
    showMessage(_("DELETING BP %1 IN %2").arg(br.id.toString())
        .arg(handler->fileName(id)));
    postCommand("clear " + br.id.toByteArray());
    // Pretend it succeeds without waiting for response.
    handler->notifyBreakpointRemoveOk(id);
}
Esempio n. 21
0
void PdbEngine::removeBreakpoint(BreakpointId id)
{
    BreakHandler *handler = breakHandler();
    QTC_ASSERT(handler->state(id) == BreakpointRemoveRequested, /**/);
    handler->notifyBreakpointRemoveProceeding(id);
    BreakpointResponse br = handler->response(id);
    showMessage(_("DELETING BP %1 IN %2").arg(br.number)
        .arg(handler->fileName(id)));
    postCommand("clear " + QByteArray::number(br.number));
    // Pretend it succeeds without waiting for response.
    handler->notifyBreakpointRemoveOk(id);
}
Esempio n. 22
0
void GdbTermEngine::setupInferior()
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    const qint64 attachedPID = m_stubProc.applicationPID();
#ifdef Q_OS_WIN
    const qint64 attachedMainThreadID = m_stubProc.applicationMainThreadID();
    showMessage(QString::fromLatin1("Attaching to %1 (%2)").arg(attachedPID).arg(attachedMainThreadID), LogMisc);
#else
    showMessage(QString::fromLatin1("Attaching to %1").arg(attachedPID), LogMisc);
#endif
    notifyInferiorPid(attachedPID);
    postCommand("attach " + QByteArray::number(attachedPID),
        CB(handleStubAttached));
}
bool
self::runSynchronousCommand(EscaladeCommand *ec)
{
    IOReturn	ret;

    // if we don't have the workloop lock already, get it
    if (!workLoop->inGate()) {
	ret = commandGate->runAction(synchronousCommandGateway, (void *)ec);
	return((ret == kIOReturnSuccess) ? true : false);
    }

    // We can't run on the workloop thread, since once we block we
    // will never be able to process the interrupt.
    if (workLoop->onThread()) {
	error("synchronous command dispatched while on workloop thread");
	return(false);
    }
    
    ret = ec->prepare(true);
    // check that prepare() succeeded
    if (ret != kIOReturnSuccess) {
	error("prepare() failed");
	ec->complete(false);
	return(false);
    }

    // post the command
    if (!postCommand(ec)) {
	error("failed to post command");
	ec->complete(false);
	return(false);
    }

    // wait for completion
    // XXX timeout!
    for (;;) {
	// Uniterruptible because getting the command back out of the controller
	// would involve a complete reset.
	ret = commandGate->commandSleep(ec, THREAD_UNINT);
	switch (ret) {
	    case THREAD_AWAKENED:	// completed as planned
		return(true);
	    case THREAD_RESTART:	// harmless, spin.
		break;
	    default:
		error("woke with unexpected result %d", ret);
		return(false);		// this is bad...
	}
    }
}
void GdbRemoteServerEngine::runEngine()
{
    QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());

    const QString remoteExecutable = startParameters().remoteExecutable;
    if (!remoteExecutable.isEmpty()) {
        // Cannot use -exec-run for QNX gdb 7.4 as it does not support path parameter for the MI call
        const bool useRun = m_isQnxGdb && m_gdbVersion > 70300;
        const QByteArray command = useRun ? "run" : "-exec-run";
        postCommand(command + " " + remoteExecutable.toLocal8Bit(), GdbEngine::RunRequest, CB(handleExecRun));
    } else {
        notifyEngineRunAndInferiorStopOk();
        continueInferiorInternal();
    }
}
Esempio n. 25
0
void PdbEngine::insertBreakpoint(BreakpointModelId id)
{
    BreakHandler *handler = breakHandler();
    QTC_CHECK(handler->state(id) == BreakpointInsertRequested);
    handler->notifyBreakpointInsertProceeding(id);

    QByteArray loc;
    if (handler->type(id) == BreakpointByFunction)
        loc = handler->functionName(id).toLatin1();
    else
        loc = handler->fileName(id).toLocal8Bit() + ':'
         + QByteArray::number(handler->lineNumber(id));

    postCommand("break " + loc, CB(handleBreakInsert), QVariant(id));
}
void GdbRemoteServerEngine::interruptInferior2()
{
    QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state());
    if (debuggerCore()->boolSetting(TargetAsync)) {
        postCommand("-exec-interrupt", GdbEngine::Immediate,
            CB(handleInterruptInferior));
    } else {
        bool ok = m_gdbProc.interrupt();
        if (!ok) {
            // FIXME: Extra state needed?
            showMessage(_("NOTE: INFERIOR STOP NOT POSSIBLE"));
            showStatusMessage(tr("Interrupting not possible"));
            notifyInferiorRunOk();
        }
    }
}
Esempio n. 27
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();
}
bool
self::runAsynchronousCommand(EscaladeCommand *ec)
{
    IOReturn	ret;

    // if not on the workloop, get ourselves there
    if (!workLoop->inGate()) {
	ret = commandGate->runAction(asynchronousCommandGateway, (void *)ec);
	return((ret == kIOReturnSuccess) ? true : false);
    }

    // hold if controller in reset
    while(resetting) {
	ret = commandGate->commandSleep(&resetting, THREAD_UNINT);
	switch (ret) {
	    case THREAD_AWAKENED:	// completed as planned
		goto reset_done;
	    case THREAD_RESTART:	// harmless, spin.
		break;
	    default:
		debug(3, "woke with unexpected result %d", ret);
		return(false);
	}
    }
reset_done:
    
    // we will not be waiting on this command
    ret = ec->prepare(false);
    // check that prepare() succeeded
    if (ret != kIOReturnSuccess) {
	ec->complete(false);
	return(false);
    }

    // post the actual command
    if (!postCommand(ec)) {
	error("failed to post command");
	ec->complete(false);
	return(false);
    }

    // command will complete asynchronously once we're off the workloop
    return(true);
}
Esempio n. 29
0
void GdbCoreEngine::handleTargetCore(const GdbResponse &response)
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    if (response.resultClass == GdbResultDone) {
        showMessage(tr("Attached to core."), StatusBar);
        handleInferiorPrepared();
        // Due to the auto-solib-add off setting, we don't have any
        // symbols yet. Load them in order of importance.
        reloadStack(true);
        reloadModulesInternal();
        postCommand("p 5", CB(handleRoundTrip));
        return;
    }
    QString msg = tr("Attach to core \"%1\" failed:")
        .arg(startParameters().coreFile)
        + QLatin1Char('\n')
        + QString::fromLocal8Bit(response.data["msg"].data());
    notifyInferiorSetupFailed(msg);
}
Esempio n. 30
0
void GdbPlainEngine::handleExecRun(const GdbResponse &response)
{
    QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
    if (response.resultClass == GdbResultRunning) {
        //notifyEngineRunOkAndInferiorRunRequested();
        notifyEngineRunAndInferiorRunOk(); // For gdb < 7.0
        //showStatusMessage(tr("Running..."));
        showMessage(_("INFERIOR STARTED"));
        showMessage(msgInferiorSetupOk(), StatusBar);
        // FIXME: That's the wrong place for it.
        if (debuggerCore()->boolSetting(EnableReverseDebugging))
            postCommand("target record");
    } else {
        QString msg = fromLocalEncoding(response.data["msg"].data());
        //QTC_CHECK(status() == InferiorRunOk);
        //interruptInferior();
        showMessage(msg);
        notifyEngineRunFailed();
    }
}