Commit 129c958a authored by hjk's avatar hjk

debugger: refactor debugger configuration check

parent 1b1663a2
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "registerhandler.h" #include "registerhandler.h"
#include "disassembleragent.h" #include "disassembleragent.h"
#include "memoryagent.h" #include "memoryagent.h"
#include "debuggerrunner.h"
#include "debuggertooltip.h" #include "debuggertooltip.h"
#include "cdbparsehelpers.h" #include "cdbparsehelpers.h"
#include "watchutils.h" #include "watchutils.h"
...@@ -115,13 +116,14 @@ enum { debugBreakpoints = 0 }; ...@@ -115,13 +116,14 @@ enum { debugBreakpoints = 0 };
* postExtensionCommand: Run a command provided by the extension producing * postExtensionCommand: Run a command provided by the extension producing
* one-line output and invoke a callback with a CdbExtensionCommand structure. */ * one-line output and invoke a callback with a CdbExtensionCommand structure. */
using namespace ProjectExplorer;
using namespace Debugger::Internal;
namespace Debugger { namespace Debugger {
namespace Cdb { namespace Cdb {
static const char localsPrefixC[] = "local."; static const char localsPrefixC[] = "local.";
using namespace Debugger::Internal;
struct MemoryViewCookie { struct MemoryViewCookie {
explicit MemoryViewCookie(MemoryAgent *a = 0, QObject *e = 0, explicit MemoryViewCookie(MemoryAgent *a = 0, QObject *e = 0,
quint64 addr = 0, quint64 l = 0) : quint64 addr = 0, quint64 l = 0) :
...@@ -252,10 +254,10 @@ static inline bool validMode(DebuggerStartMode sm) ...@@ -252,10 +254,10 @@ static inline bool validMode(DebuggerStartMode sm)
return true; return true;
} }
static inline QString msgCdbDisabled(ProjectExplorer::ToolChainType tc) static inline QString msgCdbDisabled(ToolChainType tc)
{ {
return CdbEngine::tr("The CDB debug engine required for %1 is currently disabled."). return CdbEngine::tr("The CDB debug engine required for %1 is currently disabled.").
arg(ProjectExplorer::ToolChain::toolChainName(tc)); arg(ToolChain::toolChainName(tc));
} }
// Accessed by RunControlFactory // Accessed by RunControlFactory
...@@ -264,7 +266,7 @@ DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp, QString *erro ...@@ -264,7 +266,7 @@ DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp, QString *erro
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
CdbOptionsPage *op = CdbOptionsPage::instance(); CdbOptionsPage *op = CdbOptionsPage::instance();
if (!op || !op->options()->isValid()) { if (!op || !op->options()->isValid()) {
*errorMessage = msgCdbDisabled(static_cast<ProjectExplorer::ToolChainType>(sp.toolChainType)); *errorMessage = msgCdbDisabled(sp.toolChainType);
return 0; return 0;
} }
if (!validMode(sp.startMode)) { if (!validMode(sp.startMode)) {
...@@ -288,30 +290,28 @@ bool isCdbEngineEnabled() ...@@ -288,30 +290,28 @@ bool isCdbEngineEnabled()
#endif #endif
} }
bool checkCdbConfiguration(int toolChainI, QString *errorMsg, QString *settingsPage) ConfigurationCheck checkCdbConfiguration(ToolChainType toolChain)
{ {
const ProjectExplorer::ToolChainType toolChain = static_cast<ProjectExplorer::ToolChainType>(toolChainI); ConfigurationCheck check;
switch (toolChain) { switch (toolChain) {
case ProjectExplorer::ToolChain_MinGW: // Do our best case ToolChain_MinGW: // Do our best
case ProjectExplorer::ToolChain_MSVC: case ToolChain_MSVC:
case ProjectExplorer::ToolChain_WINCE: case ToolChain_WINCE:
case ProjectExplorer::ToolChain_OTHER: case ToolChain_OTHER:
case ProjectExplorer::ToolChain_UNKNOWN: case ToolChain_UNKNOWN:
case ProjectExplorer::ToolChain_INVALID: case ToolChain_INVALID:
if (!isCdbEngineEnabled()) { if (!isCdbEngineEnabled()) {
*errorMsg = msgCdbDisabled(toolChain); check.errorMessage = msgCdbDisabled(toolChain);
*settingsPage = CdbOptionsPage::settingsId(); check.settingsPage = CdbOptionsPage::settingsId();
return false;
} }
break; break;
default: default:
//: %1 is something like "GCCE" or "Intel C++ Compiler (Linux)" (see ToolChain context) //: %1 is something like "GCCE" or "Intel C++ Compiler (Linux)" (see ToolChain context)
*errorMsg = CdbEngine::tr("The CDB debug engine does not support the %1 toolchain."). check.errorMessage = CdbEngine::tr("The CDB debug engine does not support the %1 toolchain.").
arg(ProjectExplorer::ToolChain::toolChainName(toolChain)); arg(ToolChain::toolChainName(toolChain));
*settingsPage = CdbOptionsPage::settingsId(); check.settingsPage = CdbOptionsPage::settingsId();
return false;
} }
return true; return check;
} }
void addCdb2OptionPages(QList<Core::IOptionsPage *> *opts) void addCdb2OptionPages(QList<Core::IOptionsPage *> *opts)
......
...@@ -2499,8 +2499,8 @@ void DebuggerPluginPrivate::createNewDock(QWidget *widget) ...@@ -2499,8 +2499,8 @@ void DebuggerPluginPrivate::createNewDock(QWidget *widget)
void DebuggerPluginPrivate::runControlStarted(DebuggerEngine *engine) void DebuggerPluginPrivate::runControlStarted(DebuggerEngine *engine)
{ {
activateDebugMode(); activateDebugMode();
QString toolChainName = ToolChain::toolChainName( QString toolChainName =
ProjectExplorer::ToolChainType((engine->startParameters().toolChainType))); ToolChain::toolChainName(engine->startParameters().toolChainType);
const QString message = tr("Starting debugger '%1' for tool chain '%2'...") const QString message = tr("Starting debugger '%1' for tool chain '%2'...")
.arg(engine->objectName()).arg(toolChainName); .arg(engine->objectName()).arg(toolChainName);
showMessage(message, StatusBar); showMessage(message, StatusBar);
......
...@@ -71,9 +71,9 @@ using namespace Debugger::Internal; ...@@ -71,9 +71,9 @@ using namespace Debugger::Internal;
namespace Debugger { namespace Debugger {
namespace Cdb { namespace Cdb {
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &, QString *error);
bool isCdbEngineEnabled(); // Check the configuration page bool isCdbEngineEnabled(); // Check the configuration page
bool checkCdbConfiguration(int toolChainI, QString *errorMsg, QString *settingsPage); ConfigurationCheck checkCdbConfiguration(ToolChainType toolChain);
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &, QString *error);
} }
namespace Internal { namespace Internal {
...@@ -176,8 +176,10 @@ DebuggerEngineType DebuggerRunControlPrivate::engineForExecutable ...@@ -176,8 +176,10 @@ DebuggerEngineType DebuggerRunControlPrivate::engineForExecutable
// We need the CDB debugger in order to be able to debug VS // We need the CDB debugger in order to be able to debug VS
// executables. // executables.
if (DebuggerRunControl::checkDebugConfiguration(ProjectExplorer::ToolChain_MSVC, ConfigurationCheck check = checkDebugConfiguration(ToolChain_MSVC);
&m_errorMessage, 0, &m_settingsIdHint)) { if (!check) {
m_errorMessage = check.errorMessage;
m_settingsIdHint = check.settingsPage;
if (enabledEngineTypes & CdbEngineType) if (enabledEngineTypes & CdbEngineType)
return CdbEngineType; return CdbEngineType;
m_errorMessage = msgEngineNotAvailable("Cdb Engine"); m_errorMessage = msgEngineNotAvailable("Cdb Engine");
...@@ -225,19 +227,19 @@ DebuggerEngineType DebuggerRunControlPrivate::engineForMode ...@@ -225,19 +227,19 @@ DebuggerEngineType DebuggerRunControlPrivate::engineForMode
// //
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static DebuggerEngineType engineForToolChain(int toolChainType) static DebuggerEngineType engineForToolChain(ToolChainType toolChainType)
{ {
switch (toolChainType) { switch (toolChainType) {
case ProjectExplorer::ToolChain_LINUX_ICC: case ToolChain_LINUX_ICC:
case ProjectExplorer::ToolChain_MinGW: case ToolChain_MinGW:
case ProjectExplorer::ToolChain_GCC: case ToolChain_GCC:
case ProjectExplorer::ToolChain_WINSCW: // S60 case ToolChain_WINSCW: // S60
case ProjectExplorer::ToolChain_GCCE: case ToolChain_GCCE:
case ProjectExplorer::ToolChain_RVCT2_ARMV5: case ToolChain_RVCT2_ARMV5:
case ProjectExplorer::ToolChain_RVCT2_ARMV6: case ToolChain_RVCT2_ARMV6:
case ProjectExplorer::ToolChain_RVCT_ARMV5_GNUPOC: case ToolChain_RVCT_ARMV5_GNUPOC:
case ProjectExplorer::ToolChain_GCCE_GNUPOC: case ToolChain_GCCE_GNUPOC:
case ProjectExplorer::ToolChain_GCC_MAEMO: case ToolChain_GCC_MAEMO:
#ifdef WITH_LLDB #ifdef WITH_LLDB
// lldb override // lldb override
if (Core::ICore::instance()->settings()->value("LLDB/enabled").toBool()) if (Core::ICore::instance()->settings()->value("LLDB/enabled").toBool())
...@@ -246,13 +248,13 @@ static DebuggerEngineType engineForToolChain(int toolChainType) ...@@ -246,13 +248,13 @@ static DebuggerEngineType engineForToolChain(int toolChainType)
return GdbEngineType; return GdbEngineType;
case ProjectExplorer::ToolChain_MSVC: case ToolChain_MSVC:
case ProjectExplorer::ToolChain_WINCE: case ToolChain_WINCE:
return CdbEngineType; return CdbEngineType;
case ProjectExplorer::ToolChain_OTHER: case ToolChain_OTHER:
case ProjectExplorer::ToolChain_UNKNOWN: case ToolChain_UNKNOWN:
case ProjectExplorer::ToolChain_INVALID: case ToolChain_INVALID:
default: default:
break; break;
} }
...@@ -345,8 +347,7 @@ DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration, ...@@ -345,8 +347,7 @@ DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration,
// Could not find anything suitable. // Could not find anything suitable.
debuggingFinished(); debuggingFinished();
// Create Message box with possibility to go to settings. // Create Message box with possibility to go to settings.
QString toolChainName = QString toolChainName = ToolChain::toolChainName(sp.toolChainType);
ToolChain::toolChainName(ProjectExplorer::ToolChainType(sp.toolChainType));
const QString msg = tr("Cannot debug '%1' (tool chain: '%2'): %3") const QString msg = tr("Cannot debug '%1' (tool chain: '%2'): %3")
.arg(sp.executable, toolChainName, d->m_errorMessage); .arg(sp.executable, toolChainName, d->m_errorMessage);
Core::ICore::instance()->showWarningWithOptions(tr("Warning"), Core::ICore::instance()->showWarningWithOptions(tr("Warning"),
...@@ -383,53 +384,41 @@ void DebuggerRunControl::setCustomEnvironment(Utils::Environment env) ...@@ -383,53 +384,41 @@ void DebuggerRunControl::setCustomEnvironment(Utils::Environment env)
d->m_engine->startParameters().environment = env; d->m_engine->startParameters().environment = env;
} }
bool DebuggerRunControl::checkDebugConfiguration(int toolChain, ConfigurationCheck checkDebugConfiguration(ToolChainType toolChain)
QString *errorMessage,
QString *settingsCategory /* = 0 */,
QString *settingsPage /* = 0 */)
{ {
errorMessage->clear(); ConfigurationCheck result;
if (settingsCategory)
settingsCategory->clear();
if (settingsPage)
settingsPage->clear();
bool success = true;
if (!(debuggerCore()->activeLanguages() & CppLanguage)) if (!(debuggerCore()->activeLanguages() & CppLanguage))
return success; return result;
switch(toolChain) { switch(toolChain) {
case ProjectExplorer::ToolChain_GCC: case ToolChain_GCC:
case ProjectExplorer::ToolChain_LINUX_ICC: case ToolChain_LINUX_ICC:
case ProjectExplorer::ToolChain_MinGW: case ToolChain_MinGW:
case ProjectExplorer::ToolChain_WINCE: // S60 case ToolChain_WINCE: // S60
case ProjectExplorer::ToolChain_WINSCW: case ToolChain_WINSCW:
case ProjectExplorer::ToolChain_GCCE: case ToolChain_GCCE:
case ProjectExplorer::ToolChain_RVCT2_ARMV5: case ToolChain_RVCT2_ARMV5:
case ProjectExplorer::ToolChain_RVCT2_ARMV6: case ToolChain_RVCT2_ARMV6:
if (debuggerCore()->gdbBinaryForToolChain(toolChain).isEmpty()) { if (debuggerCore()->gdbBinaryForToolChain(toolChain).isEmpty()) {
*errorMessage = msgNoBinaryForToolChain(toolChain); result.errorMessage = msgNoBinaryForToolChain(toolChain);
*settingsPage = GdbOptionsPage::settingsId(); result.errorMessage += msgEngineNotAvailable("Gdb");
*errorMessage += msgEngineNotAvailable("Gdb"); result.settingsPage = GdbOptionsPage::settingsId();
success = false;
} else {
success = true;
} }
break; break;
case ProjectExplorer::ToolChain_MSVC: case ToolChain_MSVC:
success = Cdb::checkCdbConfiguration(toolChain, errorMessage, settingsPage); result = Cdb::checkCdbConfiguration(toolChain);
if (!success) { if (!result) {
*errorMessage += msgEngineNotAvailable("Cdb"); result.errorMessage += msgEngineNotAvailable("Cdb");
if (settingsPage) result.settingsPage = QLatin1String("Cdb");
*settingsPage = QLatin1String("Cdb");
} }
break; break;
} }
if (!success && settingsCategory && settingsPage && !settingsPage->isEmpty())
*settingsCategory = QLatin1String(Constants::DEBUGGER_SETTINGS_CATEGORY);
return success; if (!result && !result.settingsPage.isEmpty())
result.settingsCategory = QLatin1String(Constants::DEBUGGER_SETTINGS_CATEGORY);
return result;
} }
void DebuggerRunControl::start() void DebuggerRunControl::start()
...@@ -642,15 +631,12 @@ QWidget *DebuggerRunControlFactory::createConfigurationWidget ...@@ -642,15 +631,12 @@ QWidget *DebuggerRunControlFactory::createConfigurationWidget
DebuggerRunControl *DebuggerRunControlFactory::create DebuggerRunControl *DebuggerRunControlFactory::create
(const DebuggerStartParameters &sp, RunConfiguration *runConfiguration) (const DebuggerStartParameters &sp, RunConfiguration *runConfiguration)
{ {
QString errorMessage; ConfigurationCheck check = checkDebugConfiguration(sp.toolChainType);
QString settingsCategory;
QString settingsPage;
if (!DebuggerRunControl::checkDebugConfiguration(sp.toolChainType, if (!check) {
&errorMessage, &settingsCategory, &settingsPage)) {
//appendMessage(errorMessage, true); //appendMessage(errorMessage, true);
Core::ICore::instance()->showWarningWithOptions(tr("Debugger"), Core::ICore::instance()->showWarningWithOptions(tr("Debugger"),
errorMessage, QString(), settingsCategory, settingsPage); check.errorMessage, QString(), check.settingsCategory, check.settingsPage);
return 0; return 0;
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "debugger_global.h" #include "debugger_global.h"
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
#include <projectexplorer/toolchaintype.h>
#include <QtCore/QScopedPointer> #include <QtCore/QScopedPointer>
...@@ -81,6 +82,20 @@ private: ...@@ -81,6 +82,20 @@ private:
} // namespace Internal } // namespace Internal
class ConfigurationCheck
{
public:
ConfigurationCheck() {}
operator bool() const { return errorMessage.isEmpty(); }
public:
QString errorMessage;
QString settingsCategory;
QString settingsPage;
};
ConfigurationCheck checkDebugConfiguration(ProjectExplorer::ToolChainType toolChain);
// This is a job description containing all data "local" to the jobs, including // This is a job description containing all data "local" to the jobs, including
// the models of the individual debugger views. // the models of the individual debugger views.
class DEBUGGER_EXPORT DebuggerRunControl class DEBUGGER_EXPORT DebuggerRunControl
...@@ -109,10 +124,6 @@ public: ...@@ -109,10 +124,6 @@ public:
void showMessage(const QString &msg, int channel); void showMessage(const QString &msg, int channel);
static bool checkDebugConfiguration(int toolChain,
QString *errorMessage,
QString *settingsCategory = 0,
QString *settingsPage = 0);
signals: signals:
void engineRequestSetup(); void engineRequestSetup();
......
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
Core::SshConnectionParameters connParams; Core::SshConnectionParameters connParams;
QString debuggerCommand; QString debuggerCommand;
int toolChainType; ProjectExplorer::ToolChainType toolChainType;
QString qtInstallPath; QString qtInstallPath;
QString dumperLibrary; QString dumperLibrary;
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
class MaemoRunConfiguration; class MaemoRunConfiguration;
class MaemoSshRunner; class MaemoSshRunner;
......
...@@ -818,16 +818,14 @@ S60DeviceDebugRunControl::S60DeviceDebugRunControl(S60DeviceRunConfiguration *rc ...@@ -818,16 +818,14 @@ S60DeviceDebugRunControl::S60DeviceDebugRunControl(S60DeviceRunConfiguration *rc
void S60DeviceDebugRunControl::start() void S60DeviceDebugRunControl::start()
{ {
QString errorMessage; Debugger::ConfigurationCheck check =
QString settingsCategory; Debugger::checkDebugConfiguration(startParameters().toolChainType);
QString settingsPage;
if (!Debugger::DebuggerRunControl::checkDebugConfiguration(startParameters().toolChainType, if (!check) {
&errorMessage, &settingsCategory, &settingsPage)) { appendMessage(check.errorMessage, ErrorMessageFormat);
appendMessage(errorMessage, ErrorMessageFormat);
emit finished(); emit finished();
Core::ICore::instance()->showWarningWithOptions(tr("Debugger for Symbian Platform"), Core::ICore::instance()->showWarningWithOptions(tr("Debugger for Symbian Platform"),
errorMessage, QString(), check.errorMessage, QString(), check.settingsCategory, check.settingsPage);
settingsCategory, settingsPage);
return; return;
} }
......
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