From 75675c88ae94ac83678cc84728ea3c6643e32706 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 1 Jun 2011 17:01:47 +0200 Subject: [PATCH] Debugger[CDB]: Add version number to QtInfo struct in ext lib. Run in a loop over qtVersion =4,5 when detecting the Qt modules (quick detection). Add version field for later evaluation in dumpers. Reformat comments. Change-Id: Ia3005fccbb92b847a0f1feef99a53eb4c318246f Reviewed-on: http://codereview.qt.nokia.com/313 Reviewed-by: Qt Sanity Bot Reviewed-by: Friedemann Kleint --- src/libs/qtcreatorcdbext/symbolgroupvalue.cpp | 62 +++++++++++-------- src/libs/qtcreatorcdbext/symbolgroupvalue.h | 3 + 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp b/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp index 76a4977e47d..86f5386d84c 100644 --- a/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp +++ b/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp @@ -552,11 +552,13 @@ std::string SymbolGroupValue::pointedToSymbolName(ULONG64 address, const std::st * as 'QtCored4![namespace::]qstrdup'. In the event someone really uses a different * library prefix or namespaced Qt, this should be found. * The crux is here that the underlying IDebugSymbols::StartSymbolMatch() - * does not accept module wildcards (as opposed to the 'x' command where 'x QtCo*!*qstrdup' - * would be acceptable and fast). OTOH, doing a wildcard search like '*qstrdup' is - * very slow and should be done only if there is really a different namespace or lib prefix. - * Parameter 'modulePatternC' is used to do a search on the modules returned (due to - * the amiguities and artifacts that appear like 'QGuid4!qstrdup'). */ + * does not accept module wildcards (as opposed to the 'x' command where + * 'x QtCo*!*qstrdup' would be acceptable and fast). OTOH, doing a wildcard search + * like '*qstrdup' is very slow and should be done only if there is really a + * different namespace or lib prefix. + * Parameter 'modulePatternC' is used to do a search on the modules returned + * (due to the amiguities and artifacts that appear like 'QGuid4!qstrdup'). */ + static inline std::string resolveQtSymbol(const char *symbolC, const char *defaultModuleNameC, const char *modulePatternC, @@ -569,19 +571,22 @@ static inline std::string resolveQtSymbol(const char *symbolC, if (debugResolveQtSymbol) DebugPrint() << ">resolveQtSymbol" << symbolC << " def=" << defaultModuleNameC << " defModName=" << defaultModuleNameC << " modPattern=" << modulePatternC; - // First try a match with the default module name 'QtCored4!qstrdup' for speed reasons - std::string defaultPattern = defaultModuleNameC; - defaultPattern.push_back('!'); - defaultPattern += symbolC; - const StringList defaultMatches = SymbolGroupValue::resolveSymbolName(defaultPattern.c_str(), ctx); - if (debugResolveQtSymbol) - DebugPrint() << "resolveQtSymbol: defaultMatches=" << DebugSequence(defaultMatches.begin(), defaultMatches.end()); const SubStringPredicate modulePattern(modulePatternC); - const StringListConstIt defaultIt = std::find_if(defaultMatches.begin(), defaultMatches.end(), modulePattern); - if (defaultIt != defaultMatches.end()) { + // First try a match with the default module name 'QtCored4!qstrdup' for speed reasons + for (int qtVersion = 4; qtVersion < 6; qtVersion++) { + std::ostringstream str; + str << defaultModuleNameC << qtVersion << '!' << symbolC; + const std::string defaultPattern = str.str(); + const StringList defaultMatches = SymbolGroupValue::resolveSymbolName(defaultPattern.c_str(), ctx); if (debugResolveQtSymbol) - DebugPrint() << "d4' rc.guiModule = rc.coreModule; rc.guiModule.replace(0, 6, "QtGui"); @@ -679,9 +687,11 @@ std::string QtInfo::prependModuleAndNameSpace(const std::string &type, std::ostream &operator<<(std::ostream &os, const QtInfo &i) { - os << "Qt Info: Modules '" << i.coreModule << "', '" << i.guiModule + os << "Qt Info: Version: " << i.version << " Modules '" + << i.coreModule << "', '" << i.guiModule << "', Namespace='" << i.nameSpace - << "', types: " << i.qObjectType << ',' << i.qObjectPrivateType << ',' << i.qWidgetPrivateType; + << "', types: " << i.qObjectType << ',' + << i.qObjectPrivateType << ',' << i.qWidgetPrivateType; return os; } diff --git a/src/libs/qtcreatorcdbext/symbolgroupvalue.h b/src/libs/qtcreatorcdbext/symbolgroupvalue.h index 964e5e16924..d31ff7f81f3 100644 --- a/src/libs/qtcreatorcdbext/symbolgroupvalue.h +++ b/src/libs/qtcreatorcdbext/symbolgroupvalue.h @@ -169,6 +169,8 @@ std::ostream &operator<<(std::ostream &, const SymbolGroupValue &v); struct QtInfo { + QtInfo() : version(0) {} + static const QtInfo &get(const SymbolGroupValueContext &ctx); // Prepend core module and Qt namespace. To be able to work with some @@ -188,6 +190,7 @@ struct QtInfo const std::string &module, const std::string &nameSpace); + int version; std::string nameSpace; std::string coreModule; std::string guiModule;