aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/debugger/debuggerplugin.cpp
diff options
context:
space:
mode:
authorEike Ziller <[email protected]>2017-10-19 13:01:12 +0200
committerEike Ziller <[email protected]>2017-10-19 13:01:12 +0200
commitbb9663529beec0530f227cb196907d8a87593a3d (patch)
treebd772de7f00d73086e1d0c0a051b9fefafdeefb2 /src/plugins/debugger/debuggerplugin.cpp
parent7208ef1ff51e766ae5af64c95436b74a6535d811 (diff)
parent38d307ffb84e4c945682263e2e006ddf23aed857 (diff)
Merge remote-tracking branch 'origin/4.5'
Diffstat (limited to 'src/plugins/debugger/debuggerplugin.cpp')
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp73
1 files changed, 41 insertions, 32 deletions
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index d8ee01a58f6..e5b8d8fdbe6 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -61,7 +61,6 @@
#include "snapshothandler.h"
#include "threadshandler.h"
#include "commonoptionspage.h"
-#include "gdb/startgdbserverdialog.h"
#include "analyzer/analyzerconstants.h"
#include "analyzer/analyzermanager.h"
@@ -734,7 +733,6 @@ public:
void updateDebugWithoutDeployMenu();
void startRemoteCdbSession();
- void startRemoteServerAndAttachToProcess();
void attachToRunningApplication();
void attachToUnstartedApplicationDialog();
void attachToQmlPort();
@@ -980,7 +978,6 @@ public:
QAction *m_startAction = 0;
QAction *m_debugWithoutDeployAction = 0;
QAction *m_startAndDebugApplicationAction = 0;
- QAction *m_startRemoteServerAction = 0;
QAction *m_attachToRunningApplication = 0;
QAction *m_attachToUnstartedApplication = 0;
QAction *m_attachToQmlPortAction = 0;
@@ -1506,10 +1503,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
act->setText(tr("Attach to Running Debug Server..."));
connect(act, &QAction::triggered, this, &StartApplicationDialog::attachToRemoteServer);
- act = m_startRemoteServerAction = new QAction(this);
- act->setText(tr("Start Debug Server Attached to Process..."));
- connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::startRemoteServerAndAttachToProcess);
-
act = m_attachToRunningApplication = new QAction(this);
act->setText(tr("Attach to Running Application..."));
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::attachToRunningApplication);
@@ -1583,11 +1576,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
cmd->setAttribute(Command::CA_Hide);
mstart->addAction(cmd, Constants::G_SPECIAL);
- cmd = ActionManager::registerAction(m_startRemoteServerAction,
- "Debugger.StartRemoteServer");
- cmd->setDescription(tr("Start Gdbserver"));
- mstart->addAction(cmd, Constants::G_SPECIAL);
-
if (m_startRemoteCdbAction) {
cmd = ActionManager::registerAction(m_startRemoteCdbAction,
"Debugger.AttachRemoteCdb");
@@ -1991,30 +1979,48 @@ void DebuggerPluginPrivate::startRemoteCdbSession()
debugger->startRunControl();
}
-void DebuggerPluginPrivate::startRemoteServerAndAttachToProcess()
+class RemoteAttachRunner : public DebuggerRunTool
{
- auto kitChooser = new DebuggerKitChooser(DebuggerKitChooser::AnyDebugging);
- auto dlg = new DeviceProcessesDialog(kitChooser, ICore::dialogParent());
- dlg->addAcceptButton(DeviceProcessesDialog::tr("&Attach to Process"));
- dlg->showAllDevices();
- if (dlg->exec() == QDialog::Rejected) {
- delete dlg;
- return;
+public:
+ RemoteAttachRunner(RunControl *runControl, Kit *kit, int pid)
+ : DebuggerRunTool(runControl, kit)
+ {
+ IDevice::ConstPtr device = DeviceKitInformation::device(kit);
+ setDisplayName("AttachToRunningProcess");
+
+ portsGatherer = new GdbServerPortsGatherer(runControl);
+ portsGatherer->setUseGdbServer(true);
+ portsGatherer->setUseQmlServer(false);
+ portsGatherer->setDevice(device);
+
+ auto gdbServer = new GdbServerRunner(runControl, portsGatherer);
+ gdbServer->setUseMulti(false);
+ gdbServer->addStartDependency(portsGatherer);
+ gdbServer->setDevice(device);
+ gdbServer->setAttachPid(ProcessHandle(pid));
+
+ addStartDependency(gdbServer);
+
+ setStartMode(AttachToRemoteProcess);
+ setCloseMode(DetachAtClose);
+
+ // setInferiorExecutable(localExecutable);
+ setUseContinueInsteadOfRun(true);
+ setContinueAfterAttach(false);
}
- dlg->setAttribute(Qt::WA_DeleteOnClose);
- Kit *kit = kitChooser->currentKit();
- QTC_ASSERT(kit, return);
- IDevice::ConstPtr device = DeviceKitInformation::device(kit);
- QTC_ASSERT(device, return);
+ void start() final
+ {
+ setRemoteChannel(portsGatherer->gdbServerChannel());
+ DebuggerRunTool::start();
+ }
- GdbServerStarter *starter = new GdbServerStarter(dlg, true);
- starter->run();
-}
+ GdbServerPortsGatherer *portsGatherer;
+};
void DebuggerPluginPrivate::attachToRunningApplication()
{
- auto kitChooser = new DebuggerKitChooser(DebuggerKitChooser::LocalDebugging);
+ auto kitChooser = new DebuggerKitChooser(DebuggerKitChooser::AnyDebugging);
auto dlg = new DeviceProcessesDialog(kitChooser, ICore::dialogParent());
dlg->addAcceptButton(DeviceProcessesDialog::tr("&Attach to Process"));
@@ -2030,11 +2036,14 @@ void DebuggerPluginPrivate::attachToRunningApplication()
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
QTC_ASSERT(device, return);
+ DeviceProcessItem process = dlg->currentProcess();
+
if (device->type() == PE::DESKTOP_DEVICE_TYPE) {
- attachToRunningProcess(kit, dlg->currentProcess(), false);
+ attachToRunningProcess(kit, process, false);
} else {
- GdbServerStarter *starter = new GdbServerStarter(dlg, true);
- starter->run();
+ auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE);
+ auto debugger = new RemoteAttachRunner(runControl, kit, process.pid);
+ debugger->startRunControl();
}
}