Commit 12ac317d authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Obtain the toolchain type and choose debugger engine accordingly.

parent f55632fc
......@@ -57,6 +57,7 @@
#endif
#include <coreplugin/icore.h>
#include <utils/qtcassert.h>
#include <projectexplorer/toolchain.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>
......@@ -95,7 +96,8 @@ QDebug operator<<(QDebug str, const DebuggerStartParameters &p)
<< " attachPID=" << p.attachPID << " useTerminal=" << p.useTerminal
<< " remoteChannel=" << p.remoteChannel
<< " remoteArchitecture=" << p.remoteArchitecture
<< " serverStartScript=" << p.serverStartScript << '\n';
<< " serverStartScript=" << p.serverStartScript
<< " toolchain=" << p.toolChainType << '\n';
return str;
}
} // namespace Internal
......@@ -155,7 +157,8 @@ IDebuggerEngine *createTcfEngine(DebuggerManager *parent, QList<Core::IOptionsPa
DebuggerStartParameters::DebuggerStartParameters() :
attachPID(-1),
useTerminal(false)
useTerminal(false),
toolChainType(ProjectExplorer::ToolChain::UNKNOWN)
{
}
......@@ -173,6 +176,7 @@ void DebuggerStartParameters::clear()
remoteChannel.clear();
remoteArchitecture.clear();
serverStartScript.clear();
toolChainType = ProjectExplorer::ToolChain::UNKNOWN;
}
// --------- DebuggerManager
......@@ -806,17 +810,59 @@ QVariant DebuggerManager::sessionValue(const QString &name)
return value;
}
// Figure out the debugger type of an executable
static inline QString msgEngineNotAvailable(const char *engine)
{
return DebuggerManager::tr("The application requires the debugger engine '%1', which is disabled.").arg(QLatin1String(engine));
}
static IDebuggerEngine *debuggerEngineForToolChain(ProjectExplorer::ToolChain::ToolChainType tc)
{
IDebuggerEngine *rc = 0;
switch (tc) {
case ProjectExplorer::ToolChain::LinuxICC:
case ProjectExplorer::ToolChain::MinGW:
case ProjectExplorer::ToolChain::GCC:
rc = gdbEngine;
break;
case ProjectExplorer::ToolChain::MSVC:
case ProjectExplorer::ToolChain::WINCE:
rc = winEngine;
break;
case ProjectExplorer::ToolChain::OTHER:
case ProjectExplorer::ToolChain::UNKNOWN:
case ProjectExplorer::ToolChain::INVALID:
break;
}
if (Debugger::Constants::Internal::debug)
qDebug() << "Toolchain" << tc << rc;
return rc;
}
// Figure out the debugger type of an executable. Analyze executable
// unless the toolchain provides a hint.
static IDebuggerEngine *determineDebuggerEngine(const QString &executable,
QString *errorMessage,
QString *settingsIdHint)
int toolChainType,
QString *errorMessage,
QString *settingsIdHint)
{
if (executable.endsWith(_(".js")))
if (IDebuggerEngine *tce = debuggerEngineForToolChain(static_cast<ProjectExplorer::ToolChain::ToolChainType>(toolChainType)))
return tce;
if (executable.endsWith(_(".js"))) {
if (!scriptEngine) {
*errorMessage = msgEngineNotAvailable("Script Engine");
return 0;
}
return scriptEngine;
}
#ifndef Q_OS_WIN
Q_UNUSED(errorMessage)
#ifndef Q_OS_WIN
Q_UNUSED(settingsIdHint)
if (!gdbEngine) {
*errorMessage = msgEngineNotAvailable("Gdb Engine");
return 0;
}
return gdbEngine;
#else
// If a file has PDB files, it has been compiled by VS.
......@@ -839,12 +885,25 @@ static IDebuggerEngine *determineDebuggerEngine(const QString &executable,
// Figure out the debugger type of a PID
static IDebuggerEngine *determineDebuggerEngine(int /* pid */,
QString * /*errorMessage*/)
int toolChainType,
QString *errorMessage)
{
if (IDebuggerEngine *tce = debuggerEngineForToolChain(static_cast<ProjectExplorer::ToolChain::ToolChainType>(toolChainType)))
return tce;
#ifdef Q_OS_WIN
// Preferably Windows debugger
return winEngine ? winEngine : gdbEngine;
if (winEngine)
return winEngine;
if (gdbEngine)
return gdbEngine;
*errorMessage = msgEngineNotAvailable("Gdb Engine");
return 0;
#else
if (!gdbEngine) {
*errorMessage = msgEngineNotAvailable("Gdb Engine");
return 0;
}
return gdbEngine;
#endif
}
......@@ -857,21 +916,23 @@ void DebuggerManager::startNewDebugger(DebuggerRunControl *runControl, const QSh
m_startParameters = startParameters;
m_inferiorPid = startParameters->attachPID > 0 ? startParameters->attachPID : 0;
m_runControl = runControl;
const QString toolChainName = ProjectExplorer::ToolChain::toolChainName(static_cast<ProjectExplorer::ToolChain::ToolChainType>(m_startParameters->toolChainType));
emit debugModeRequested();
showDebuggerOutput(QLatin1String("status:"), tr("Starting debugger for tool chain '%1'...").arg(toolChainName));
QString errorMessage;
QString settingsIdHint;
switch (startMode()) {
case AttachExternal:
case AttachCrashedExternal:
m_engine = determineDebuggerEngine(m_startParameters->attachPID, &errorMessage);
m_engine = determineDebuggerEngine(m_startParameters->attachPID, m_startParameters->toolChainType, &errorMessage);
break;
case AttachTcf:
m_engine = tcfEngine;
break;
default:
m_engine = determineDebuggerEngine(m_startParameters->executable, &errorMessage, &settingsIdHint);
m_engine = determineDebuggerEngine(m_startParameters->executable, m_startParameters->toolChainType, &errorMessage, &settingsIdHint);
break;
}
......@@ -879,7 +940,8 @@ void DebuggerManager::startNewDebugger(DebuggerRunControl *runControl, const QSh
debuggingFinished();
// Create Message box with possibility to go to settings
QAbstractButton *settingsButton = 0;
QMessageBox msgBox(QMessageBox::Warning, tr("Warning"), tr("Cannot debug '%1': %2").arg(m_startParameters->executable, errorMessage), QMessageBox::Ok);
QMessageBox msgBox(QMessageBox::Warning, tr("Warning"), tr("Cannot debug '%1' (tool chain: '%2'): %3").
arg(m_startParameters->executable, toolChainName, errorMessage), QMessageBox::Ok);
if (!settingsIdHint.isEmpty())
settingsButton = msgBox.addButton(tr("Settings..."), QMessageBox::AcceptRole);
msgBox.exec();
......@@ -887,6 +949,7 @@ void DebuggerManager::startNewDebugger(DebuggerRunControl *runControl, const QSh
Core::ICore::instance()->showOptionsDialog(_(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY), settingsIdHint);
return;
}
if (Debugger::Constants::Internal::debug)
qDebug() << m_startParameters->executable << m_engine;
......
......@@ -145,6 +145,7 @@ struct DebuggerStartParameters
QString remoteChannel;
QString remoteArchitecture;
QString serverStartScript;
int toolChainType;
};
QDebug operator<<(QDebug str, const DebuggerStartParameters &);
......
......@@ -82,6 +82,14 @@ RunControl* DebuggerRunner::run(RunConfigurationPtr runConfiguration,
ApplicationRunConfigurationPtr rc =
runConfiguration.dynamicCast<ApplicationRunConfiguration>();
Q_ASSERT(!rc.isNull());
switch (sp->toolChainType) {
case ProjectExplorer::ToolChain::UNKNOWN:
case ProjectExplorer::ToolChain::INVALID:
sp->toolChainType = rc->toolChainType();
break;
default:
break;
}
//qDebug() << "***** Debugging" << rc->name() << rc->executable();
DebuggerRunControl *runControl = new DebuggerRunControl(m_manager, startMode, sp, rc);
return runControl;
......
......@@ -37,6 +37,7 @@
#include <QtCore/QDir>
#include <QtCore/QTemporaryFile>
#include <QtCore/QString>
#include <QtCore/QCoreApplication>
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
......@@ -102,6 +103,29 @@ QStringList ToolChain::supportedToolChains()
<< QLatin1String("wince");
}
QString ToolChain::toolChainName(ToolChainType tc)
{
switch (tc) {
case GCC:
return QLatin1String("gcc");
case LinuxICC:
return QLatin1String("Linux icc");
case MinGW:
return QLatin1String("MinGW");
case MSVC:
return QLatin1String("MS VC");
case WINCE:
return QLatin1String("Windows CE");
case OTHER:
return QCoreApplication::translate("ToolChain", "Other");
case INVALID:
return QCoreApplication::translate("ToolChain", "<Invalid>");
case UNKNOWN:
break;
};
return QCoreApplication::translate("ToolChain", "<Unknown>");
}
GccToolChain::GccToolChain(const QString &gcc)
: m_gcc(gcc)
{
......
......@@ -96,6 +96,8 @@ public:
static QStringList availableMSVCVersions();
static QStringList supportedToolChains();
static QString toolChainName(ToolChainType tc);
protected:
virtual bool equals(ToolChain *other) const = 0;
};
......
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