summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2017-04-25 18:01:26 +0200
committerhjk <hjk@qt.io>2017-04-26 09:23:18 +0000
commit81d931558762866d1b60ae59a408a3be9e32b131 (patch)
tree4e592805ecd3db406eb620eab297bc8e37e0d34e
parent1ee59f187983bd3f13dd697e8e7259643b57e9f7 (diff)
downloadqt-creator-81d931558762866d1b60ae59a408a3be9e32b131.tar.gz
Debugger: Add a boost::variant dumper
This requires making template argument extraction a bit more robust GCC 5.4.1 created debug info only reports the first argument for boost::variant<int, bool>: #include <boost/variant/variant.hpp int main() { boost::variant<int, float> v = 1; return 0; } py print(gdb.parse_and_eval('v').type) -> boost::variant<int, float> py print(gdb.parse_and_eval('v').type.template_argument(0)) -> int py print(gdb.parse_and_eval('v').type.template_argument(1)) -> Traceback (most recent call last): File \"<string>\", line 1, in <module> RuntimeError: No argument 1 in template. Error while executing Python code. Change-Id: Iedca8b073078c93449ab61bb2cab05d6cd9803ba Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--share/qtcreator/debugger/boosttypes.py9
-rw-r--r--share/qtcreator/debugger/dumper.py7
-rw-r--r--share/qtcreator/debugger/gdbbridge.py3
-rw-r--r--tests/auto/debugger/tst_dumpers.cpp32
4 files changed, 50 insertions, 1 deletions
diff --git a/share/qtcreator/debugger/boosttypes.py b/share/qtcreator/debugger/boosttypes.py
index ccd88b3864..e61d1e4bb8 100644
--- a/share/qtcreator/debugger/boosttypes.py
+++ b/share/qtcreator/debugger/boosttypes.py
@@ -140,3 +140,12 @@ def qdump__boost__unordered__unordered_set(d, value):
yield val
p = d.extractPointer(buckets + bucketCount * d.ptrSize())
d.putItems(size, children(p), maxNumChild = 10000)
+
+
+def qdump__boost__variant(d, value):
+ allTypes = value.type.templateArguments()
+ realType = allTypes[value.split('i')[0]]
+ alignment = max([t.alignment() for t in allTypes])
+ dummy, val = value.split('%is{%s}' % (max(4, alignment), realType.name))
+ d.putItem(val)
+ d.putBetterType(value.type)
diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py
index c03f07d9e9..663015e77d 100644
--- a/share/qtcreator/debugger/dumper.py
+++ b/share/qtcreator/debugger/dumper.py
@@ -522,6 +522,9 @@ class DumperBase:
return baseType # Override in backends.
def listTemplateParameters(self, typename):
+ return self.listTemplateParametersManually(typename)
+
+ def listTemplateParametersManually(self, typename):
targs = []
if not typename.endswith('>'):
return targs
@@ -573,6 +576,10 @@ class DumperBase:
if item.find('.') > -1:
res.append(float(item))
else:
+ if item.endswith('l'):
+ item = item[:-1]
+ if item.endswith('u'):
+ item = item[:-1]
val = toInteger(item)
if val > 0x80000000:
val -= 0x100000000
diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py
index 70c8beaad4..90b76ef61a 100644
--- a/share/qtcreator/debugger/gdbbridge.py
+++ b/share/qtcreator/debugger/gdbbridge.py
@@ -382,7 +382,8 @@ class Dumper(DumperBase):
else:
error('UNKNOWN TEMPLATE PARAMETER')
pos += 1
- return targs
+ targs2 = self.listTemplateParametersManually(str(nativeType))
+ return targs if len(targs) >= len(targs2) else targs2
def nativeTypeEnumDisplay(self, nativeType, intval):
try:
diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp
index 650109a598..3badbb487c 100644
--- a/tests/auto/debugger/tst_dumpers.cpp
+++ b/tests/auto/debugger/tst_dumpers.cpp
@@ -5944,6 +5944,38 @@ void tst_Dumpers::dumper_data()
+ Check("s2.0", "[0]", "\"def\"", "std::string") % BoostVersion(1 * 100000 + 54 * 100)
+ Check("s2.1", "[1]", "\"abc\"", "std::string") % BoostVersion(1 * 100000 + 54 * 100);
+#ifdef Q_OS_LINUX
+ QTest::newRow("BoostVariant")
+ << Data("#include <boost/variant/variant.hpp>\n"
+ "#include <string>\n",
+
+ "boost::variant<char, short> ch1 = char(1);\n"
+ "boost::variant<char, short> ch2 = short(2);\n"
+
+ "boost::variant<int, float> if1 = int(1);\n"
+ "boost::variant<int, float> if2 = float(2);\n"
+
+ "boost::variant<int, double> id1 = int(1);\n"
+ "boost::variant<int, double> id2 = double(2);\n"
+
+ "boost::variant<int, std::string> is1 = int(1);\n"
+ "boost::variant<int, std::string> is2 = std::string(\"sss\");\n")
+
+ + BoostProfile()
+
+ + Check("ch1", "1", TypePattern("boost::variant<char, short.*>"))
+ + Check("ch2", "2", TypePattern("boost::variant<char, short.*>"))
+
+ + Check("if1", "1", TypePattern("boost::variant<int, float.*>"))
+ + Check("if2", FloatValue("2"), TypePattern("boost::variant<int, float.*>"))
+
+ + Check("id1", "1", TypePattern("boost::variant<int, double.*>"))
+ + Check("id2", FloatValue("2"), TypePattern("boost::variant<int, double.*>"))
+
+ + Check("is1", "1", TypePattern("boost::variant<int, std::.*>"))
+ + Check("is2", "\"sss\"", TypePattern("boost::variant<int, std::.*>"));
+#endif
+
QTest::newRow("Eigen")
<< Data("#ifdef HAS_EIGEN\n"