2011-10-18 17:13:33 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2011-10-18 17:13:33 +02:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2011-10-18 17:13:33 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2011-10-18 17:13:33 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2011-09-22 11:18:14 +02:00
|
|
|
#include "startgdbserverdialog.h"
|
|
|
|
|
|
2012-03-02 11:43:16 +01:00
|
|
|
#include "devicemanagermodel.h"
|
2011-09-22 11:18:14 +02:00
|
|
|
#include "remotelinuxprocesslist.h"
|
|
|
|
|
#include "linuxdeviceconfiguration.h"
|
|
|
|
|
#include "linuxdeviceconfigurations.h"
|
|
|
|
|
#include "remotelinuxusedportsgatherer.h"
|
|
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
2011-12-05 19:10:32 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
#include <utils/pathchooser.h>
|
2012-02-28 10:34:50 +01:00
|
|
|
#include <utils/portlist.h>
|
2011-12-06 15:39:25 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2011-09-22 11:18:14 +02:00
|
|
|
#include <utils/ssh/sshconnection.h>
|
|
|
|
|
#include <utils/ssh/sshremoteprocessrunner.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QVariant>
|
|
|
|
|
#include <QSettings>
|
2011-12-06 15:39:25 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAction>
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QDialog>
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
#include <QSpacerItem>
|
|
|
|
|
#include <QTableView>
|
|
|
|
|
#include <QTextBrowser>
|
|
|
|
|
#include <QVBoxLayout>
|
2011-12-06 15:39:25 +01:00
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
const char LastSysroot[] = "RemoteLinux/LastSysroot";
|
|
|
|
|
const char LastDevice[] = "RemoteLinux/LastDevice";
|
|
|
|
|
const char LastProcessName[] = "RemoteLinux/LastProcessName";
|
|
|
|
|
//const char LastLocalExecutable[] = "RemoteLinux/LastLocalExecutable";
|
2011-09-22 11:18:14 +02:00
|
|
|
|
|
|
|
|
namespace RemoteLinux {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class StartGdbServerDialogPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-12-06 15:39:25 +01:00
|
|
|
StartGdbServerDialogPrivate(StartGdbServerDialog *q);
|
2011-09-22 11:18:14 +02:00
|
|
|
|
|
|
|
|
LinuxDeviceConfiguration::ConstPtr currentDevice() const
|
|
|
|
|
{
|
|
|
|
|
LinuxDeviceConfigurations *devices = LinuxDeviceConfigurations::instance();
|
2011-12-06 15:39:25 +01:00
|
|
|
return devices->deviceAt(deviceComboBox->currentIndex());
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
StartGdbServerDialog *q;
|
2011-09-22 11:18:14 +02:00
|
|
|
AbstractRemoteLinuxProcessList *processList;
|
|
|
|
|
QSortFilterProxyModel proxyModel;
|
2011-12-06 15:39:25 +01:00
|
|
|
|
|
|
|
|
QComboBox *deviceComboBox;
|
|
|
|
|
QLineEdit *processFilterLineEdit;
|
|
|
|
|
QTableView *tableView;
|
|
|
|
|
QPushButton *attachProcessButton;
|
|
|
|
|
QTextBrowser *textBrowser;
|
|
|
|
|
QPushButton *closeButton;
|
|
|
|
|
PathChooser *sysrootPathChooser;
|
|
|
|
|
|
2011-12-21 20:14:42 +01:00
|
|
|
RemoteLinuxUsedPortsGatherer gatherer;
|
2011-12-06 15:39:25 +01:00
|
|
|
SshRemoteProcessRunner runner;
|
|
|
|
|
QSettings *settings;
|
|
|
|
|
QString remoteCommandLine;
|
2011-09-22 11:18:14 +02:00
|
|
|
};
|
|
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q)
|
2011-12-21 20:14:42 +01:00
|
|
|
: q(q), processList(0)
|
2011-12-06 15:39:25 +01:00
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
settings = ICore::settings();
|
2011-12-06 15:39:25 +01:00
|
|
|
|
|
|
|
|
deviceComboBox = new QComboBox(q);
|
|
|
|
|
|
|
|
|
|
sysrootPathChooser = new PathChooser(q);
|
|
|
|
|
sysrootPathChooser->setExpectedKind(PathChooser::Directory);
|
|
|
|
|
sysrootPathChooser->setPromptDialogTitle(StartGdbServerDialog::tr("Select Sysroot"));
|
|
|
|
|
sysrootPathChooser->setPath(settings->value(LastSysroot).toString());
|
|
|
|
|
|
|
|
|
|
//executablePathChooser = new PathChooser(q);
|
|
|
|
|
//executablePathChooser->setExpectedKind(PathChooser::File);
|
|
|
|
|
//executablePathChooser->setPromptDialogTitle(StartGdbServerDialog::tr("Select Executable"));
|
|
|
|
|
//executablePathChooser->setPath(settings->value(LastLocalExecutable).toString());
|
|
|
|
|
|
|
|
|
|
processFilterLineEdit = new QLineEdit(q);
|
|
|
|
|
processFilterLineEdit->setText(settings->value(LastProcessName).toString());
|
|
|
|
|
processFilterLineEdit->selectAll();
|
|
|
|
|
|
|
|
|
|
tableView = new QTableView(q);
|
|
|
|
|
tableView->setShowGrid(false);
|
|
|
|
|
tableView->setSortingEnabled(true);
|
|
|
|
|
tableView->horizontalHeader()->setDefaultSectionSize(100);
|
|
|
|
|
tableView->horizontalHeader()->setStretchLastSection(true);
|
|
|
|
|
tableView->verticalHeader()->setVisible(false);
|
|
|
|
|
tableView->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
|
|
|
|
|
|
attachProcessButton = new QPushButton(q);
|
|
|
|
|
attachProcessButton->setText(StartGdbServerDialog::tr("&Attach to Selected Process"));
|
|
|
|
|
|
|
|
|
|
closeButton = new QPushButton(q);
|
|
|
|
|
closeButton->setText(StartGdbServerDialog::tr("Close"));
|
|
|
|
|
|
|
|
|
|
textBrowser = new QTextBrowser(q);
|
|
|
|
|
textBrowser->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
QFormLayout *formLayout = new QFormLayout();
|
|
|
|
|
formLayout->addRow(StartGdbServerDialog::tr("Device:"), deviceComboBox);
|
|
|
|
|
formLayout->addRow(StartGdbServerDialog::tr("Sysroot:"), sysrootPathChooser);
|
|
|
|
|
formLayout->addRow(StartGdbServerDialog::tr("&Filter by process name:"),
|
|
|
|
|
processFilterLineEdit);
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *horizontalLayout2 = new QHBoxLayout();
|
|
|
|
|
horizontalLayout2->addStretch(1);
|
|
|
|
|
horizontalLayout2->addWidget(attachProcessButton);
|
|
|
|
|
horizontalLayout2->addWidget(closeButton);
|
|
|
|
|
|
|
|
|
|
formLayout->addRow(tableView);
|
|
|
|
|
formLayout->addRow(textBrowser);
|
|
|
|
|
formLayout->addRow(horizontalLayout2);
|
|
|
|
|
q->setLayout(formLayout);
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-22 11:18:14 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
|
2011-09-22 11:18:14 +02:00
|
|
|
StartGdbServerDialog::StartGdbServerDialog(QWidget *parent) :
|
|
|
|
|
QDialog(parent),
|
2011-12-06 15:39:25 +01:00
|
|
|
d(new Internal::StartGdbServerDialogPrivate(this))
|
2011-09-22 11:18:14 +02:00
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
setWindowTitle(tr("List of Remote Processes"));
|
|
|
|
|
|
2011-09-22 11:18:14 +02:00
|
|
|
LinuxDeviceConfigurations *devices = LinuxDeviceConfigurations::instance();
|
2012-03-02 11:43:16 +01:00
|
|
|
DeviceManagerModel * const model = new DeviceManagerModel(devices, this);
|
2011-12-06 15:39:25 +01:00
|
|
|
|
|
|
|
|
QObject::connect(d->closeButton, SIGNAL(clicked()), this, SLOT(reject()));
|
|
|
|
|
|
2012-03-02 11:43:16 +01:00
|
|
|
d->deviceComboBox->setModel(model);
|
2011-12-06 15:39:25 +01:00
|
|
|
d->deviceComboBox->setCurrentIndex(d->settings->value(LastDevice).toInt());
|
2011-12-21 20:14:42 +01:00
|
|
|
connect(&d->gatherer, SIGNAL(error(QString)), SLOT(portGathererError(QString)));
|
|
|
|
|
connect(&d->gatherer, SIGNAL(portListReady()), SLOT(portListReady()));
|
2012-03-02 11:43:16 +01:00
|
|
|
if (devices->deviceCount() == 0) {
|
2011-12-06 15:39:25 +01:00
|
|
|
d->tableView->setEnabled(false);
|
2011-09-22 11:18:14 +02:00
|
|
|
} else {
|
2011-12-06 15:39:25 +01:00
|
|
|
d->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
2011-09-22 11:18:14 +02:00
|
|
|
d->proxyModel.setDynamicSortFilter(true);
|
|
|
|
|
d->proxyModel.setFilterKeyColumn(1);
|
2011-12-06 15:39:25 +01:00
|
|
|
d->tableView->setModel(&d->proxyModel);
|
|
|
|
|
connect(d->processFilterLineEdit, SIGNAL(textChanged(QString)),
|
2011-09-22 11:18:14 +02:00
|
|
|
&d->proxyModel, SLOT(setFilterRegExp(QString)));
|
|
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
connect(d->tableView->selectionModel(),
|
2011-09-22 11:18:14 +02:00
|
|
|
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
2011-12-06 15:39:25 +01:00
|
|
|
SLOT(updateButtons()));
|
2012-01-04 14:20:01 +01:00
|
|
|
connect(d->sysrootPathChooser, SIGNAL(changed(QString)),
|
|
|
|
|
SLOT(updateButtons()));
|
2011-12-06 15:39:25 +01:00
|
|
|
//connect(d->updateListButton, SIGNAL(clicked()),
|
|
|
|
|
// SLOT(updateProcessList()));
|
|
|
|
|
connect(d->attachProcessButton, SIGNAL(clicked()), SLOT(attachToProcess()));
|
2011-09-22 11:18:14 +02:00
|
|
|
connect(&d->proxyModel, SIGNAL(layoutChanged()),
|
|
|
|
|
SLOT(handleProcessListUpdated()));
|
2011-12-06 15:39:25 +01:00
|
|
|
connect(d->deviceComboBox, SIGNAL(currentIndexChanged(int)),
|
2011-09-22 11:18:14 +02:00
|
|
|
SLOT(attachToDevice(int)));
|
2011-12-06 15:39:25 +01:00
|
|
|
updateButtons();
|
|
|
|
|
attachToDevice(d->deviceComboBox->currentIndex());
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StartGdbServerDialog::~StartGdbServerDialog()
|
|
|
|
|
{
|
|
|
|
|
delete d->processList;
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::attachToDevice(int index)
|
|
|
|
|
{
|
|
|
|
|
LinuxDeviceConfigurations *devices = LinuxDeviceConfigurations::instance();
|
|
|
|
|
delete d->processList;
|
|
|
|
|
d->processList = new GenericRemoteLinuxProcessList(devices->deviceAt(index));
|
|
|
|
|
d->proxyModel.setSourceModel(d->processList);
|
|
|
|
|
connect(d->processList, SIGNAL(error(QString)),
|
|
|
|
|
SLOT(handleRemoteError(QString)));
|
|
|
|
|
connect(d->processList, SIGNAL(modelReset()),
|
|
|
|
|
SLOT(handleProcessListUpdated()));
|
|
|
|
|
connect(d->processList, SIGNAL(processKilled()),
|
|
|
|
|
SLOT(handleProcessKilled()), Qt::QueuedConnection);
|
|
|
|
|
updateProcessList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::handleRemoteError(const QString &errorMsg)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::critical(this, tr("Remote Error"), errorMsg);
|
2011-12-06 15:39:25 +01:00
|
|
|
updateButtons();
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::handleProcessListUpdated()
|
|
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
d->tableView->resizeRowsToContents();
|
|
|
|
|
updateButtons();
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::updateProcessList()
|
|
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
d->attachProcessButton->setEnabled(false);
|
2011-09-22 11:18:14 +02:00
|
|
|
d->processList->update();
|
2011-12-06 15:39:25 +01:00
|
|
|
d->proxyModel.setFilterRegExp(QString());
|
|
|
|
|
d->proxyModel.setFilterRegExp(d->processFilterLineEdit->text());
|
|
|
|
|
updateButtons();
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::attachToProcess()
|
|
|
|
|
{
|
|
|
|
|
const QModelIndexList &indexes =
|
2011-12-06 15:39:25 +01:00
|
|
|
d->tableView->selectionModel()->selectedIndexes();
|
2011-09-22 11:18:14 +02:00
|
|
|
if (indexes.empty())
|
|
|
|
|
return;
|
2011-12-06 15:39:25 +01:00
|
|
|
d->attachProcessButton->setEnabled(false);
|
2011-09-22 11:18:14 +02:00
|
|
|
|
|
|
|
|
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
|
|
|
|
|
PortList ports = device->freePorts();
|
2011-12-21 20:14:42 +01:00
|
|
|
const int port = d->gatherer.getNextFreePort(&ports);
|
2011-09-22 11:18:14 +02:00
|
|
|
const int row = d->proxyModel.mapToSource(indexes.first()).row();
|
2011-12-06 15:39:25 +01:00
|
|
|
QTC_ASSERT(row >= 0, return);
|
2011-09-22 11:18:14 +02:00
|
|
|
const int pid = d->processList->pidAt(row);
|
2011-12-06 15:39:25 +01:00
|
|
|
d->remoteCommandLine = d->processList->commandLineAt(row);
|
2011-09-22 11:18:14 +02:00
|
|
|
if (port == -1) {
|
2011-12-06 15:39:25 +01:00
|
|
|
reportFailure();
|
|
|
|
|
return;
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
2011-12-06 15:39:25 +01:00
|
|
|
|
|
|
|
|
d->settings->setValue(LastSysroot, d->sysrootPathChooser->path());
|
|
|
|
|
d->settings->setValue(LastDevice, d->deviceComboBox->currentIndex());
|
|
|
|
|
d->settings->setValue(LastProcessName, d->processFilterLineEdit->text());
|
|
|
|
|
|
|
|
|
|
startGdbServerOnPort(port, pid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::reportFailure()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(false, /**/);
|
|
|
|
|
logMessage(tr("Process aborted"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::logMessage(const QString &line)
|
|
|
|
|
{
|
|
|
|
|
d->textBrowser->append(line);
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::handleProcessKilled()
|
|
|
|
|
{
|
|
|
|
|
updateProcessList();
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
void StartGdbServerDialog::updateButtons()
|
2011-09-22 11:18:14 +02:00
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
d->attachProcessButton->setEnabled(d->tableView->selectionModel()->hasSelection()
|
|
|
|
|
|| d->proxyModel.rowCount() == 1);
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::portGathererError(const QString &text)
|
|
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
logMessage(tr("Could not retrieve list of free ports:"));
|
|
|
|
|
logMessage(text);
|
|
|
|
|
reportFailure();
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::portListReady()
|
|
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
updateButtons();
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::startGdbServer()
|
|
|
|
|
{
|
|
|
|
|
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
|
2011-12-21 20:14:42 +01:00
|
|
|
d->gatherer.start(SshConnection::create(device->sshParameters()), device);
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
2011-12-05 19:10:32 +01:00
|
|
|
void StartGdbServerDialog::attachToRemoteProcess()
|
|
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
startGdbServer();
|
2011-12-05 19:10:32 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-22 11:18:14 +02:00
|
|
|
void StartGdbServerDialog::handleConnectionError()
|
|
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
logMessage(tr("Connection error: %1").arg(d->runner.lastConnectionErrorString()));
|
2011-09-22 11:18:14 +02:00
|
|
|
emit processAborted();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::handleProcessStarted()
|
|
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
logMessage(tr("Starting gdbserver..."));
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::handleProcessOutputAvailable(const QByteArray &ba)
|
|
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
logMessage(QString::fromUtf8(ba.trimmed()));
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::handleProcessErrorOutput(const QByteArray &ba)
|
|
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
logMessage(QString::fromUtf8(ba.trimmed()));
|
2011-09-22 11:18:14 +02:00
|
|
|
// "Attached; pid = 16740"
|
|
|
|
|
// "Listening on port 10000"
|
|
|
|
|
int pos = ba.indexOf("Listening on port");
|
2011-12-06 15:39:25 +01:00
|
|
|
if (pos == -1)
|
|
|
|
|
return;
|
|
|
|
|
const int port = ba.mid(pos + 18).trimmed().toInt();
|
|
|
|
|
logMessage(tr("Port %1 is now accessible.").arg(port));
|
|
|
|
|
reportOpenPort(port);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::reportOpenPort(int port)
|
|
|
|
|
{
|
|
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
QObject *ob = pm->getObjectByName("DebuggerCore");
|
|
|
|
|
if (!ob)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
|
2012-02-29 17:14:03 +01:00
|
|
|
QString channel = QString("%1:%2").arg(device->sshParameters().host).arg(port);
|
2011-12-06 15:39:25 +01:00
|
|
|
logMessage(tr("Server started on %1").arg(channel));
|
|
|
|
|
|
|
|
|
|
QMetaObject::invokeMethod(ob, "gdbServerStarted", Qt::QueuedConnection,
|
|
|
|
|
Q_ARG(QString, channel),
|
|
|
|
|
Q_ARG(QString, d->sysrootPathChooser->path()),
|
|
|
|
|
Q_ARG(QString, d->remoteCommandLine));
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::handleProcessClosed(int status)
|
|
|
|
|
{
|
2011-12-06 15:39:25 +01:00
|
|
|
logMessage(tr("Process gdbserver finished. Status: %1").arg(status));
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartGdbServerDialog::startGdbServerOnPort(int port, int pid)
|
|
|
|
|
{
|
|
|
|
|
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
|
2011-11-09 17:38:19 +01:00
|
|
|
connect(&d->runner, SIGNAL(connectionError()), SLOT(handleConnectionError()));
|
2011-11-09 14:19:50 +01:00
|
|
|
connect(&d->runner, SIGNAL(processStarted()), SLOT(handleProcessStarted()));
|
|
|
|
|
connect(&d->runner, SIGNAL(processOutputAvailable(QByteArray)),
|
|
|
|
|
SLOT(handleProcessOutputAvailable(QByteArray)));
|
|
|
|
|
connect(&d->runner, SIGNAL(processErrorOutputAvailable(QByteArray)),
|
|
|
|
|
SLOT(handleProcessErrorOutput(QByteArray)));
|
|
|
|
|
connect(&d->runner, SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int)));
|
2011-09-22 11:18:14 +02:00
|
|
|
|
2012-02-24 15:19:10 +01:00
|
|
|
QByteArray cmd = "/usr/bin/gdbserver --attach :"
|
2011-09-22 11:18:14 +02:00
|
|
|
+ QByteArray::number(port) + " " + QByteArray::number(pid);
|
2011-12-06 15:39:25 +01:00
|
|
|
logMessage(tr("Running command: %1").arg(QString::fromLatin1(cmd)));
|
2011-11-09 14:19:50 +01:00
|
|
|
d->runner.run(cmd, device->sshParameters());
|
2011-09-22 11:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace RemoteLinux
|