diff --git a/src/plugins/debugger/cdb/cdb.pri b/src/plugins/debugger/cdb/cdb.pri index d0901fec591a415219bfa4479b19ddd908725a0d..59652c3856a60598fdd30005c47c4dc3f6bbae35 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 0f7e19945d0140f520b8d7c507f683917f45cc46..a589b8adfa8edfa433b2800cb7276c365201636a 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 34db9ee1b8f1dc2f8c4297f8050057380e75ae51..aa9995dda1e01909f93ada4ed00410f159fd6b12 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 a3fc68922aaf3a3e723d10cdbeb827d1f3155006..be283bf260b38088c38226cb449dd72e0fd4c7c9 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 9152762fcb031a40fa4de720f4331f581f540c36..f8c5bb04b7a9235b61a2ee2aa174603fe36666bd 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 760b012a447ee4638fbd917b23150998504b059f..2dd20da9fe98f966adf60cefe9973a045d52eb76 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 {