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>
This commit is contained in:
Kai Koehne
2012-02-01 09:03:05 +01:00
committed by hjk
parent e46a5579d3
commit fe8cead2d0
7 changed files with 72 additions and 33 deletions

View File

@@ -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
};

View File

@@ -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;

View File

@@ -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) {
// 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!

View File

@@ -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;

View File

@@ -373,13 +373,13 @@ void QmlEngine::runEngine()
{
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
if (!isSlaveEngine() && startParameters().startMode != AttachToRemoteServer
&& startParameters().startMode != AttachToQmlPort)
if (!isSlaveEngine()) {
if (startParameters().startMode != AttachToRemoteServer)
startApplicationLauncher();
if (startParameters().startMode == AttachToQmlPort)
else
beginConnection();
}
}
void QmlEngine::startApplicationLauncher()
{

View File

@@ -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:

View File

@@ -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();