void StartGdbServerDialog::attachToProcess()
{
    const QModelIndexList &indexes =
            d->tableView->selectionModel()->selectedIndexes();
    if (indexes.empty())
        return;
    d->attachProcessButton->setEnabled(false);

    LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
    if (!device)
        return;
    PortList ports = device->freePorts();
    const int port = d->gatherer.getNextFreePort(&ports);
    const int row = d->proxyModel.mapToSource(indexes.first()).row();
    QTC_ASSERT(row >= 0, return);
    RemoteProcess process = d->processList->at(row);
    d->remoteCommandLine = process.cmdLine;
    d->remoteExecutable = process.exe;
    if (port == -1) {
        reportFailure();
        return;
    }

    d->settings->setValue(LastProfile, d->profileChooser->currentProfileId().toString());
    d->settings->setValue(LastDevice, d->deviceComboBox->currentIndex());
    d->settings->setValue(LastProcessName, d->processFilterLineEdit->text());

    startGdbServerOnPort(port, process.pid);
}
Exemple #2
0
PortList MaemoGlobal::freePorts(const LinuxDeviceConfiguration::ConstPtr &devConf,
    const QtSupport::BaseQtVersion *qtVersion)
{
    if (!devConf || !qtVersion)
        return PortList();
    if (devConf->type() == LinuxDeviceConfiguration::Emulator) {
        MaemoQemuRuntime rt;
        const int id = qtVersion->uniqueId();
        if (MaemoQemuManager::instance().runtimeForQtVersion(id, &rt))
            return rt.m_freePorts;
    }
    return devConf->freePorts();
}