Commit ab92c14b authored by hjk's avatar hjk

Debugger: Fix std::complex dumper for LLDB

Change-Id: I5ffb0f60039bb05f8467e925e71cf710a0712791
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 6c673a04
......@@ -1215,7 +1215,14 @@ class Dumper(DumperBase):
return toInteger(value.address)
def createPointerValue(self, address, pointeeType):
return gdb.Value(address).cast(pointeeType.pointer())
# This might not always work:
# a Python 3 based GDB due to the bug addressed in
# https://sourceware.org/ml/gdb-patches/2013-09/msg00571.html
try:
return gdb.Value(address).cast(pointeeType.pointer())
except:
# Try _some_ fallback (good enough for the std::complex dumper)
return gdb.parse_and_eval("(%s*)%s" % (pointeeType, address))
def intSize(self):
return 4
......@@ -1227,7 +1234,11 @@ class Dumper(DumperBase):
return self.lookupType('void*').sizeof == 4
def createValue(self, address, referencedType):
return gdb.Value(address).cast(referencedType.pointer()).dereference()
try:
return gdb.Value(address).cast(referencedType.pointer()).dereference()
except:
# Try _some_ fallback (good enough for the std::complex dumper)
return gdb.parse_and_eval("{%s}%s" % (referencedType, address))
def readRawMemory(self, addr, size):
mem = gdb.selected_inferior().read_memory(addr, size)
......
......@@ -79,9 +79,8 @@ def qdump__std____1__array(d, value):
def qdump__std__complex(d, value):
innerType = d.templateArgument(value.type, 0)
base = value.address.cast(innerType.pointer())
real = base.dereference()
imag = (base + 1).dereference()
real = value.cast(innerType)
imag = d.createValue(d.addressOf(value) + innerType.sizeof, innerType)
d.putValue("(%f, %f)" % (real, imag));
d.putNumChild(2)
if d.isExpanded():
......
......@@ -2469,8 +2469,10 @@ void tst_Dumpers::dumper_data()
QTest::newRow("StdComplex")
<< Data("#include <complex>\n",
"std::complex<double> c(1, 2);\n")
% Check("c", "(1.000000, 2.000000)", "std::complex<double>");
"std::complex<double> c(1, 2);\n"
"unused(&c);\n")
% Check("c", "(1.000000, 2.000000)", "std::complex<double>")
% CheckType("c.real", "double");
QTest::newRow("CComplexGdb")
<< Data("#include <complex.h>\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment