From fe8cead2d004e5a571bd8a65f91757db2c34a12c Mon Sep 17 00:00:00 2001 From: Kai Koehne <kai.koehne@nokia.com> Date: Wed, 1 Feb 2012 09:03:05 +0100 Subject: [PATCH] Debugger: Make language to debug (QML/CPP) explicit Make the choice of language part of the DebuggerStartParameters, instead of deriving it indirectly from the current project. This prevents e.g. the QmlCppEngine to be used when loading core files. Change-Id: I9d1c9ab318ba789abe3a6ea0478ebda71857e793 Reviewed-by: hjk <qthjk@ovi.com> --- src/plugins/debugger/debuggerconstants.h | 1 - src/plugins/debugger/debuggerplugin.cpp | 10 ++- src/plugins/debugger/debuggerrunner.cpp | 74 ++++++++++++------- .../debugger/debuggerstartparameters.h | 3 + src/plugins/debugger/qml/qmlengine.cpp | 12 +-- .../qt-s60/s60devicedebugruncontrol.cpp | 3 + .../remotelinux/remotelinuxdebugsupport.cpp | 2 + 7 files changed, 72 insertions(+), 33 deletions(-) diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index 9cdd0526437..b605e747c4a 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -130,7 +130,6 @@ enum DebuggerStartMode AttachToRemoteServer, // Attach to a running gdbserver AttachToRemoteProcess, // Attach to a running remote process StartRemoteProcess, // Start and attach to a remote process - AttachToQmlPort, // Attach to QML debugging port StartRemoteGdb, // Start gdb itself remotely StartRemoteEngine // Start ipc guest engine on other machine }; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index d2fa8b764ea..094c0181418 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1844,7 +1844,7 @@ void DebuggerPluginPrivate::attachToQmlPort() sp.qmlServerPort = dlg.port(); sp.sysroot = dlg.sysroot(); - sp.startMode = AttachToQmlPort; + sp.startMode = AttachToRemoteServer; // // get files from all the projects in the session @@ -2713,6 +2713,14 @@ static QString formatStartParameters(DebuggerStartParameters &sp) QTextStream str(&rc); str << "Start parameters: '" << sp.displayName << "' mode: " << sp.startMode << "\nABI: " << sp.toolChainAbi.toString() << '\n'; + str << "Languages: "; + if (sp.languages == AnyLanguage) + str << "any"; + if (sp.languages & CppLanguage) + str << "c++ "; + if (sp.languages & QmlLanguage) + str << "qml"; + str << '\n'; if (!sp.executable.isEmpty()) { str << "Executable: " << QDir::toNativeSeparators(sp.executable) << ' ' << sp.processArgs; diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 3f1bbb7ee1a..e87a9268e1e 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -365,7 +365,8 @@ RunConfiguration *DebuggerRunControl::runConfiguration() const // //////////////////////////////////////////////////////////////////////// -static QList<DebuggerEngineType> enginesForToolChain(const Abi &toolChain) +static QList<DebuggerEngineType> enginesForToolChain(const Abi &toolChain, + DebuggerLanguages languages) { QList<DebuggerEngineType> result; switch (toolChain.binaryFormat()) { @@ -373,6 +374,8 @@ static QList<DebuggerEngineType> enginesForToolChain(const Abi &toolChain) case Abi::MachOFormat: result.push_back(LldbEngineType); result.push_back(GdbEngineType); + if (languages & QmlLanguage) + result.push_back(QmlEngineType); break; case Abi::PEFormat: if (toolChain.osFlavor() == Abi::WindowsMSysFlavor) { @@ -382,6 +385,8 @@ static QList<DebuggerEngineType> enginesForToolChain(const Abi &toolChain) result.push_back(CdbEngineType); result.push_back(GdbEngineType); } + if (languages & QmlLanguage) + result.push_back(QmlEngineType); break; case Abi::RuntimeQmlFormat: result.push_back(QmlEngineType); @@ -435,9 +440,22 @@ static QList<DebuggerEngineType> enginesForExecutable(const QString &executable) // Debugger type for mode. static QList<DebuggerEngineType> enginesForMode(DebuggerStartMode startMode, + DebuggerLanguages languages, bool hardConstraintsOnly) { QList<DebuggerEngineType> result; + + if (languages == QmlLanguage) { + QTC_ASSERT(startMode == StartInternal + || startMode == AttachToRemoteServer, + qDebug() << "qml debugging not supported for mode" + << startMode); + + // Qml language only + result.push_back(QmlEngineType); + return result; + } + switch (startMode) { case NoStartMode: break; @@ -449,6 +467,9 @@ static QList<DebuggerEngineType> enginesForMode(DebuggerStartMode startMode, result.push_back(CdbEngineType); // Preferably Windows debugger for attaching locally. #endif result.push_back(GdbEngineType); + + if (languages & QmlLanguage) + result.push_back(QmlEngineType); } break; case AttachCore: @@ -460,6 +481,8 @@ static QList<DebuggerEngineType> enginesForMode(DebuggerStartMode startMode, case StartRemoteProcess: case StartRemoteGdb: result.push_back(GdbEngineType); + if (languages & QmlLanguage) + result.push_back(QmlEngineType); break; case AttachToRemoteProcess: case AttachToRemoteServer: @@ -468,6 +491,9 @@ static QList<DebuggerEngineType> enginesForMode(DebuggerStartMode startMode, result.push_back(CdbEngineType); #endif result.push_back(GdbEngineType); + + if (languages & QmlLanguage) + result.push_back(QmlEngineType); } break; case AttachCrashedExternal: @@ -478,9 +504,6 @@ static QList<DebuggerEngineType> enginesForMode(DebuggerStartMode startMode, // For now thats the only supported IPC engine. result.push_back(LldbEngineType); break; - case AttachToQmlPort: - result.push_back(QmlEngineType); // Only QML can do this - break; } return result; } @@ -494,14 +517,14 @@ static QList<DebuggerEngineType> engineTypes(const DebuggerStartParameters &sp) if (!result.isEmpty()) return result; - result = enginesForMode(sp.startMode, true); + result = enginesForMode(sp.startMode, sp.languages, true); if (!result.isEmpty()) return result; // 'hard constraints' done (with the exception of QML ABI checked here), // further try to restrict available engines. if (sp.toolChainAbi.isValid()) { - result = enginesForToolChain(sp.toolChainAbi); + result = enginesForToolChain(sp.toolChainAbi, sp.languages); if (!result.isEmpty()) return result; } @@ -519,7 +542,7 @@ static QList<DebuggerEngineType> engineTypes(const DebuggerStartParameters &sp) if (!result.isEmpty()) return result; - result = enginesForMode(sp.startMode, false); + result = enginesForMode(sp.startMode, sp.languages, false); return result; } @@ -577,27 +600,19 @@ static inline bool canUseEngine(DebuggerEngineType et, DEBUGGER_EXPORT ConfigurationCheck checkDebugConfiguration(const DebuggerStartParameters &sp) { ConfigurationCheck result; - const unsigned activeLangs = debuggerCore()->activeLanguages(); - const bool qmlLanguage = activeLangs & QmlLanguage; - const bool cppLanguage = activeLangs & CppLanguage; if (debug) qDebug().nospace() << "checkDebugConfiguration " << sp.toolChainAbi.toString() << " Start mode=" << sp.startMode << " Executable=" << sp.executable << " Debugger command=" << sp.debuggerCommand; // Get all applicable types. - QList<DebuggerEngineType> requiredTypes; - if (qmlLanguage && !cppLanguage) { - requiredTypes.push_back(QmlEngineType); - } else { - requiredTypes = engineTypes(sp); - } + QList<DebuggerEngineType> requiredTypes = engineTypes(sp); if (requiredTypes.isEmpty()) { result.errorMessage = QLatin1String("Internal error: Unable to determine debugger engine type for this configuration"); return result; } if (debug) qDebug() << " Required: " << engineTypeNames(requiredTypes); - // Filter out disables types, command line + current settings. + // Filter out disabled types, command line + current settings. unsigned cmdLineEnabledEngines = debuggerCore()->enabledEngines(); #ifdef WITH_LLDB if (!Core::ICore::settings()->value(QLatin1String("LLDB/enabled")).toBool()) @@ -605,6 +620,7 @@ DEBUGGER_EXPORT ConfigurationCheck checkDebugConfiguration(const DebuggerStartPa #else cmdLineEnabledEngines &= ~LldbEngineType; #endif + DebuggerEngineType usableType = NoEngineType; QList<DebuggerEngineType> unavailableTypes; foreach (DebuggerEngineType et, requiredTypes) { @@ -644,13 +660,17 @@ DEBUGGER_EXPORT ConfigurationCheck checkDebugConfiguration(const DebuggerStartPa // Anything left: Happy. result.errorMessage.clear(); result.errorDetails.clear(); - if (qmlLanguage && cppLanguage - && usableType != QmlEngineType) { - result.masterSlaveEngineTypes.first = QmlCppEngineType; - result.masterSlaveEngineTypes.second = usableType; - } else { - result.masterSlaveEngineTypes.first = usableType; - } + + + // Could we actually use a combined qml/cpp-engine? + if (usableType != QmlEngineType + && requiredTypes.contains(QmlEngineType)) { + result.masterSlaveEngineTypes.first = QmlCppEngineType; + result.masterSlaveEngineTypes.second = usableType; + } else { + result.masterSlaveEngineTypes.first = usableType; + } + if (debug) qDebug() << engineTypeName(result.masterSlaveEngineTypes.first) << engineTypeName(result.masterSlaveEngineTypes.second); return result; @@ -757,9 +777,13 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu } } - if (debuggerCore()->isActiveDebugLanguage(QmlLanguage)) { + if (runConfiguration->useCppDebugger()) + sp.languages |= CppLanguage; + + if (runConfiguration->useQmlDebugger()) { sp.qmlServerAddress = _("127.0.0.1"); sp.qmlServerPort = runConfiguration->qmlDebugServerPort(); + sp.languages |= QmlLanguage; // Makes sure that all bindings go through the JavaScript engine, so that // breakpoints are actually hit! diff --git a/src/plugins/debugger/debuggerstartparameters.h b/src/plugins/debugger/debuggerstartparameters.h index 668458d2654..2b5b25332a7 100644 --- a/src/plugins/debugger/debuggerstartparameters.h +++ b/src/plugins/debugger/debuggerstartparameters.h @@ -61,6 +61,7 @@ public: attachPID(-1), useTerminal(false), breakOnMain(false), + languages(AnyLanguage), qmlServerAddress(QLatin1String("127.0.0.1")), qmlServerPort(ProjectExplorer::Constants::QML_DEFAULT_DEBUG_SERVER_PORT), useServerStartScript(false), @@ -87,6 +88,7 @@ public: qint64 attachPID; bool useTerminal; bool breakOnMain; + DebuggerLanguages languages; // Used by AttachCrashedExternal. QString crashParameter; @@ -98,6 +100,7 @@ public: QString projectBuildDirectory; QStringList projectSourceFiles; + QString qtInstallPath; // Used by remote debugging. QString remoteChannel; diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 7183dc1e2c6..85c6bfc5836 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -373,12 +373,12 @@ void QmlEngine::runEngine() { QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); - if (!isSlaveEngine() && startParameters().startMode != AttachToRemoteServer - && startParameters().startMode != AttachToQmlPort) - startApplicationLauncher(); - - if (startParameters().startMode == AttachToQmlPort) - beginConnection(); + if (!isSlaveEngine()) { + if (startParameters().startMode != AttachToRemoteServer) + startApplicationLauncher(); + else + beginConnection(); + } } void QmlEngine::startApplicationLauncher() diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp index eea93643790..8097234fb63 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp @@ -100,11 +100,14 @@ static Debugger::DebuggerStartParameters s60DebuggerStartParams(const S60DeviceR sp.qmlServerAddress = activeDeployConf->deviceAddress(); sp.qmlServerPort = rc->qmlDebugServerPort(); if (rc->useQmlDebugger()) { + sp.languages |= Debugger::QmlLanguage; QString qmlArgs = rc->qmlCommandLineArguments(); if (sp.processArgs.length()) sp.processArgs.prepend(QLatin1Char(' ')); sp.processArgs.prepend(qmlArgs); } + if (rc->useCppDebugger()) + sp.languages |= Debugger::CppLanguage; sp.communicationChannel = activeDeployConf->communicationChannel() == S60DeployConfiguration::CommunicationCodaTcpConnection? Debugger::DebuggerStartParameters::CommunicationChannelTcpIp: diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp index 5e149fb762c..dddc6bd71de 100644 --- a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp +++ b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp @@ -97,10 +97,12 @@ DebuggerStartParameters AbstractRemoteLinuxDebugSupport::startParameters(const R DebuggerStartParameters params; const LinuxDeviceConfiguration::ConstPtr &devConf = runConfig->deviceConfig(); if (runConfig->useQmlDebugger()) { + params.languages |= QmlLanguage; params.qmlServerAddress = runConfig->deviceConfig()->sshParameters().host; params.qmlServerPort = -1; } if (runConfig->useCppDebugger()) { + params.languages |= CppLanguage; params.processArgs = runConfig->arguments(); if (runConfig->activeQt4BuildConfiguration()->qtVersion()) params.sysroot = runConfig->activeQt4BuildConfiguration()->qtVersion()->systemRoot(); -- GitLab