From 55ab8742e28f99d2c7981615db61eb525168763f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Tue, 9 Nov 2010 12:40:36 +0100 Subject: [PATCH] Debugger: Move cdbsymbolpathlisteditor to shared for new CDB engine. --- src/plugins/debugger/cdb/cdb.pri | 2 - src/plugins/debugger/cdb/cdboptions.cpp | 29 ++------------- src/plugins/debugger/cdb/cdboptions.h | 1 - .../cdbsymbolpathlisteditor.cpp | 37 ++++++++++++++++++- .../{cdb => shared}/cdbsymbolpathlisteditor.h | 11 ++++++ src/plugins/debugger/shared/shared.pri | 7 +++- 6 files changed, 55 insertions(+), 32 deletions(-) rename src/plugins/debugger/{cdb => shared}/cdbsymbolpathlisteditor.cpp (75%) rename src/plugins/debugger/{cdb => shared}/cdbsymbolpathlisteditor.h (80%) diff --git a/src/plugins/debugger/cdb/cdb.pri b/src/plugins/debugger/cdb/cdb.pri index d0901fec591..59652c3856a 100644 --- a/src/plugins/debugger/cdb/cdb.pri +++ b/src/plugins/debugger/cdb/cdb.pri @@ -16,7 +16,6 @@ HEADERS += \ $$PWD/cdboptions.h \ $$PWD/cdboptionspage.h \ $$PWD/cdbdumperhelper.h \ - $$PWD/cdbsymbolpathlisteditor.h \ $$PWD/cdbexceptionutils.h SOURCES += \ @@ -31,7 +30,6 @@ SOURCES += \ $$PWD/cdboptions.cpp \ $$PWD/cdboptionspage.cpp \ $$PWD/cdbdumperhelper.cpp \ - $$PWD/cdbsymbolpathlisteditor.cpp \ $$PWD/cdbexceptionutils.cpp FORMS += $$PWD/cdboptionspagewidget.ui diff --git a/src/plugins/debugger/cdb/cdboptions.cpp b/src/plugins/debugger/cdb/cdboptions.cpp index 0f7e19945d0..a589b8adfa8 100644 --- a/src/plugins/debugger/cdb/cdboptions.cpp +++ b/src/plugins/debugger/cdb/cdboptions.cpp @@ -29,6 +29,7 @@ #include "cdboptions.h" #include "coreengine.h" +#include "cdbsymbolpathlisteditor.h" #include <QtCore/QSettings> #include <QtCore/QDir> @@ -117,36 +118,14 @@ unsigned CdbOptions::compare(const CdbOptions &rhs) const return rc; } -static const char symbolServerPrefixC[] = "symsrv*symsrv.dll*"; -static const char symbolServerPostfixC[] = "*http://msdl.microsoft.com/download/symbols"; - QString CdbOptions::symbolServerPath(const QString &cacheDir) { - QString s = QLatin1String(symbolServerPrefixC); - s += QDir::toNativeSeparators(cacheDir); - s += QLatin1String(symbolServerPostfixC); - return s; -} - -bool CdbOptions::isSymbolServerPath(const QString &path, QString *cacheDir /* = 0 */) -{ - // Split apart symbol server post/prefixes - if (!path.startsWith(QLatin1String(symbolServerPrefixC)) || !path.endsWith(QLatin1String(symbolServerPostfixC))) - return false; - if (cacheDir) { - const unsigned prefixLength = qstrlen(symbolServerPrefixC); - *cacheDir = path.mid(prefixLength, path.size() - prefixLength - qstrlen(symbolServerPostfixC)); - } - return true; + return CdbSymbolPathListEditor::symbolServerPath(cacheDir); } -int CdbOptions::indexOfSymbolServerPath(const QStringList &paths, QString *cacheDir /* = 0 */) +int CdbOptions::indexOfSymbolServerPath(const QStringList &symbolPaths, QString *cacheDir) { - const int count = paths.size(); - for (int i = 0; i < count; i++) - if (CdbOptions::isSymbolServerPath(paths.at(i), cacheDir)) - return i; - return -1; + return CdbSymbolPathListEditor::indexOfSymbolServerPath(symbolPaths, cacheDir); } } // namespace Internal diff --git a/src/plugins/debugger/cdb/cdboptions.h b/src/plugins/debugger/cdb/cdboptions.h index 34db9ee1b8f..aa9995dda1e 100644 --- a/src/plugins/debugger/cdb/cdboptions.h +++ b/src/plugins/debugger/cdb/cdboptions.h @@ -60,7 +60,6 @@ public: // Format a symbol server specification with a cache directory static QString symbolServerPath(const QString &cacheDir); // Check whether the path is a symbol server specification and return the cache directory - static bool isSymbolServerPath(const QString &symbolPath, QString *cacheDir = 0); static int indexOfSymbolServerPath(const QStringList &symbolPaths, QString *cacheDir = 0); static QString settingsGroup(); diff --git a/src/plugins/debugger/cdb/cdbsymbolpathlisteditor.cpp b/src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp similarity index 75% rename from src/plugins/debugger/cdb/cdbsymbolpathlisteditor.cpp rename to src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp index a3fc68922aa..be283bf260b 100644 --- a/src/plugins/debugger/cdb/cdbsymbolpathlisteditor.cpp +++ b/src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp @@ -28,7 +28,6 @@ **************************************************************************/ #include "cdbsymbolpathlisteditor.h" -#include "cdboptions.h" #include <utils/pathchooser.h> @@ -105,6 +104,11 @@ void CacheDirectoryDialog::accept() QDialog::accept(); } +// ---------------- CdbSymbolPathListEditor + +const char *CdbSymbolPathListEditor::symbolServerPrefixC = "symsrv*symsrv.dll*"; +const char *CdbSymbolPathListEditor::symbolServerPostfixC = "*http://msdl.microsoft.com/download/symbols"; + CdbSymbolPathListEditor::CdbSymbolPathListEditor(QWidget *parent) : Utils::PathListEditor(parent) { @@ -127,7 +131,36 @@ void CdbSymbolPathListEditor::addSymbolServer() { const QString cacheDir = promptCacheDirectory(this); if (!cacheDir.isEmpty()) - insertPathAtCursor(CdbOptions::symbolServerPath(cacheDir)); + insertPathAtCursor(CdbSymbolPathListEditor::symbolServerPath(cacheDir)); +} + +QString CdbSymbolPathListEditor::symbolServerPath(const QString &cacheDir) +{ + QString s = QLatin1String(symbolServerPrefixC); + s += QDir::toNativeSeparators(cacheDir); + s += QLatin1String(symbolServerPostfixC); + return s; +} + +bool CdbSymbolPathListEditor::isSymbolServerPath(const QString &path, QString *cacheDir /* = 0 */) +{ + // Split apart symbol server post/prefixes + if (!path.startsWith(QLatin1String(symbolServerPrefixC)) || !path.endsWith(QLatin1String(symbolServerPostfixC))) + return false; + if (cacheDir) { + const unsigned prefixLength = qstrlen(symbolServerPrefixC); + *cacheDir = path.mid(prefixLength, path.size() - prefixLength - qstrlen(symbolServerPostfixC)); + } + return true; +} + +int CdbSymbolPathListEditor::indexOfSymbolServerPath(const QStringList &paths, QString *cacheDir /* = 0 */) +{ + const int count = paths.size(); + for (int i = 0; i < count; i++) + if (CdbSymbolPathListEditor::isSymbolServerPath(paths.at(i), cacheDir)) + return i; + return -1; } } // namespace Internal diff --git a/src/plugins/debugger/cdb/cdbsymbolpathlisteditor.h b/src/plugins/debugger/shared/cdbsymbolpathlisteditor.h similarity index 80% rename from src/plugins/debugger/cdb/cdbsymbolpathlisteditor.h rename to src/plugins/debugger/shared/cdbsymbolpathlisteditor.h index 9152762fcb0..f8c5bb04b7a 100644 --- a/src/plugins/debugger/cdb/cdbsymbolpathlisteditor.h +++ b/src/plugins/debugger/shared/cdbsymbolpathlisteditor.h @@ -75,6 +75,17 @@ public: static QString promptCacheDirectory(QWidget *parent); + // Pre- and Postfix used to build a symbol server path specification + static const char *symbolServerPrefixC; + static const char *symbolServerPostfixC; + + // Format a symbol server specification with a local cache directory + static QString symbolServerPath(const QString &cacheDir); + // Check for a symbol server path and extract local cache directory + static bool isSymbolServerPath(const QString &path, QString *cacheDir = 0); + // Check for symbol server in list of paths. + static int indexOfSymbolServerPath(const QStringList &paths, QString *cacheDir = 0); + private slots: void addSymbolServer(); }; diff --git a/src/plugins/debugger/shared/shared.pri b/src/plugins/debugger/shared/shared.pri index 760b012a447..2dd20da9fe9 100644 --- a/src/plugins/debugger/shared/shared.pri +++ b/src/plugins/debugger/shared/shared.pri @@ -1,7 +1,10 @@ -SOURCES += $$PWD/backtrace.cpp -HEADERS += $$PWD/backtrace.h +SOURCES += $$PWD/backtrace.cpp \ + $$PWD/cdbsymbolpathlisteditor.cpp + +HEADERS += $$PWD/backtrace.h \ + $$PWD/cdbsymbolpathlisteditor.h win32 { -- GitLab