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