Commit 1d052ec9 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger[New CDB]: Improve and enable auto-detection.

Also take over symbol path of the old CDB engine on
auto-detect.
parent 93fc835d
......@@ -28,6 +28,7 @@
**************************************************************************/
#include "cdboptions2.h"
#include "cdbengine2.h"
#ifdef Q_OS_WIN
# include <utils/winutils.h>
......@@ -36,6 +37,7 @@
#include <QtCore/QSettings>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QCoreApplication>
static const char settingsGroupC[] = "CDB2";
static const char enabledKeyC[] = "Enabled";
......@@ -57,26 +59,87 @@ QString CdbOptions::settingsGroup()
return QLatin1String(settingsGroupC);
}
void CdbOptions::clear()
void CdbOptions::clearExecutable()
{
is64bit = enabled = false;
executable.clear();
}
void CdbOptions::clear()
{
clearExecutable();
symbolPaths.clear();
sourcePaths.clear();
}
void CdbOptions::fromSettings(const QSettings *s)
static inline QString msgAutoDetectFail(bool is64Bit, const QString &executable,
const QString &extLib)
{
return QCoreApplication::translate("Debugger::Cdb::CdbOptions",
"Auto-detection of the new CDB debugging engine (%1bit) failed:\n"
"Debugger executable: %2\n"
"Extension library : %3 not present.\n").arg(is64Bit ? 64 : 32).
arg(QDir::toNativeSeparators(executable), QDir::toNativeSeparators(extLib));
}
static inline QString msgAutoDetect(bool is64Bit, const QString &executable,
const QString &extLib,
const QStringList &symbolPaths)
{
return QCoreApplication::translate("Debugger::Cdb::CdbOptions",
"The new CDB debugging engine (%1bit) has been set up automatically:\n"
"Debugger executable: %2\n"
"Extension library : %3\n"
"Symbol paths : %4\n").arg(is64Bit ? 64 : 32).
arg(QDir::toNativeSeparators(executable), QDir::toNativeSeparators(extLib),
symbolPaths.join(QString(QLatin1Char(';'))));
}
QStringList CdbOptions::oldEngineSymbolPaths(const QSettings *s)
{
return s->value(QLatin1String("CDB/SymbolPaths")).toStringList();
}
bool CdbOptions::autoDetect(const QSettings *s)
{
QString autoExecutable;
bool auto64Bit;
// Check installation and existence of the extension library
CdbOptions::autoDetectExecutable(&autoExecutable, &auto64Bit);
if (autoExecutable.isEmpty())
return false;
const QString extLib = CdbEngine::extensionLibraryName(auto64Bit);
if (!QFileInfo(extLib).isFile()) {
const QString failMsg = msgAutoDetectFail(auto64Bit, autoExecutable, extLib);
qWarning("%s", qPrintable(failMsg));
clearExecutable();
return false;
}
enabled = true;
is64bit = auto64Bit;
executable = autoExecutable;
// Is there a symbol path from an old install? Use that
if (symbolPaths.empty())
symbolPaths = CdbOptions::oldEngineSymbolPaths(s);
const QString msg = msgAutoDetect(is64bit, QDir::toNativeSeparators(executable),
QDir::toNativeSeparators(extLib), symbolPaths);
qWarning("%s", qPrintable(msg));
return true;
}
void CdbOptions::fromSettings(QSettings *s)
{
clear();
// Is this the first time we are called ->
// try to find automatically
const QString keyRoot = QLatin1String(settingsGroupC) + QLatin1Char('/');
const QString enabledKey = keyRoot + QLatin1String(enabledKeyC);
#if 0 // TODO: Enable autodetection after deprecating the old CDB engine only.
// First-time autodetection: Write back parameters
const bool firstTime = !s->contains(enabledKey);
if (firstTime)
CdbOptions::autoDetectExecutable(&executable, &is64bit);
#endif
if (firstTime && autoDetect(s)) {
toSettings(s);
return;
}
enabled = s->value(enabledKey, false).toBool();
is64bit = s->value(keyRoot + QLatin1String(is64bitKeyC), is64bit).toBool();
executable = s->value(keyRoot + QLatin1String(pathKeyC), executable).toString();
......
......@@ -43,9 +43,11 @@ struct CdbOptions
{
public:
CdbOptions();
void clearExecutable();
void clear();
void fromSettings(const QSettings *s);
void fromSettings(QSettings *s); // Writes parameters on first-time autodetect
bool autoDetect(const QSettings *s);
void toSettings(QSettings *s) const;
bool equals(const CdbOptions &rhs) const;
......@@ -54,6 +56,7 @@ public:
QStringList *checkedDirectories = 0);
static QString settingsGroup();
static QStringList oldEngineSymbolPaths(const QSettings *s);
bool enabled;
bool is64bit;
......
......@@ -91,7 +91,7 @@ void CdbOptionsPageWidget::setOptions(CdbOptions &o)
m_ui.pathChooser->setPath(o.executable);
m_ui.is64BitCheckBox->setChecked(o.is64bit);
m_ui.cdbPathGroupBox->setChecked(o.enabled);
m_ui.symbolPathListEditor->setPathList(o.symbolPaths);
setSymbolPaths(o.symbolPaths);
m_ui.sourcePathListEditor->setPathList(o.sourcePaths);
}
......@@ -111,11 +111,21 @@ CdbOptions CdbOptionsPageWidget::options() const
rc.executable = path();
rc.enabled = m_ui.cdbPathGroupBox->isChecked();
rc.is64bit = is64Bit();
rc.symbolPaths = m_ui.symbolPathListEditor->pathList();
rc.symbolPaths = symbolPaths();
rc.sourcePaths = m_ui.sourcePathListEditor->pathList();
return rc;
}
QStringList CdbOptionsPageWidget::symbolPaths() const
{
return m_ui.symbolPathListEditor->pathList();
}
void CdbOptionsPageWidget::setSymbolPaths(const QStringList &s)
{
m_ui.symbolPathListEditor->setPathList(s);
}
void CdbOptionsPageWidget::hideReportLabel()
{
m_ui.reportLabel->clear();
......@@ -136,6 +146,10 @@ void CdbOptionsPageWidget::autoDetect()
// Now check for the extension library as well.
const bool allOk = checkInstallation(executable, is64Bit(), &report);
setReport(report, allOk);
// On this occasion, if no symbol paths are specified, check for an
// old CDB installation
if (symbolPaths().isEmpty())
setSymbolPaths(CdbOptions::oldEngineSymbolPaths(Core::ICore::instance()->settings()));
} else {
const QString msg = tr("\"Debugging Tools for Windows\" could not be found.");
const QString details = tr("Checked:\n%1").arg(checkedDirectories.join(QString(QLatin1Char('\n'))));
......
......@@ -63,6 +63,8 @@ private slots:
void hideReportLabel();
private:
QStringList symbolPaths() const;
void setSymbolPaths(const QStringList &s);
void setReport(const QString &, bool success);
inline bool is64Bit() const;
inline QString path() const;
......
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