Commit 129c958a authored by hjk's avatar hjk

debugger: refactor debugger configuration check

parent 1b1663a2
......@@ -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)
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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();
......
......@@ -101,7 +101,7 @@ public:
Core::SshConnectionParameters connParams;
QString debuggerCommand;
int toolChainType;
ProjectExplorer::ToolChainType toolChainType;
QString qtInstallPath;
QString dumperLibrary;
......
......@@ -41,6 +41,7 @@
namespace Qt4ProjectManager {
namespace Internal {
class MaemoRunConfiguration;
class MaemoSshRunner;
......
......@@ -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;
}
......
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