forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.0'
Change-Id: I3f28f1f53cf2b2228928fbd7accf25d87bb40243
This commit is contained in:
@@ -307,16 +307,10 @@ public:
|
||||
|
||||
// Result.
|
||||
DebuggerRunParameters m_rp;
|
||||
|
||||
// Scratch data.
|
||||
const Kit *m_kit = 0;
|
||||
const RunConfiguration *m_runConfig = 0;
|
||||
DebuggerRunConfigurationAspect *m_debuggerAspect = 0;
|
||||
Target *m_target = 0;
|
||||
Project *m_project = 0;
|
||||
|
||||
QStringList m_errors;
|
||||
DebuggerRunControl *m_runControl = 0;
|
||||
|
||||
const RunConfiguration *m_runConfig = 0;
|
||||
};
|
||||
|
||||
void DebuggerRunControlCreator::initialize(const DebuggerStartParameters &sp)
|
||||
@@ -326,22 +320,20 @@ void DebuggerRunControlCreator::initialize(const DebuggerStartParameters &sp)
|
||||
|
||||
void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const Kit *kit)
|
||||
{
|
||||
QTC_ASSERT(!m_kit, return);
|
||||
QTC_ASSERT(!m_target, return);
|
||||
QTC_ASSERT(!m_runConfig, return);
|
||||
|
||||
m_kit = kit;
|
||||
m_runConfig = runConfig;
|
||||
|
||||
Target *target = 0;
|
||||
Project *project = 0;
|
||||
|
||||
// Find a Kit and Target. Either could be missing.
|
||||
if (m_runConfig)
|
||||
m_target = m_runConfig->target();
|
||||
target = m_runConfig->target();
|
||||
|
||||
if (!m_kit && m_target)
|
||||
m_kit = m_target->kit();
|
||||
if (!kit && target)
|
||||
kit = target->kit();
|
||||
|
||||
// Make sure we have something sensible to start with.
|
||||
m_rp.inferior.runMode == ApplicationLauncher::Console;
|
||||
m_rp.inferior.runMode = ApplicationLauncher::Console;
|
||||
m_rp.useTerminal = false;
|
||||
|
||||
// Extract as much as possible from available RunConfiguration.
|
||||
@@ -359,7 +351,7 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
|
||||
m_rp.inferior.executable = p.exe;
|
||||
}
|
||||
|
||||
if (!m_kit) {
|
||||
if (!kit) {
|
||||
// This code can only be reached when starting via the command line
|
||||
// (-debug pid or executable) or attaching from runconfiguration
|
||||
// without specifying a kit. Try to find a kit via ABI.
|
||||
@@ -372,14 +364,14 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
|
||||
|
||||
if (!abis.isEmpty()) {
|
||||
// Try exact abis.
|
||||
m_kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
|
||||
kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
|
||||
if (const ToolChain *tc = ToolChainKitInformation::toolChain(k))
|
||||
return abis.contains(tc->targetAbi()) && DebuggerKitInformation::isValidDebugger(k);
|
||||
return false;
|
||||
}));
|
||||
if (!m_kit) {
|
||||
if (!kit) {
|
||||
// Or something compatible.
|
||||
m_kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
|
||||
kit = KitManager::find(KitMatcher([abis](const Kit *k) -> bool {
|
||||
if (const ToolChain *tc = ToolChainKitInformation::toolChain(k))
|
||||
foreach (const Abi &a, abis)
|
||||
if (a.isCompatibleWith(tc->targetAbi()) && DebuggerKitInformation::isValidDebugger(k))
|
||||
@@ -390,11 +382,11 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_kit)
|
||||
m_kit = KitManager::defaultKit();
|
||||
if (!kit)
|
||||
kit = KitManager::defaultKit();
|
||||
|
||||
// We really should have a kit now.
|
||||
if (!m_kit) {
|
||||
if (!kit) {
|
||||
m_errors.append(DebuggerKitInformation::tr("No kit found."));
|
||||
return;
|
||||
}
|
||||
@@ -409,23 +401,23 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
|
||||
}
|
||||
}
|
||||
|
||||
if (ToolChain *tc = ToolChainKitInformation::toolChain(m_kit))
|
||||
if (ToolChain *tc = ToolChainKitInformation::toolChain(kit))
|
||||
m_rp.toolChainAbi = tc->targetAbi();
|
||||
|
||||
if (m_target)
|
||||
m_project = m_target->project();
|
||||
if (target)
|
||||
project = target->project();
|
||||
|
||||
if (m_project && m_rp.projectSourceDirectory.isEmpty())
|
||||
m_rp.projectSourceDirectory = m_project->projectDirectory().toString();
|
||||
if (project && m_rp.projectSourceDirectory.isEmpty())
|
||||
m_rp.projectSourceDirectory = project->projectDirectory().toString();
|
||||
|
||||
if (m_project && m_rp.projectSourceFiles.isEmpty())
|
||||
m_rp.projectSourceFiles = m_project->files(Project::SourceFiles);
|
||||
if (project && m_rp.projectSourceFiles.isEmpty())
|
||||
m_rp.projectSourceFiles = project->files(Project::SourceFiles);
|
||||
|
||||
if (m_project && m_rp.projectSourceFiles.isEmpty())
|
||||
m_rp.projectSourceFiles = m_project->files(Project::SourceFiles);
|
||||
if (project && m_rp.projectSourceFiles.isEmpty())
|
||||
m_rp.projectSourceFiles = project->files(Project::SourceFiles);
|
||||
|
||||
if (false && m_project && m_kit) {
|
||||
const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(m_kit);
|
||||
if (false && project && kit) {
|
||||
const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
|
||||
m_rp.nativeMixedEnabled = version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 7, 0);
|
||||
}
|
||||
|
||||
@@ -434,39 +426,26 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
|
||||
if (ok)
|
||||
m_rp.nativeMixedEnabled = bool(nativeMixedOverride);
|
||||
|
||||
// validate debugger if C++ debugging is enabled
|
||||
if (m_rp.languages & CppLanguage) {
|
||||
const QList<Task> tasks = DebuggerKitInformation::validateDebugger(m_kit);
|
||||
if (!tasks.isEmpty()) {
|
||||
foreach (const Task &t, tasks)
|
||||
m_errors.append(t.description);
|
||||
return;
|
||||
}
|
||||
m_rp.cppEngineType = DebuggerKitInformation::engineType(kit);
|
||||
m_rp.sysRoot = SysRootKitInformation::sysRoot(kit).toString();
|
||||
m_rp.debuggerCommand = DebuggerKitInformation::debuggerCommand(kit).toString();
|
||||
m_rp.device = DeviceKitInformation::device(kit);
|
||||
|
||||
if (project) {
|
||||
m_rp.projectSourceDirectory = project->projectDirectory().toString();
|
||||
m_rp.projectSourceFiles = project->files(Project::SourceFiles);
|
||||
}
|
||||
|
||||
m_rp.cppEngineType = DebuggerKitInformation::engineType(m_kit);
|
||||
m_rp.sysRoot = SysRootKitInformation::sysRoot(m_kit).toString();
|
||||
m_rp.debuggerCommand = DebuggerKitInformation::debuggerCommand(m_kit).toString();
|
||||
m_rp.device = DeviceKitInformation::device(m_kit);
|
||||
|
||||
if (m_project) {
|
||||
m_rp.projectSourceDirectory = m_project->projectDirectory().toString();
|
||||
m_rp.projectSourceFiles = m_project->files(Project::SourceFiles);
|
||||
}
|
||||
|
||||
if (m_runConfig)
|
||||
m_debuggerAspect = m_runConfig->extraAspect<DebuggerRunConfigurationAspect>();
|
||||
|
||||
if (m_rp.displayName.isEmpty() && m_runConfig)
|
||||
m_rp.displayName = m_runConfig->displayName();
|
||||
|
||||
if (runConfig && runConfig->property("supportsDebugger").toBool()) {
|
||||
QString mainScript = runConfig->property("mainScript").toString();
|
||||
QString interpreter = runConfig->property("interpreter").toString();
|
||||
if (m_runConfig && m_runConfig->property("supportsDebugger").toBool()) {
|
||||
QString mainScript = m_runConfig->property("mainScript").toString();
|
||||
QString interpreter = m_runConfig->property("interpreter").toString();
|
||||
if (!interpreter.isEmpty() && mainScript.endsWith(_(".py"))) {
|
||||
m_rp.mainScript = mainScript;
|
||||
m_rp.interpreter = interpreter;
|
||||
QString args = runConfig->property("arguments").toString();
|
||||
QString args = m_runConfig->property("arguments").toString();
|
||||
if (!args.isEmpty()) {
|
||||
if (!m_rp.inferior.commandLineArguments.isEmpty())
|
||||
m_rp.inferior.commandLineArguments.append(QLatin1Char(' '));
|
||||
@@ -476,32 +455,52 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
|
||||
}
|
||||
}
|
||||
|
||||
if (m_debuggerAspect) {
|
||||
m_rp.multiProcess = m_debuggerAspect->useMultiProcess();
|
||||
DebuggerRunConfigurationAspect *debuggerAspect = 0;
|
||||
if (m_runConfig)
|
||||
debuggerAspect = m_runConfig->extraAspect<DebuggerRunConfigurationAspect>();
|
||||
|
||||
if (debuggerAspect)
|
||||
m_rp.multiProcess = debuggerAspect->useMultiProcess();
|
||||
|
||||
if (debuggerAspect) {
|
||||
m_rp.languages = NoLanguage;
|
||||
if (m_debuggerAspect->useCppDebugger())
|
||||
if (debuggerAspect->useCppDebugger())
|
||||
m_rp.languages |= CppLanguage;
|
||||
|
||||
if (m_debuggerAspect->useQmlDebugger()) {
|
||||
if (debuggerAspect->useQmlDebugger())
|
||||
m_rp.languages |= QmlLanguage;
|
||||
if (m_rp.device && m_rp.device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
QTcpServer server;
|
||||
const bool canListen = server.listen(QHostAddress::LocalHost)
|
||||
|| server.listen(QHostAddress::LocalHostIPv6);
|
||||
if (!canListen) {
|
||||
m_errors.append(DebuggerPlugin::tr("Not enough free ports for QML debugging.") + QLatin1Char(' '));
|
||||
return;
|
||||
}
|
||||
m_rp.qmlServerAddress = server.serverAddress().toString();
|
||||
m_rp.qmlServerPort = server.serverPort();
|
||||
}
|
||||
|
||||
// Makes sure that all bindings go through the JavaScript engine, so that
|
||||
// breakpoints are actually hit!
|
||||
const QString optimizerKey = _("QML_DISABLE_OPTIMIZER");
|
||||
if (!m_rp.inferior.environment.hasKey(optimizerKey))
|
||||
m_rp.inferior.environment.set(optimizerKey, _("1"));
|
||||
// This can happen e.g. when started from the command line.
|
||||
if (m_rp.languages == NoLanguage)
|
||||
m_rp.languages = CppLanguage;
|
||||
|
||||
// validate debugger if C++ debugging is enabled
|
||||
if (m_rp.languages & CppLanguage) {
|
||||
const QList<Task> tasks = DebuggerKitInformation::validateDebugger(kit);
|
||||
if (!tasks.isEmpty()) {
|
||||
foreach (const Task &t, tasks)
|
||||
m_errors.append(t.description);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_rp.languages & QmlLanguage) {
|
||||
if (m_rp.device && m_rp.device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
QTcpServer server;
|
||||
const bool canListen = server.listen(QHostAddress::LocalHost)
|
||||
|| server.listen(QHostAddress::LocalHostIPv6);
|
||||
if (!canListen) {
|
||||
m_errors.append(DebuggerPlugin::tr("Not enough free ports for QML debugging.") + QLatin1Char(' '));
|
||||
return;
|
||||
}
|
||||
m_rp.qmlServerAddress = server.serverAddress().toString();
|
||||
m_rp.qmlServerPort = server.serverPort();
|
||||
|
||||
// Makes sure that all bindings go through the JavaScript engine, so that
|
||||
// breakpoints are actually hit!
|
||||
const QString optimizerKey = _("QML_DISABLE_OPTIMIZER");
|
||||
if (!m_rp.inferior.environment.hasKey(optimizerKey))
|
||||
m_rp.inferior.environment.set(optimizerKey, _("1"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,13 +516,10 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
|
||||
}
|
||||
}
|
||||
|
||||
if (m_rp.masterEngineType == NoEngineType && m_debuggerAspect) {
|
||||
const bool wantCppDebugger = m_debuggerAspect->useCppDebugger() && (m_rp.languages & CppLanguage);
|
||||
const bool wantQmlDebugger = m_debuggerAspect->useQmlDebugger() && (m_rp.languages & QmlLanguage);
|
||||
|
||||
if (wantQmlDebugger) {
|
||||
if (m_rp.masterEngineType == NoEngineType) {
|
||||
if (m_rp.languages & QmlLanguage) {
|
||||
QmlDebug::QmlDebugServicesPreset service;
|
||||
if (wantCppDebugger) {
|
||||
if (m_rp.languages & CppLanguage) {
|
||||
if (m_rp.nativeMixedEnabled) {
|
||||
service = QmlDebug::QmlNativeDebuggerServices;
|
||||
} else {
|
||||
@@ -536,7 +532,7 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
|
||||
}
|
||||
if (m_rp.startMode != AttachExternal)
|
||||
QtcProcess::addArg(&m_rp.inferior.commandLineArguments,
|
||||
wantCppDebugger && m_rp.nativeMixedEnabled ?
|
||||
(m_rp.languages & CppLanguage) && m_rp.nativeMixedEnabled ?
|
||||
QmlDebug::qmlDebugNativeArguments(service, false) :
|
||||
QmlDebug::qmlDebugTcpArguments(service, m_rp.qmlServerPort));
|
||||
}
|
||||
|
Reference in New Issue
Block a user