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>
This commit is contained in:
hjk
2017-04-25 18:01:26 +02:00
parent 1ee59f1879
commit 81d9315587
4 changed files with 50 additions and 1 deletions
+7
View File
@@ -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