Commit 7ce17490 authored by Tobias Hunger's avatar Tobias Hunger

Toolchain: Allow SDK to provide default debuggers

Allow the SDK to provide default debuggers for any ABI.

Task-number: QTCREATORBUG-4292
Task-number: QTCREATORBUG-4299
Reviewed-by: Christian Kandeler
parent 25fb467b
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "linuxiccparser.h" #include "linuxiccparser.h"
#include "headerpath.h" #include "headerpath.h"
#include "projectexplorerconstants.h" #include "projectexplorerconstants.h"
#include "toolchainmanager.h"
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
...@@ -521,11 +522,13 @@ QList<ToolChain *> Internal::GccToolChainFactory::autoDetectToolchains(const QSt ...@@ -521,11 +522,13 @@ QList<ToolChain *> Internal::GccToolChainFactory::autoDetectToolchains(const QSt
if (!abiList.contains(requiredAbi)) if (!abiList.contains(requiredAbi))
return result; return result;
QString debuggerPath; // Find the first debugger QString debuggerPath = ToolChainManager::instance()->defaultDebugger(requiredAbi); // Find the first debugger
foreach (const QString &debugger, debuggers) { if (debuggerPath.isEmpty()) {
debuggerPath = systemEnvironment.searchInPath(debugger); foreach (const QString &debugger, debuggers) {
if (!debuggerPath.isEmpty()) debuggerPath = systemEnvironment.searchInPath(debugger);
break; if (!debuggerPath.isEmpty())
break;
}
} }
foreach (const Abi &abi, abiList) { foreach (const Abi &abi, abiList) {
......
...@@ -47,6 +47,9 @@ ...@@ -47,6 +47,9 @@
static const char *const TOOLCHAIN_DATA_KEY = "ToolChain."; static const char *const TOOLCHAIN_DATA_KEY = "ToolChain.";
static const char *const TOOLCHAIN_COUNT_KEY = "ToolChain.Count"; static const char *const TOOLCHAIN_COUNT_KEY = "ToolChain.Count";
static const char *const TOOLCHAIN_FILE_VERSION_KEY = "Version"; static const char *const TOOLCHAIN_FILE_VERSION_KEY = "Version";
static const char *const DEFAULT_DEBUGGER_COUNT_KEY = "DefaultDebugger.Count";
static const char *const DEFAULT_DEBUGGER_ABI_KEY = "DefaultDebugger.Abi.";
static const char *const DEFAULT_DEBUGGER_PATH_KEY = "DefaultDebugger.Path.";
static const char *const TOOLCHAIN_FILENAME = "/toolChains.xml"; static const char *const TOOLCHAIN_FILENAME = "/toolChains.xml";
static QString settingsFileName() static QString settingsFileName()
...@@ -70,6 +73,7 @@ class ToolChainManagerPrivate ...@@ -70,6 +73,7 @@ class ToolChainManagerPrivate
{ {
public: public:
QList<ToolChain *> m_toolChains; QList<ToolChain *> m_toolChains;
QMap<QString, QString> m_abiToDebugger;
}; };
} // namespace Internal } // namespace Internal
...@@ -96,6 +100,11 @@ ToolChainManager::ToolChainManager(QObject *parent) : ...@@ -96,6 +100,11 @@ ToolChainManager::ToolChainManager(QObject *parent) :
void ToolChainManager::restoreToolChains() void ToolChainManager::restoreToolChains()
{ {
// Restore SDK settings first
restoreToolChains(Core::ICore::instance()->resourcePath()
+ QLatin1String("/Nokia") + QLatin1String(TOOLCHAIN_FILENAME), true);
// Then auto detect
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
QList<ToolChainFactory *> factories = pm->getObjects<ToolChainFactory>(); QList<ToolChainFactory *> factories = pm->getObjects<ToolChainFactory>();
// Autodetect tool chains: // Autodetect tool chains:
...@@ -105,9 +114,8 @@ void ToolChainManager::restoreToolChains() ...@@ -105,9 +114,8 @@ void ToolChainManager::restoreToolChains()
registerToolChain(tc); registerToolChain(tc);
} }
// Then restore user settings
restoreToolChains(settingsFileName(), false); restoreToolChains(settingsFileName(), false);
restoreToolChains(Core::ICore::instance()->resourcePath()
+ QLatin1String("/Nokia") + QLatin1String(TOOLCHAIN_FILENAME), true);
} }
ToolChainManager::~ToolChainManager() ToolChainManager::~ToolChainManager()
...@@ -138,6 +146,8 @@ void ToolChainManager::saveToolChains() ...@@ -138,6 +146,8 @@ void ToolChainManager::saveToolChains()
} }
writer.saveValue(QLatin1String(TOOLCHAIN_COUNT_KEY), count); writer.saveValue(QLatin1String(TOOLCHAIN_COUNT_KEY), count);
writer.save(settingsFileName(), "QtCreatorToolChains"); writer.save(settingsFileName(), "QtCreatorToolChains");
// Do not save default debuggers! Those are set by the SDK!
} }
void ToolChainManager::restoreToolChains(const QString &fileName, bool autoDetected) void ToolChainManager::restoreToolChains(const QString &fileName, bool autoDetected)
...@@ -152,10 +162,22 @@ void ToolChainManager::restoreToolChains(const QString &fileName, bool autoDetec ...@@ -152,10 +162,22 @@ void ToolChainManager::restoreToolChains(const QString &fileName, bool autoDetec
if (version < 1) if (version < 1)
return; return;
// Read default debugger settings (if any)
int count = data.value(QLatin1String(DEFAULT_DEBUGGER_COUNT_KEY)).toInt();
for (int i = 0; i < count; ++i) {
const QString abiKey = QString::fromLatin1(DEFAULT_DEBUGGER_ABI_KEY) + QString::number(i);
if (!data.contains(abiKey))
continue;
const QString pathKey = QString::fromLatin1(DEFAULT_DEBUGGER_PATH_KEY) + QString::number(i);
if (!data.contains(abiKey))
continue;
m_d->m_abiToDebugger.insert(data.value(abiKey).toString(), data.value(pathKey).toString());
}
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
QList<ToolChainFactory *> factories = pm->getObjects<ToolChainFactory>(); QList<ToolChainFactory *> factories = pm->getObjects<ToolChainFactory>();
int count = data.value(QLatin1String(TOOLCHAIN_COUNT_KEY), 0).toInt(); count = data.value(QLatin1String(TOOLCHAIN_COUNT_KEY), 0).toInt();
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
const QString key = QString::fromLatin1(TOOLCHAIN_DATA_KEY) + QString::number(i); const QString key = QString::fromLatin1(TOOLCHAIN_DATA_KEY) + QString::number(i);
if (!data.contains(key)) if (!data.contains(key))
...@@ -207,6 +229,11 @@ ToolChain *ToolChainManager::findToolChain(const QString &id) const ...@@ -207,6 +229,11 @@ ToolChain *ToolChainManager::findToolChain(const QString &id) const
return 0; return 0;
} }
QString ToolChainManager::defaultDebugger(const Abi &abi) const
{
return m_d->m_abiToDebugger.value(abi.toString());
}
void ToolChainManager::notifyAboutUpdate(ProjectExplorer::ToolChain *tc) void ToolChainManager::notifyAboutUpdate(ProjectExplorer::ToolChain *tc)
{ {
if (!tc || !m_d->m_toolChains.contains(tc)) if (!tc || !m_d->m_toolChains.contains(tc))
......
...@@ -68,6 +68,8 @@ public: ...@@ -68,6 +68,8 @@ public:
QList<ToolChain *> findToolChains(const Abi &abi) const; QList<ToolChain *> findToolChains(const Abi &abi) const;
ToolChain *findToolChain(const QString &id) const; ToolChain *findToolChain(const QString &id) const;
QString defaultDebugger(const Abi &abi) const;
public slots: public slots:
void registerToolChain(ProjectExplorer::ToolChain *tc); void registerToolChain(ProjectExplorer::ToolChain *tc);
void deregisterToolChain(ProjectExplorer::ToolChain *tc); void deregisterToolChain(ProjectExplorer::ToolChain *tc);
......
...@@ -321,6 +321,9 @@ QList<ProjectExplorer::ToolChain *> MaemoToolChainFactory::createToolChainList(c ...@@ -321,6 +321,9 @@ QList<ProjectExplorer::ToolChain *> MaemoToolChainFactory::createToolChainList(c
target = "Meego"; target = "Meego";
mTc->setDisplayName(tr("%1 GCC (%2)").arg(target).arg(MaemoGlobal::maddeRoot(v))); mTc->setDisplayName(tr("%1 GCC (%2)").arg(target).arg(MaemoGlobal::maddeRoot(v)));
mTc->setCompilerPath(MaemoGlobal::targetRoot(v) + QLatin1String("/bin/gcc")); mTc->setCompilerPath(MaemoGlobal::targetRoot(v) + QLatin1String("/bin/gcc"));
mTc->setDebuggerCommand(ProjectExplorer::ToolChainManager::instance()->defaultDebugger(v->qtAbis().at(0)));
if (mTc->debuggerCommand().isEmpty())
mTc->setDebuggerCommand(MaemoGlobal::targetRoot(v) + QLatin1String("/bin/gdb"));
result.append(mTc); result.append(mTc);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment