RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, RunMode mode, QString *errorMessage)
{
    Q_ASSERT(canRun(runConfig, mode));

    RemoteLinuxRunConfiguration *rc = qobject_cast<RemoteLinuxRunConfiguration *>(runConfig);
    Q_ASSERT(rc);
    if (mode == ProjectExplorer::NormalRunMode)
        return new RemoteLinuxRunControl(rc);

    DebuggerStartParameters params = LinuxDeviceDebugSupport::startParameters(rc);
    if (mode == ProjectExplorer::DebugRunModeWithBreakOnMain)
        params.breakOnMain = true;
    DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc, errorMessage);
    if (!runControl)
        return 0;
    LinuxDeviceDebugSupport * const debugSupport =
            new LinuxDeviceDebugSupport(rc, runControl->engine());
    connect(runControl, SIGNAL(finished()), debugSupport, SLOT(handleDebuggingFinished()));
    return runControl;
}
Esempio n. 2
0
RunControl *MaemoDebugSupport::createDebugRunControl(RemoteLinuxRunConfiguration *runConfig)
{
    DebuggerStartParameters params;
    const LinuxDeviceConfiguration::ConstPtr &devConf = runConfig->deviceConfig();

    const RemoteLinuxRunConfiguration::DebuggingType debuggingType
        = runConfig->debuggingType();
    if (debuggingType != RemoteLinuxRunConfiguration::DebugCppOnly) {
        params.qmlServerAddress = runConfig->deviceConfig()->sshParameters().host;
        params.qmlServerPort = -1;
    }
    if (debuggingType != RemoteLinuxRunConfiguration::DebugQmlOnly) {
        params.processArgs = runConfig->arguments();
        if (runConfig->activeQt4BuildConfiguration()->qtVersion())
            params.sysroot = runConfig->activeQt4BuildConfiguration()->qtVersion()->systemRoot();
        params.toolChainAbi = runConfig->abi();
        if (runConfig->useRemoteGdb()) {
            params.startMode = StartRemoteGdb;
            params.executable = runConfig->remoteExecutableFilePath();
            params.debuggerCommand = runConfig->commandPrefix() + QLatin1String(" /usr/bin/gdb");
            params.connParams = devConf->sshParameters();
            params.localMountDir = runConfig->localDirToMountForRemoteGdb();
            params.remoteMountPoint
                = runConfig->remoteProjectSourcesMountPoint();
            const QString execDirAbs
                = QDir::fromNativeSeparators(QFileInfo(runConfig->localExecutableFilePath()).path());
            const QString execDirRel
                = QDir(params.localMountDir).relativeFilePath(execDirAbs);
            params.remoteSourcesDir = QString(params.remoteMountPoint
                + QLatin1Char('/') + execDirRel).toUtf8();
        } else {
            params.startMode = AttachToRemote;
            params.executable = runConfig->localExecutableFilePath();
            params.debuggerCommand = runConfig->gdbCmd();
            params.remoteChannel
                = devConf->sshParameters().host + QLatin1String(":-1");
            params.useServerStartScript = true;

            // TODO: This functionality should be inside the debugger.
            const ProjectExplorer::Abi &abi = runConfig->target()
                ->activeBuildConfiguration()->toolChain()->targetAbi();
            params.remoteArchitecture = abi.toString();
            params.gnuTarget = QLatin1String(abi.architecture() == ProjectExplorer::Abi::ArmArchitecture
                ? "arm-none-linux-gnueabi": "i386-unknown-linux-gnu");
        }
    } else {
        params.startMode = AttachToRemote;
    }
    params.displayName = runConfig->displayName();

    if (const ProjectExplorer::Project *project = runConfig->target()->project()) {
        params.projectSourceDirectory = project->projectDirectory();
        if (const ProjectExplorer::BuildConfiguration *buildConfig = runConfig->target()->activeBuildConfiguration()) {
            params.projectBuildDirectory = buildConfig->buildDirectory();
        }
        params.projectSourceFiles = project->files(Project::ExcludeGeneratedFiles);
    }

    DebuggerRunControl * const runControl =
        DebuggerPlugin::createDebugger(params, runConfig);
    bool useGdb = params.startMode == StartRemoteGdb
        && debuggingType != RemoteLinuxRunConfiguration::DebugQmlOnly;
    MaemoDebugSupport *debugSupport =
        new MaemoDebugSupport(runConfig, runControl->engine(), useGdb);
    connect(runControl, SIGNAL(finished()),
        debugSupport, SLOT(handleDebuggingFinished()));
    return runControl;
}