forked from qt-creator/qt-creator
Debugger: Introduce createDebuggerWorker and reuse it
Task-number: QTCREATORBUG-29168 Change-Id: I101fdc1589d36ff996eef12308cf4165143b04af Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -88,15 +88,12 @@ public:
|
||||
AndroidDebugWorkerFactory()
|
||||
{
|
||||
setProducer([](RunControl *runControl) {
|
||||
DebuggerRunTool *debugger = new DebuggerRunTool(runControl);
|
||||
debugger->setId("AndroidDebugger");
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setupPortsGatherer(runControl);
|
||||
rp.setSkipDebugServer(true);
|
||||
rp.setLldbPlatform("remote-android");
|
||||
|
||||
auto androidRunner = new RecipeRunner(runControl, androidRecipe(runControl));
|
||||
debugger->addStartDependency(androidRunner);
|
||||
|
||||
BuildConfiguration *bc = runControl->buildConfiguration();
|
||||
Kit *kit = runControl->kit();
|
||||
@@ -161,6 +158,9 @@ public:
|
||||
if (qtVersion)
|
||||
rp.addSearchDirectory(qtVersion->qmlPath());
|
||||
}
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
debugger->addStartDependency(androidRunner);
|
||||
|
||||
QObject::connect(debugger, &RunWorker::started, debugger, [runControl, packageName] {
|
||||
qCDebug(androidDebugSupportLog) << "Starting debugger - package name: " << packageName
|
||||
<< ", PID: " << runControl->attachPid().pid();
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Debugger;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Tasking;
|
||||
using namespace Utils;
|
||||
@@ -574,13 +575,15 @@ void TestRunner::debugTests()
|
||||
.arg(config->displayName());
|
||||
reportResult(ResultType::MessageWarn, details);
|
||||
}
|
||||
auto debugger = new Debugger::DebuggerRunTool(runControl);
|
||||
debugger->runParameters().setInferior(inferior);
|
||||
debugger->runParameters().setDisplayName(config->displayName());
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setInferior(inferior);
|
||||
rp.setDisplayName(config->displayName());
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
|
||||
bool useOutputProcessor = true;
|
||||
if (Kit *kit = config->project()->activeKit()) {
|
||||
if (Debugger::DebuggerKitAspect::engineType(kit) == Debugger::CdbEngineType) {
|
||||
if (DebuggerKitAspect::engineType(kit) == CdbEngineType) {
|
||||
reportResult(ResultType::MessageWarn,
|
||||
Tr::tr("Unable to display test results when using CDB."));
|
||||
useOutputProcessor = false;
|
||||
|
@@ -38,29 +38,32 @@ class BareMetalDebugSupportFactory final : public RunWorkerFactory
|
||||
public:
|
||||
BareMetalDebugSupportFactory()
|
||||
{
|
||||
setProducer([](RunControl *runControl) {
|
||||
DebuggerRunTool *debugger = new DebuggerRunTool(runControl);
|
||||
setProducer([](RunControl *runControl) -> RunWorker * {
|
||||
const auto dev = std::static_pointer_cast<const BareMetalDevice>(runControl->device());
|
||||
if (!dev) {
|
||||
// TODO: reportFailure won't work from RunWorker's c'tor.
|
||||
debugger->reportFailure(Tr::tr("Cannot debug: Kit has no device."));
|
||||
return debugger;
|
||||
runControl->postMessage(Tr::tr("Cannot debug: Kit has no device."), ErrorMessageFormat);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const QString providerId = dev->debugServerProviderId();
|
||||
IDebugServerProvider *p = DebugServerProviderManager::findProvider(providerId);
|
||||
if (!p) {
|
||||
// TODO: reportFailure won't work from RunWorker's c'tor.
|
||||
debugger->reportFailure(Tr::tr("No debug server provider found for %1").arg(providerId));
|
||||
return debugger;
|
||||
runControl->postMessage(Tr::tr("No debug server provider found for %1").arg(providerId),
|
||||
ErrorMessageFormat);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
if (Result<> res = p->setupDebuggerRunParameters(rp, runControl); !res) {
|
||||
runControl->postMessage(res.error(), ErrorMessageFormat); // TODO: reportFailure won't work from RunWorker's c'tor.
|
||||
return nullptr;
|
||||
}
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
if (RunWorker *runner = p->targetRunner(runControl))
|
||||
debugger->addStartDependency(runner);
|
||||
|
||||
if (Result<> res = p->setupDebuggerRunParameters(debugger->runParameters(), runControl); !res)
|
||||
debugger->reportFailure(res.error()); // TODO: reportFailure won't work from RunWorker's c'tor.
|
||||
|
||||
return debugger;
|
||||
});
|
||||
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
|
||||
|
@@ -113,10 +113,7 @@ public:
|
||||
QdbDebugWorkerFactory()
|
||||
{
|
||||
setProducer([](RunControl *runControl) {
|
||||
auto worker = new DebuggerRunTool(runControl);
|
||||
worker->setId("QdbDeviceDebugSupport");
|
||||
|
||||
DebuggerRunParameters &rp = worker->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setupPortsGatherer(runControl);
|
||||
rp.setStartMode(Debugger::AttachToRemoteServer);
|
||||
rp.setCloseMode(KillAndExitMonitorAtClose);
|
||||
@@ -125,11 +122,13 @@ public:
|
||||
rp.addSolibSearchDir("%{sysroot}/system/lib");
|
||||
rp.setSkipDebugServer(true);
|
||||
|
||||
auto debuggee = createQdbDeviceInferiorWorker(runControl, QmlDebuggerServices);
|
||||
worker->addStartDependency(debuggee);
|
||||
debuggee->addStopDependency(worker);
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
|
||||
return worker;
|
||||
auto debuggee = createQdbDeviceInferiorWorker(runControl, QmlDebuggerServices);
|
||||
debugger->addStartDependency(debuggee);
|
||||
debuggee->addStopDependency(debugger);
|
||||
|
||||
return debugger;
|
||||
});
|
||||
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
addSupportedRunConfig(Constants::QdbRunConfigurationId);
|
||||
|
@@ -405,9 +405,7 @@ void StartApplicationDialog::run(bool attachRemote)
|
||||
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
runControl->setKit(k);
|
||||
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
const QString inputAddress = dialog.channelOverrideEdit->text();
|
||||
if (!inputAddress.isEmpty()) {
|
||||
rp.setRemoteChannel(inputAddress);
|
||||
@@ -433,7 +431,7 @@ void StartApplicationDialog::run(bool attachRemote)
|
||||
rp.setInferiorEnvironment(k->runEnvironment());
|
||||
|
||||
if (!attachRemote)
|
||||
debugger->runParameters().setStartMode(isLocal ? StartExternal : StartRemoteProcess);
|
||||
rp.setStartMode(isLocal ? StartExternal : StartRemoteProcess);
|
||||
|
||||
if (attachRemote) {
|
||||
rp.setStartMode(AttachToRemoteServer);
|
||||
@@ -442,6 +440,9 @@ void StartApplicationDialog::run(bool attachRemote)
|
||||
rp.setDisplayName(Tr::tr("Attach to %1").arg(rp.remoteChannel().toDisplayString()));
|
||||
}
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
|
||||
runControl->start();
|
||||
}
|
||||
|
||||
@@ -574,8 +575,7 @@ void runAttachToQmlPortDialog()
|
||||
|
||||
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
runControl->setKit(kit);
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
|
||||
QUrl qmlServer = device->toolControlChannel(IDevice::QmlControlChannel);
|
||||
qmlServer.setPort(dlg.port());
|
||||
@@ -588,6 +588,9 @@ void runAttachToQmlPortDialog()
|
||||
rp.setRemoteChannel(channel);
|
||||
rp.setStartMode(AttachToQmlServer);
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
|
||||
runControl->start();
|
||||
}
|
||||
|
||||
@@ -721,12 +724,14 @@ void runStartRemoteCdbSessionDialog(Kit *kit)
|
||||
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
runControl->setKit(kit);
|
||||
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setStartMode(AttachToRemoteServer);
|
||||
rp.setCloseMode(KillAtClose);
|
||||
rp.setRemoteChannel(dlg.connection());
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
|
||||
runControl->start();
|
||||
}
|
||||
|
||||
|
@@ -1413,8 +1413,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
|
||||
|
||||
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
runControl->setKit(kit);
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setInferiorExecutable(executable);
|
||||
if (!sysRoot.isEmpty())
|
||||
rp.setSysRoot(FilePath::fromUserInput(sysRoot));
|
||||
@@ -1442,6 +1441,9 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
|
||||
}
|
||||
rp.setUseTerminal(useTerminal);
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
|
||||
m_scheduledStarts.append(runControl);
|
||||
return true;
|
||||
}
|
||||
@@ -1460,8 +1462,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
|
||||
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
runControl->setKit(findUniversalCdbKit());
|
||||
runControl->setAttachPid(ProcessHandle(pid));
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setStartMode(AttachToCrashedProcess);
|
||||
rp.setCrashParameter(it->section(':', 0, 0));
|
||||
rp.setDisplayName(Tr::tr("Crashed process %1").arg(pid));
|
||||
@@ -1471,6 +1472,10 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
|
||||
"does not match the pattern <handle>:<pid>.").arg(*it, option);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
|
||||
m_scheduledStarts.append(runControl);
|
||||
return true;
|
||||
}
|
||||
@@ -1637,13 +1642,15 @@ void DebuggerPluginPrivate::attachToLastCore()
|
||||
runControl->setKit(KitManager::defaultKit());
|
||||
runControl->setDisplayName(Tr::tr("Last Core file \"%1\"").arg(lastCore.coreFile.toUserOutput()));
|
||||
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setInferiorExecutable(lastCore.binary);
|
||||
rp.setCoreFilePath(lastCore.coreFile);
|
||||
rp.setStartMode(AttachToCore);
|
||||
rp.setCloseMode(DetachAtClose);
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
|
||||
runControl->start();
|
||||
}
|
||||
|
||||
@@ -1686,9 +1693,7 @@ void DebuggerPluginPrivate::attachToRunningApplication()
|
||||
runControl->setDisplayName(Tr::tr("Process %1").arg(processInfo.processId));
|
||||
runControl->requestDebugChannel();
|
||||
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
debugger->setId("AttachToRunningProcess");
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setServerAttachPid(ProcessHandle(processInfo.processId));
|
||||
rp.setServerUseMulti(false);
|
||||
rp.setServerEssential(false);
|
||||
@@ -1697,6 +1702,9 @@ void DebuggerPluginPrivate::attachToRunningApplication()
|
||||
rp.setUseContinueInsteadOfRun(true);
|
||||
rp.setContinueAfterAttach(false);
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
|
||||
runControl->start();
|
||||
}
|
||||
}
|
||||
@@ -1759,15 +1767,16 @@ RunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit,
|
||||
runControl->setDisplayName(Tr::tr("Process %1").arg(processInfo.processId));
|
||||
runControl->setAttachPid(ProcessHandle(processInfo.processId));
|
||||
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setInferiorExecutable(device->filePath(processInfo.executable));
|
||||
rp.setStartMode(AttachToLocalProcess);
|
||||
rp.setCloseMode(DetachAtClose);
|
||||
rp.setContinueAfterAttach(contAfterAttach);
|
||||
|
||||
runControl->start();
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
|
||||
runControl->start();
|
||||
return runControl;
|
||||
}
|
||||
|
||||
@@ -2319,12 +2328,14 @@ void DebuggerPlugin::attachExternalApplication(RunControl *rc)
|
||||
runControl->setDisplayName(Tr::tr("Process %1").arg(pid.pid()));
|
||||
runControl->setAttachPid(pid);
|
||||
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setInferiorExecutable(rc->targetFilePath());
|
||||
rp.setStartMode(AttachToLocalProcess);
|
||||
rp.setCloseMode(DetachAtClose);
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
|
||||
runControl->start();
|
||||
}
|
||||
|
||||
|
@@ -688,13 +688,14 @@ void EnginesDriver::start()
|
||||
rc->copyDataFromRunControl(m_runControl);
|
||||
rc->resetDataForAttachToCore();
|
||||
auto name = QString(Tr::tr("%1 - Snapshot %2").arg(m_runControl->displayName()).arg(++m_snapshotCounter));
|
||||
auto debugger = new DebuggerRunTool(rc);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(rc);
|
||||
rp.setStartMode(AttachToCore);
|
||||
rp.setCloseMode(DetachAtClose);
|
||||
rp.setDisplayName(name);
|
||||
rp.setCoreFilePath(FilePath::fromString(coreFile));
|
||||
rp.setSnapshot(true);
|
||||
auto debugger = createDebuggerWorker(rc, rp);
|
||||
Q_UNUSED(debugger)
|
||||
rc->start();
|
||||
});
|
||||
}
|
||||
@@ -835,6 +836,13 @@ Group debuggerRecipe(RunControl *runControl, const DebuggerRunParameters &initia
|
||||
};
|
||||
}
|
||||
|
||||
RunWorker *createDebuggerWorker(RunControl *runControl, const DebuggerRunParameters &initialParameters,
|
||||
const std::function<void(DebuggerRunParameters &)> ¶metersModifier)
|
||||
{
|
||||
return new RecipeRunner(runControl,
|
||||
debuggerRecipe(runControl, initialParameters, parametersModifier));
|
||||
}
|
||||
|
||||
void DebuggerRunTool::stop()
|
||||
{
|
||||
if (!d->m_taskTreeRunner.isRunning())
|
||||
@@ -875,7 +883,9 @@ class DebuggerRunWorkerFactory final : public ProjectExplorer::RunWorkerFactory
|
||||
public:
|
||||
DebuggerRunWorkerFactory()
|
||||
{
|
||||
setProduct<DebuggerRunTool>();
|
||||
setProducer([](RunControl *runControl) {
|
||||
return createDebuggerWorker(runControl, DebuggerRunParameters::fromRunControl(runControl));
|
||||
});
|
||||
setId(Constants::DEBUGGER_RUN_FACTORY);
|
||||
|
||||
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
|
@@ -19,6 +19,11 @@ DEBUGGER_EXPORT Tasking::Group debuggerRecipe(
|
||||
const DebuggerRunParameters &initialParameters,
|
||||
const std::function<void(DebuggerRunParameters &)> ¶metersModifier = {});
|
||||
|
||||
DEBUGGER_EXPORT ProjectExplorer::RunWorker *createDebuggerWorker(
|
||||
ProjectExplorer::RunControl *runControl,
|
||||
const DebuggerRunParameters &initialParameters,
|
||||
const std::function<void(DebuggerRunParameters &)> ¶metersModifier = {});
|
||||
|
||||
class DEBUGGER_EXPORT DebuggerRunTool final : public ProjectExplorer::RunWorker
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@@ -106,13 +106,13 @@ void DebuggerUnitTests::testStateMachine()
|
||||
|
||||
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
runControl->copyDataFromRunConfiguration(rc);
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setInferior(rc->runnable());
|
||||
rp.setTestCase(TestNoBoundsOfCurrentFunction);
|
||||
|
||||
connect(debugger, &DebuggerRunTool::stopped,
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
connect(debugger, &RunWorker::stopped,
|
||||
&QTestEventLoop::instance(), &QTestEventLoop::exitLoop);
|
||||
|
||||
runControl->start();
|
||||
@@ -120,7 +120,6 @@ void DebuggerUnitTests::testStateMachine()
|
||||
QTestEventLoop::instance().enterLoop(5);
|
||||
}
|
||||
|
||||
|
||||
enum FakeEnum { FakeDebuggerCommonSettingsId };
|
||||
|
||||
void DebuggerUnitTests::testBenchmark()
|
||||
|
@@ -349,8 +349,7 @@ void runAttachToCoreDialog()
|
||||
runControl->setKit(dlg.kit());
|
||||
runControl->setDisplayName(Tr::tr("Core file \"%1\"").arg(dlg.coreFile().toUserOutput()));
|
||||
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setInferiorExecutable(dlg.symbolFileCopy());
|
||||
rp.setCoreFilePath(dlg.coreFileCopy());
|
||||
rp.setStartMode(AttachToCore);
|
||||
@@ -360,6 +359,9 @@ void runAttachToCoreDialog()
|
||||
if (!sysRoot.isEmpty())
|
||||
rp.setSysRoot(sysRoot);
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
|
||||
runControl->start();
|
||||
}
|
||||
|
||||
|
@@ -811,14 +811,8 @@ IosRunWorkerFactory::IosRunWorkerFactory()
|
||||
addSupportedRunConfig(Constants::IOS_RUNCONFIG_ID);
|
||||
}
|
||||
|
||||
static void startDebugger(RunControl *runControl, DebuggerRunTool *debugger, IosRunner *iosRunner)
|
||||
static void parametersModifier(RunControl *runControl, DebuggerRunParameters &rp, IosRunner *iosRunner)
|
||||
{
|
||||
if (!iosRunner->isAppRunning()) {
|
||||
debugger->reportFailure(Tr::tr("Application not running."));
|
||||
return;
|
||||
}
|
||||
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
const bool cppDebug = rp.isCppDebugging();
|
||||
const bool qmlDebug = rp.isQmlDebugging();
|
||||
if (cppDebug) {
|
||||
@@ -857,16 +851,13 @@ static void startDebugger(RunControl *runControl, DebuggerRunTool *debugger, Ios
|
||||
|
||||
static RunWorker *createWorker(RunControl *runControl)
|
||||
{
|
||||
DebuggerRunTool *debugger = new DebuggerRunTool(runControl);
|
||||
debugger->setId("IosDebugSupport");
|
||||
|
||||
IosDevice::ConstPtr dev = std::dynamic_pointer_cast<const IosDevice>(runControl->device());
|
||||
const bool isIosDeviceType = runControl->device()->type() == Ios::Constants::IOS_DEVICE_TYPE;
|
||||
const bool isIosDeviceInstance = bool(dev);
|
||||
// type info and device class must match
|
||||
QTC_ASSERT(isIosDeviceInstance == isIosDeviceType,
|
||||
runControl->postMessage(Tr::tr("Internal error."), ErrorMessageFormat); return nullptr);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
// TODO cannot use setupPortsGatherer() from DebuggerRunTool, because that also requests
|
||||
// the "debugChannel", which then results in runControl trying to retrieve ports&URL for that
|
||||
// via IDevice, which doesn't really work with the iOS setup, and also completely changes
|
||||
@@ -886,7 +877,6 @@ static RunWorker *createWorker(RunControl *runControl)
|
||||
runner = deviceCtlRunner = new DeviceCtlRunner(runControl);
|
||||
deviceCtlRunner->setStartStopped(true);
|
||||
}
|
||||
debugger->addStartDependency(runner);
|
||||
|
||||
if (isIosDeviceInstance) {
|
||||
if (dev->handler() == IosDevice::Handler::DeviceCtl) {
|
||||
@@ -914,7 +904,8 @@ static RunWorker *createWorker(RunControl *runControl)
|
||||
rp.setDisplayName(data->applicationName);
|
||||
rp.setContinueAfterAttach(true);
|
||||
|
||||
if (isIosDeviceInstance && dev->handler() == IosDevice::Handler::DeviceCtl) {
|
||||
const bool isDeviceCtl = isIosDeviceInstance && dev->handler() == IosDevice::Handler::DeviceCtl;
|
||||
if (isDeviceCtl) {
|
||||
const auto msgOnlyCppDebuggingSupported = [] {
|
||||
return Tr::tr("Only C++ debugging is supported for devices with iOS 17 and later.");
|
||||
};
|
||||
@@ -929,11 +920,15 @@ static RunWorker *createWorker(RunControl *runControl)
|
||||
runControl->postMessage(msgOnlyCppDebuggingSupported(), LogMessageFormat);
|
||||
}
|
||||
rp.setInferiorExecutable(data->localExecutable);
|
||||
} else {
|
||||
QObject::connect(runner, &RunWorker::started, debugger, [runControl, debugger, iosRunner] {
|
||||
startDebugger(runControl, debugger, iosRunner);
|
||||
});
|
||||
}
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp,
|
||||
[runControl, iosRunner, isDeviceCtl](DebuggerRunParameters &rp) {
|
||||
if (isDeviceCtl)
|
||||
return;
|
||||
parametersModifier(runControl, rp, iosRunner);
|
||||
});
|
||||
debugger->addStartDependency(runner);
|
||||
return debugger;
|
||||
}
|
||||
|
||||
|
@@ -133,19 +133,9 @@ void showAttachToProcessDialog()
|
||||
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
runControl->copyDataFromRunConfiguration(runConfig);
|
||||
runControl->setAttachPid(ProcessHandle(pid));
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
debugger->setId("QnxAttachDebugSupport");
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setupPortsGatherer(runControl);
|
||||
rp.setUseCtrlCStub(true);
|
||||
if (rp.isCppDebugging()) {
|
||||
const auto modifier = [runControl](Process &process) {
|
||||
const int pdebugPort = runControl->debugChannel().port();
|
||||
process.setCommand({QNX_DEBUG_EXECUTABLE, {QString::number(pdebugPort)}});
|
||||
};
|
||||
auto worker = createProcessWorker(runControl, modifier);
|
||||
debugger->addStartDependency(worker);
|
||||
}
|
||||
|
||||
rp.setStartMode(AttachToRemoteServer);
|
||||
rp.setCloseMode(DetachAtClose);
|
||||
@@ -157,6 +147,17 @@ void showAttachToProcessDialog()
|
||||
rp.setSysRoot(qtVersion->qnxTarget());
|
||||
rp.setUseContinueInsteadOfRun(true);
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
|
||||
if (rp.isCppDebugging()) {
|
||||
const auto modifier = [runControl](Process &process) {
|
||||
const int pdebugPort = runControl->debugChannel().port();
|
||||
process.setCommand({QNX_DEBUG_EXECUTABLE, {QString::number(pdebugPort)}});
|
||||
};
|
||||
auto worker = createProcessWorker(runControl, modifier);
|
||||
debugger->addStartDependency(worker);
|
||||
}
|
||||
|
||||
runControl->start();
|
||||
}
|
||||
|
||||
@@ -168,9 +169,6 @@ public:
|
||||
QnxDebugWorkerFactory()
|
||||
{
|
||||
setProducer([](RunControl *runControl) {
|
||||
auto debugger = new DebuggerRunTool(runControl);
|
||||
|
||||
debugger->setId("QnxDebugSupport");
|
||||
runControl->postMessage(Tr::tr("Preparing remote side..."), LogMessageFormat);
|
||||
|
||||
const auto modifier = [runControl](Process &process) {
|
||||
@@ -192,11 +190,8 @@ public:
|
||||
auto slog2InfoRunner = new RecipeRunner(runControl, slog2InfoRecipe(runControl));
|
||||
worker->addStartDependency(slog2InfoRunner);
|
||||
|
||||
debugger->addStartDependency(worker);
|
||||
|
||||
Kit *k = runControl->kit();
|
||||
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setupPortsGatherer(runControl);
|
||||
rp.setStartMode(AttachToRemoteServer);
|
||||
rp.setCloseMode(KillAtClose);
|
||||
@@ -208,6 +203,8 @@ public:
|
||||
rp.modifyDebuggerEnvironment(qtVersion->environment());
|
||||
}
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
debugger->addStartDependency(worker);
|
||||
return debugger;
|
||||
});
|
||||
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
|
@@ -152,22 +152,15 @@ class AppManagerDebugWorkerFactory final : public RunWorkerFactory
|
||||
public:
|
||||
AppManagerDebugWorkerFactory()
|
||||
{
|
||||
setProducer([](RunControl *runControl) {
|
||||
DebuggerRunTool *debugger = new DebuggerRunTool(runControl);
|
||||
debugger->setId("ApplicationManagerPlugin.Debug.Support");
|
||||
|
||||
auto debuggee = createInferiorRunner(runControl, QmlDebuggerServices);
|
||||
debugger->addStartDependency(debuggee);
|
||||
debugger->addStopDependency(debuggee);
|
||||
debuggee->addStopDependency(debugger);
|
||||
|
||||
setProducer([](RunControl *runControl) -> RunWorker * {
|
||||
BuildConfiguration *bc = runControl->buildConfiguration();
|
||||
|
||||
const Internal::TargetInformation targetInformation(bc);
|
||||
if (!targetInformation.isValid()) {
|
||||
// TODO: reportFailure won't work from RunWorker's c'tor.
|
||||
debugger->reportFailure(Tr::tr("Cannot debug: Invalid target information."));
|
||||
return debugger;
|
||||
runControl->postMessage(Tr::tr("Cannot debug: Invalid target information."),
|
||||
ErrorMessageFormat);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FilePath symbolFile;
|
||||
@@ -184,16 +177,20 @@ public:
|
||||
}).targetFilePath;
|
||||
} else {
|
||||
// TODO: reportFailure won't work from RunWorker's c'tor.
|
||||
debugger->reportFailure(Tr::tr("Cannot debug: Only QML and native applications are supported."));
|
||||
return debugger;
|
||||
runControl->postMessage(Tr::tr("Cannot debug: Only QML and native applications are supported."),
|
||||
ErrorMessageFormat);
|
||||
return nullptr;
|
||||
}
|
||||
if (symbolFile.isEmpty()) {
|
||||
// TODO: reportFailure won't work from RunWorker's c'tor.
|
||||
debugger->reportFailure(Tr::tr("Cannot debug: Local executable is not set."));
|
||||
return debugger;
|
||||
runControl->postMessage(Tr::tr("Cannot debug: Local executable is not set."),
|
||||
ErrorMessageFormat);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Debugger::DebuggerRunParameters &rp = debugger->runParameters();
|
||||
auto debuggee = createInferiorRunner(runControl, QmlDebuggerServices);
|
||||
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setupPortsGatherer(runControl);
|
||||
rp.setStartMode(Debugger::AttachToRemoteServer);
|
||||
rp.setCloseMode(Debugger::KillAndExitMonitorAtClose);
|
||||
@@ -217,6 +214,11 @@ public:
|
||||
rp.setSysRoot(sysroot);
|
||||
}
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
debugger->addStartDependency(debuggee);
|
||||
debugger->addStopDependency(debuggee);
|
||||
debuggee->addStopDependency(debugger);
|
||||
|
||||
return debugger;
|
||||
});
|
||||
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
|
@@ -46,13 +46,11 @@ class RemoteLinuxDebugWorkerFactory final : public ProjectExplorer::RunWorkerFac
|
||||
public:
|
||||
RemoteLinuxDebugWorkerFactory()
|
||||
{
|
||||
setProducer([](RunControl *rc) {
|
||||
rc->requestDebugChannel();
|
||||
setProducer([](RunControl *runControl) {
|
||||
runControl->requestDebugChannel();
|
||||
|
||||
auto debugger = new DebuggerRunTool(rc);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
debugger->setId("RemoteLinuxDebugWorker");
|
||||
rp.setupPortsGatherer(rc);
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setupPortsGatherer(runControl);
|
||||
rp.setUseTerminal(false);
|
||||
rp.setAddQmlServerInferiorCmdArgIfNeeded(true);
|
||||
|
||||
@@ -60,11 +58,11 @@ public:
|
||||
rp.setCloseMode(KillAndExitMonitorAtClose);
|
||||
rp.setUseExtendedRemote(true);
|
||||
|
||||
if (rc->device()->osType() == Utils::OsTypeMac)
|
||||
if (runControl->device()->osType() == Utils::OsTypeMac)
|
||||
rp.setLldbPlatform("remote-macosx");
|
||||
else
|
||||
rp.setLldbPlatform("remote-linux");
|
||||
return debugger;
|
||||
return createDebuggerWorker(runControl, rp);
|
||||
});
|
||||
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
addSupportedDeviceType(Constants::GenericLinuxOsType);
|
||||
|
@@ -1044,16 +1044,15 @@ static ExecutableItem debuggerRecipe(const Storage<ProcessHandle> pidStorage, Ru
|
||||
|
||||
return Sync([runControl, pidStorage] {
|
||||
// TODO: Make a part of this recipe
|
||||
auto debugger = new Debugger::DebuggerRunTool(runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl);
|
||||
rp.setStartMode(Debugger::AttachToRemoteServer);
|
||||
rp.setDisplayName(QString("VGdb %1").arg(pidStorage->pid()));
|
||||
rp.setRemoteChannelPipe(QString("vgdb --pid=%1").arg(pidStorage->pid()));
|
||||
rp.setUseContinueInsteadOfRun(true);
|
||||
rp.addExpectedSignal("SIGTRAP");
|
||||
|
||||
auto debugger = createDebuggerWorker(runControl, rp);
|
||||
QObject::connect(runControl, &RunControl::stopped, debugger, &RunControl::deleteLater);
|
||||
|
||||
debugger->initiateStart();
|
||||
});
|
||||
}
|
||||
@@ -1575,8 +1574,7 @@ void HeobData::processFinished()
|
||||
if (m_data[0] >= HEOB_PID_ATTACH) {
|
||||
m_runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
m_runControl->setKit(m_kit);
|
||||
auto debugger = new DebuggerRunTool(m_runControl);
|
||||
DebuggerRunParameters &rp = debugger->runParameters();
|
||||
DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(m_runControl);
|
||||
rp.setAttachPid(ProcessHandle(m_data[1]));
|
||||
rp.setDisplayName(Tr::tr("Process %1").arg(m_data[1]));
|
||||
rp.setStartMode(AttachToLocalProcess);
|
||||
@@ -1586,6 +1584,8 @@ void HeobData::processFinished()
|
||||
|
||||
connect(m_runControl, &RunControl::started, this, &HeobData::debugStarted);
|
||||
connect(m_runControl, &RunControl::stopped, this, &HeobData::debugStopped);
|
||||
auto debugger = createDebuggerWorker(m_runControl, rp);
|
||||
Q_UNUSED(debugger)
|
||||
m_runControl->start();
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user