Debugger: Also move is{Cpp,Qml}Debugging() to DebuggerRunParameters

Change-Id: Ic318c5813316da66097c8438ec26602491b4f863
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2025-01-10 17:27:50 +01:00
parent 9376ac09d4
commit 05350fc830
8 changed files with 33 additions and 43 deletions

View File

@@ -105,7 +105,7 @@ public:
rp.setUseTargetAsync(true); rp.setUseTargetAsync(true);
} }
if (isCppDebugging()) { if (rp.isCppDebugging()) {
qCDebug(androidDebugSupportLog) << "C++ debugging enabled"; qCDebug(androidDebugSupportLog) << "C++ debugging enabled";
const ProjectNode *node = target->project()->findNodeForBuildKey(runControl->buildKey()); const ProjectNode *node = target->project()->findNodeForBuildKey(runControl->buildKey());
FilePaths solibSearchPath = getSoLibSearchPath(node); FilePaths solibSearchPath = getSoLibSearchPath(node);
@@ -147,7 +147,7 @@ public:
qCDebug(androidDebugSupportLog).noquote() << "Sysroot: " << sysRoot.toUserOutput(); qCDebug(androidDebugSupportLog).noquote() << "Sysroot: " << sysRoot.toUserOutput();
} }
} }
if (isQmlDebugging()) { if (rp.isQmlDebugging()) {
qCDebug(androidDebugSupportLog) << "QML debugging enabled. QML server: " qCDebug(androidDebugSupportLog) << "QML debugging enabled. QML server: "
<< runControl->qmlChannel().toDisplayString(); << runControl->qmlChannel().toDisplayString();
//TODO: Not sure if these are the right paths. //TODO: Not sure if these are the right paths.
@@ -170,7 +170,7 @@ void AndroidDebugSupport::start()
{ {
DebuggerRunParameters &rp = runParameters(); DebuggerRunParameters &rp = runParameters();
rp.setAttachPid(m_runner->pid()); rp.setAttachPid(m_runner->pid());
if (isCppDebugging()) { if (rp.isCppDebugging()) {
if (cppEngineType() == LldbEngineType) { if (cppEngineType() == LldbEngineType) {
QString deviceSerialNumber = Internal::deviceSerialNumber(runControl()->target()); QString deviceSerialNumber = Internal::deviceSerialNumber(runControl()->target());
const int colonPos = deviceSerialNumber.indexOf(QLatin1Char(':')); const int colonPos = deviceSerialNumber.indexOf(QLatin1Char(':'));
@@ -187,7 +187,7 @@ void AndroidDebugSupport::start()
rp.setRemoteChannel(debugServer); rp.setRemoteChannel(debugServer);
} }
} }
if (isQmlDebugging()) if (rp.isQmlDebugging())
rp.setQmlServer(runControl()->qmlChannel()); rp.setQmlServer(runControl()->qmlChannel());
DebuggerRunTool::start(); DebuggerRunTool::start();
} }

View File

@@ -148,7 +148,7 @@ DebuggerRunParameters DebuggerRunParameters::fromRunControl(ProjectExplorer::Run
if (auto aspect = runControl->aspectData<DebuggerRunConfigurationAspect>()) { if (auto aspect = runControl->aspectData<DebuggerRunConfigurationAspect>()) {
if (!aspect->useCppDebugger) if (!aspect->useCppDebugger)
params.cppEngineType = NoEngineType; params.cppEngineType = NoEngineType;
params.isQmlDebugging = aspect->useQmlDebugger; params.m_isQmlDebugging = aspect->useQmlDebugger;
params.isPythonDebugging = aspect->usePythonDebugger; params.isPythonDebugging = aspect->usePythonDebugger;
params.multiProcess = aspect->useMultiProcess; params.multiProcess = aspect->useMultiProcess;
params.additionalStartupCommands = aspect->overrideStartup; params.additionalStartupCommands = aspect->overrideStartup;
@@ -226,7 +226,7 @@ Result DebuggerRunParameters::fixupParameters(ProjectExplorer::RunControl *runCo
if (!validationErrors.isEmpty()) if (!validationErrors.isEmpty())
return Result::Error(validationErrors.join('\n')); return Result::Error(validationErrors.join('\n'));
if (isQmlDebugging) { if (m_isQmlDebugging) {
const auto device = runControl->device(); const auto device = runControl->device();
if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
if (m_qmlServer.port() <= 0) { if (m_qmlServer.port() <= 0) {
@@ -253,7 +253,7 @@ Result DebuggerRunParameters::fixupParameters(ProjectExplorer::RunControl *runCo
} }
} }
if (isQmlDebugging) { if (m_isQmlDebugging) {
QmlDebugServicesPreset service; QmlDebugServicesPreset service;
if (isCppDebugging()) { if (isCppDebugging()) {
if (nativeMixedEnabled) { if (nativeMixedEnabled) {
@@ -310,7 +310,7 @@ void DebuggerRunParameters::setStartMode(DebuggerStartMode startMode)
return; return;
cppEngineType = NoEngineType; cppEngineType = NoEngineType;
isQmlDebugging = true; m_isQmlDebugging = true;
m_closeMode = KillAtClose; m_closeMode = KillAtClose;
// FIXME: This is horribly wrong. // FIXME: This is horribly wrong.
@@ -346,7 +346,7 @@ bool DebuggerRunParameters::isCppDebugging() const
bool DebuggerRunParameters::isNativeMixedDebugging() const bool DebuggerRunParameters::isNativeMixedDebugging() const
{ {
return nativeMixedEnabled && isCppDebugging() && isQmlDebugging; return nativeMixedEnabled && isCppDebugging() && m_isQmlDebugging;
} }
namespace Internal { namespace Internal {
@@ -2899,7 +2899,7 @@ QString DebuggerEngine::formatStartParameters() const
str << "Languages: "; str << "Languages: ";
if (sp.isCppDebugging()) if (sp.isCppDebugging())
str << "c++ "; str << "c++ ";
if (sp.isQmlDebugging) if (sp.isQmlDebugging())
str << "qml"; str << "qml";
str << '\n'; str << '\n';
if (!sp.inferior().command.isEmpty()) { if (!sp.inferior().command.isEmpty()) {

View File

@@ -109,6 +109,9 @@ public:
void setQmlServer(const QUrl &qmlServer) { m_qmlServer = qmlServer; } void setQmlServer(const QUrl &qmlServer) { m_qmlServer = qmlServer; }
QUrl qmlServer() const { return m_qmlServer; } QUrl qmlServer() const { return m_qmlServer; }
bool isQmlDebugging() const { return m_isQmlDebugging; }
void setQmlDebugging(bool on) { m_isQmlDebugging = on; }
void setRemoteChannel(const QString &channel) { m_remoteChannel = channel; } void setRemoteChannel(const QString &channel) { m_remoteChannel = channel; }
void setRemoteChannel(const QUrl &url) { void setRemoteChannel(const QUrl &url) {
m_remoteChannel = QString("%1:%2").arg(url.host()).arg(url.port()); m_remoteChannel = QString("%1:%2").arg(url.host()).arg(url.port());
@@ -176,7 +179,6 @@ public:
DebuggerEngineType cppEngineType = NoEngineType; DebuggerEngineType cppEngineType = NoEngineType;
QString version; QString version;
bool isQmlDebugging = false;
bool isPythonDebugging = false; bool isPythonDebugging = false;
bool breakOnMain = false; bool breakOnMain = false;
bool multiProcess = false; // Whether to set detach-on-fork off. bool multiProcess = false; // Whether to set detach-on-fork off.
@@ -244,6 +246,7 @@ private:
Utils::FilePaths m_solibSearchPath; Utils::FilePaths m_solibSearchPath;
QUrl m_qmlServer; // Used by Qml debugging. QUrl m_qmlServer; // Used by Qml debugging.
bool m_isQmlDebugging = false;
QString m_remoteChannel; // Used by general remote debugging. QString m_remoteChannel; // Used by general remote debugging.
bool m_useExtendedRemote = false; // Whether to use GDB's target extended-remote or not. bool m_useExtendedRemote = false; // Whether to use GDB's target extended-remote or not.

View File

@@ -281,7 +281,7 @@ void DebuggerRunTool::continueAfterTerminalStart()
if (runControl()->usesQmlChannel()) { if (runControl()->usesQmlChannel()) {
m_runParameters.setQmlServer(runControl()->qmlChannel()); m_runParameters.setQmlServer(runControl()->qmlChannel());
if (d->addQmlServerInferiorCommandLineArgumentIfNeeded if (d->addQmlServerInferiorCommandLineArgumentIfNeeded
&& m_runParameters.isQmlDebugging && m_runParameters.isQmlDebugging()
&& m_runParameters.isCppDebugging()) { && m_runParameters.isCppDebugging()) {
int qmlServerPort = m_runParameters.qmlServer().port(); int qmlServerPort = m_runParameters.qmlServer().port();
@@ -373,7 +373,7 @@ void DebuggerRunTool::continueAfterDebugServerStart()
m_engines << createUvscEngine(); m_engines << createUvscEngine();
break; break;
default: default:
if (!m_runParameters.isQmlDebugging) { if (!m_runParameters.isQmlDebugging()) {
reportFailure(noEngineMessage() + '\n' + reportFailure(noEngineMessage() + '\n' +
Tr::tr("Specify Debugger settings in Projects > Run.")); Tr::tr("Specify Debugger settings in Projects > Run."));
return; return;
@@ -386,7 +386,7 @@ void DebuggerRunTool::continueAfterDebugServerStart()
if (m_runParameters.isPythonDebugging) if (m_runParameters.isPythonDebugging)
m_engines << createPdbEngine(); m_engines << createPdbEngine();
if (m_runParameters.isQmlDebugging) if (m_runParameters.isQmlDebugging())
m_engines << createQmlEngine(); m_engines << createQmlEngine();
} }
@@ -558,22 +558,12 @@ void DebuggerRunTool::handleEngineFinished(DebuggerEngine *engine)
} }
} }
bool DebuggerRunTool::isCppDebugging() const
{
return m_runParameters.isCppDebugging();
}
bool DebuggerRunTool::isQmlDebugging() const
{
return m_runParameters.isQmlDebugging;
}
void DebuggerRunTool::setupPortsGatherer() void DebuggerRunTool::setupPortsGatherer()
{ {
if (isCppDebugging()) if (m_runParameters.isCppDebugging())
runControl()->requestDebugChannel(); runControl()->requestDebugChannel();
if (isQmlDebugging()) if (m_runParameters.isQmlDebugging())
runControl()->requestQmlChannel(); runControl()->requestQmlChannel();
} }

View File

@@ -47,14 +47,9 @@ public:
void kickoffTerminalProcess(); void kickoffTerminalProcess();
void interruptTerminal(); void interruptTerminal();
DebuggerRunParameters &runParameters() { return m_runParameters; }
void addQmlServerInferiorCommandLineArgumentIfNeeded(); void addQmlServerInferiorCommandLineArgumentIfNeeded();
void setupPortsGatherer(); void setupPortsGatherer();
bool isCppDebugging() const;
bool isQmlDebugging() const;
void modifyDebuggerEnvironment(const Utils::EnvironmentItems &item); void modifyDebuggerEnvironment(const Utils::EnvironmentItems &item);
void setDeviceUuid(const QString &uuid); void setDeviceUuid(const QString &uuid);
@@ -63,6 +58,8 @@ public:
DebuggerEngineType cppEngineType() const; DebuggerEngineType cppEngineType() const;
DebuggerRunParameters &runParameters() { return m_runParameters; }
private: private:
void showMessage(const QString &msg, int channel = LogDebug, int timeout = -1); void showMessage(const QString &msg, int channel = LogDebug, int timeout = -1);

View File

@@ -907,21 +907,21 @@ IosDebugSupport::IosDebugSupport(RunControl *runControl)
setId("IosDebugSupport"); setId("IosDebugSupport");
IosDevice::ConstPtr dev = std::dynamic_pointer_cast<const IosDevice>(device()); IosDevice::ConstPtr dev = std::dynamic_pointer_cast<const IosDevice>(device());
DebuggerRunParameters &rp = runParameters();
if (dev->type() == Ios::Constants::IOS_SIMULATOR_TYPE if (dev->type() == Ios::Constants::IOS_SIMULATOR_TYPE
|| dev->handler() == IosDevice::Handler::IosTool) { || dev->handler() == IosDevice::Handler::IosTool) {
m_iosRunner = new IosRunner(runControl); m_iosRunner = new IosRunner(runControl);
m_iosRunner->setCppDebugging(isCppDebugging()); m_iosRunner->setCppDebugging(rp.isCppDebugging());
m_iosRunner->setQmlDebugging(isQmlDebugging() ? QmlDebuggerServices : NoQmlDebugServices); m_iosRunner->setQmlDebugging(rp.isQmlDebugging() ? QmlDebuggerServices : NoQmlDebugServices);
addStartDependency(m_iosRunner); addStartDependency(m_iosRunner);
} else { } else {
QTC_CHECK(isCppDebugging()); QTC_CHECK(rp.isCppDebugging());
m_deviceCtlRunner = new DeviceCtlRunner(runControl); m_deviceCtlRunner = new DeviceCtlRunner(runControl);
m_deviceCtlRunner->setStartStopped(true); m_deviceCtlRunner->setStartStopped(true);
addStartDependency(m_deviceCtlRunner); addStartDependency(m_deviceCtlRunner);
} }
DebuggerRunParameters &rp = runParameters();
if (device()->type() == Ios::Constants::IOS_DEVICE_TYPE) { if (device()->type() == Ios::Constants::IOS_DEVICE_TYPE) {
if (dev->handler() == IosDevice::Handler::DeviceCtl) { if (dev->handler() == IosDevice::Handler::DeviceCtl) {
QTC_CHECK(IosDeviceManager::isDeviceCtlDebugSupported()); QTC_CHECK(IosDeviceManager::isDeviceCtlDebugSupported());
@@ -957,12 +957,12 @@ void IosDebugSupport::start()
const auto msgOnlyCppDebuggingSupported = [] { const auto msgOnlyCppDebuggingSupported = [] {
return Tr::tr("Only C++ debugging is supported for devices with iOS 17 and later."); return Tr::tr("Only C++ debugging is supported for devices with iOS 17 and later.");
}; };
if (!isCppDebugging()) { if (!rp.isCppDebugging()) {
reportFailure(msgOnlyCppDebuggingSupported()); reportFailure(msgOnlyCppDebuggingSupported());
return; return;
} }
if (isQmlDebugging()) { if (rp.isQmlDebugging()) {
runParameters().isQmlDebugging = false; rp.setQmlDebugging(false);
appendMessage(msgOnlyCppDebuggingSupported(), OutputFormat::LogMessageFormat, true); appendMessage(msgOnlyCppDebuggingSupported(), OutputFormat::LogMessageFormat, true);
} }
rp.setAttachPid(m_deviceCtlRunner->processIdentifier()); rp.setAttachPid(m_deviceCtlRunner->processIdentifier());
@@ -980,8 +980,8 @@ void IosDebugSupport::start()
const Port qmlServerPort = m_iosRunner->qmlServerPort(); const Port qmlServerPort = m_iosRunner->qmlServerPort();
rp.setAttachPid(m_iosRunner->pid()); rp.setAttachPid(m_iosRunner->pid());
const bool cppDebug = isCppDebugging(); const bool cppDebug = rp.isCppDebugging();
const bool qmlDebug = isQmlDebugging(); const bool qmlDebug = rp.isQmlDebugging();
if (cppDebug) { if (cppDebug) {
rp.setInferiorExecutable(data->localExecutable); rp.setInferiorExecutable(data->localExecutable);
rp.setRemoteChannel("connect://localhost:" + gdbServerPort.toString()); rp.setRemoteChannel("connect://localhost:" + gdbServerPort.toString());

View File

@@ -137,7 +137,7 @@ void showAttachToProcessDialog()
debugger->setId("QnxAttachDebugSupport"); debugger->setId("QnxAttachDebugSupport");
debugger->setupPortsGatherer(); debugger->setupPortsGatherer();
rp.setUseCtrlCStub(true); rp.setUseCtrlCStub(true);
if (debugger->isCppDebugging()) { if (rp.isCppDebugging()) {
auto pdebugRunner = new ProcessRunner(runControl); auto pdebugRunner = new ProcessRunner(runControl);
pdebugRunner->setId("PDebugRunner"); pdebugRunner->setId("PDebugRunner");
pdebugRunner->setStartModifier([pdebugRunner, runControl] { pdebugRunner->setStartModifier([pdebugRunner, runControl] {

View File

@@ -156,10 +156,10 @@ private:
rp.setStartMode(Debugger::AttachToRemoteServer); rp.setStartMode(Debugger::AttachToRemoteServer);
rp.setCloseMode(Debugger::KillAndExitMonitorAtClose); rp.setCloseMode(Debugger::KillAndExitMonitorAtClose);
if (isQmlDebugging()) if (rp.isQmlDebugging())
rp.setQmlServer(runControl()->qmlChannel()); rp.setQmlServer(runControl()->qmlChannel());
if (isCppDebugging()) { if (rp.isCppDebugging()) {
rp.setUseExtendedRemote(false); rp.setUseExtendedRemote(false);
rp.setUseContinueInsteadOfRun(true); rp.setUseContinueInsteadOfRun(true);
rp.setContinueAfterAttach(true); rp.setContinueAfterAttach(true);