OSDN Git Service

debugger: show cdb vtable pointer in hex
authorhjk <qtc-committer@nokia.com>
Mon, 11 Jul 2011 09:19:29 +0000 (11:19 +0200)
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>
Mon, 11 Jul 2011 10:33:15 +0000 (12:33 +0200)
Change-Id: I8deb537ce837e54315b0f0a64897363f70344137
Reviewed-by: Friedemann Kleint
Task-number: QTCREATORBUG-5381
Reviewed-on: http://codereview.qt.nokia.com/1405
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
src/libs/qtcreatorcdbext/symbolgroupnode.cpp
src/libs/qtcreatorcdbext/symbolgroupvalue.cpp
src/libs/qtcreatorcdbext/symbolgroupvalue.h
src/plugins/debugger/watchdata.cpp
src/plugins/debugger/watchhandler.cpp
src/plugins/debugger/watchutils.h

index f5f6eda..631c53e 100644 (file)
@@ -762,6 +762,14 @@ static void fixValue(const std::string &type, std::wstring *value)
         }
     }
 
+    // Strip a vtable "0x13f37b7c8 module!Class::`vftable'" to a plain pointer.
+    if (SymbolGroupValue::isVTableType(type)) {
+        const std::wstring::size_type blankPos = value->find(L' ', 2);
+        if (blankPos != std::wstring::npos)
+            value->erase(blankPos, value->size() - blankPos);
+        return;
+    }
+
     // Pointers: fix '0x00000000`00000AD class bla' ... to "0xAD", but leave
     // 'const char *' values as is ('0x00000000`00000AD "hallo").
     if (!type.empty() && type.at(type.size() - 1) == L'*') {
index 86f5386..22cda17 100644 (file)
@@ -417,6 +417,13 @@ unsigned SymbolGroupValue::isPointerType(const std::string &t)
     return 0;
 }
 
+// Return number of characters to strip for pointer type
+bool SymbolGroupValue::isVTableType(const std::string &t)
+{
+    const char vtableTypeC[] = "__fptr() [";
+    return t.compare(0, sizeof(vtableTypeC) - 1, vtableTypeC) == 0;
+}
+
 // add pointer type 'Foo' -> 'Foo *', 'Foo *' -> 'Foo **'
 std::string SymbolGroupValue::pointerType(const std::string &type)
 {
index d31ff7f..7e8c433 100644 (file)
@@ -113,6 +113,7 @@ public:
     static std::string moduleOfType(const std::string &type);
     // pointer type, return number of characters to strip
     static unsigned isPointerType(const std::string &);
+    static bool isVTableType(const std::string &t);
     // add pointer type 'Foo' -> 'Foo *', 'Foo *' -> 'Foo **'
     static std::string pointerType(const std::string &type);
     // Symbol Name/(Expression) of a pointed-to instance ('Foo' at 0x10') ==> '*(Foo *)0x10'
index 72da172..242eaf1 100644 (file)
@@ -68,6 +68,13 @@ bool isPointerType(const QByteArray &type)
     return type.endsWith('*') || type.endsWith("* const");
 }
 
+bool isVTablePointer(const QByteArray &type)
+{
+    // FIXME: That is cdb only.
+    // But no user type can be named like this, so this is safe.
+    return type.startsWith("__fptr()");
+}
+
 bool isCharPointerType(const QByteArray &type)
 {
     return type == "char *" || type == "const char *" || type == "char const *";
index 4b442f9..02c1152 100644 (file)
@@ -371,7 +371,7 @@ static inline QString formattedValue(const WatchData &data, int format)
         return reformatInteger(data.value.toLongLong(), format);
     }
 
-    if (!isPointerType(data.type)) {
+    if (!isPointerType(data.type) && !isVTablePointer(data.type)) {
         bool ok = false;
         qulonglong integer = data.value.toULongLong(&ok, 0);
         if (ok)
index 37ce016..b120c49 100644 (file)
@@ -81,6 +81,7 @@ bool hasLetterOrNumber(const QString &exp);
 bool hasSideEffects(const QString &exp);
 bool isKeyWord(const QString &exp);
 bool isPointerType(const QByteArray &type);
+bool isVTablePointer(const QByteArray &type);
 bool isCharPointerType(const QByteArray &type);
 bool startsWithDigit(const QString &str);
 QByteArray stripPointerType(QByteArray type);