Commit bf9a3b20 authored by hjk's avatar hjk
Browse files

Debugger: Fix LLDB reference display for LLDB 320.x



There is seemingly still no proper API for that, and
the old hack broke. Use a new one.

Change-Id: I9e638ca1fbd84c43c7d31b65e017792d1b6a1e0b
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 55a6050f
......@@ -920,7 +920,6 @@ class Dumper(DumperBase):
return False
def putItem(self, value, tryDynamic=True):
#value = value.GetDynamicValue(lldb.eDynamicCanRunTarget)
typeName = value.GetType().GetUnqualifiedType().GetName()
if self.isGoodLldb:
value.SetPreferDynamicValue(tryDynamic)
......@@ -965,10 +964,11 @@ class Dumper(DumperBase):
realType = value.GetType()
if hasattr(realType, 'GetCanonicalType'):
baseType = realType.GetCanonicalType()
baseValue = value.Cast(baseType.unqualified())
self.putItem(baseValue)
self.putBetterType(realType)
return
if baseType != realType:
baseValue = value.Cast(baseType.unqualified())
self.putItem(baseValue)
self.putBetterType(realType)
return
# Our turf now.
if self.isGoodLldb:
......@@ -986,11 +986,24 @@ class Dumper(DumperBase):
# References
if value.GetType().IsReferenceType():
origType = value.GetTypeName();
type = value.GetType().GetDereferencedType().unqualified()
addr = value.GetLoadAddress()
self.putItem(value.CreateValueFromAddress(None, addr, type))
self.putBetterType(origType)
addr = value.GetValueAsUnsigned()
#warn("FROM: %s" % value)
#warn("ADDR: 0x%x" % addr)
#warn("TYPE: %s" % type)
# Works:
#item = self.currentThread().GetSelectedFrame().EvaluateExpression(
# "(%s*)0x%x" % (type, addr)).Dereference()
# Works:
item = value.CreateValueFromExpression(None,
"(%s*)0x%x" % (type, addr), lldb.SBExpressionOptions()).Dereference()
# Does not work:
#item = value.CreateValueFromAddress(None, addr, type)
# Does not work:
#item = value.Cast(type.GetPointerType()).Dereference()
#warn("TOOO: %s" % item)
self.putItem(item)
self.putBetterType(value.GetTypeName())
return
# Pointers
......@@ -1534,7 +1547,6 @@ class Dumper(DumperBase):
def selectThread(self, args):
self.process.SetSelectedThreadByID(args['id'])
self.reportData()
self.reportStack()
def requestModuleSymbols(self, frame):
self.handleCommand("target module list " + frame)
......
......@@ -1441,7 +1441,10 @@ void tst_Dumpers::dumper_data()
"public:\n"
" Foo(int i = 0)\n"
" : a(i), b(2)\n"
" {}\n"
" {\n"
" for (int j = 0; j < 6; ++j)\n"
" x[j] = 'a' + j;\n"
" }\n"
" virtual ~Foo()\n"
" {\n"
" a = 5;\n"
......@@ -4845,12 +4848,12 @@ void tst_Dumpers::dumper_data()
QTest::newRow("Reference")
<< Data(fooData +
"#include <string>\n"
<< Data("#include <string>\n"
"#include <QString>\n"
"using namespace std;\n"
"string fooxx() { return \"bababa\"; }\n",
"string fooxx() { return \"bababa\"; }\n"
+ fooData,
"int a1 = 43;\n"
"const int &b1 = a1;\n"
......@@ -4888,7 +4891,7 @@ void tst_Dumpers::dumper_data()
+ Check("a2", "\"hello\"", "std::string")
+ Check("b2", "\"bababa\"", Pattern("(std::)?string &")) // Clang...
+ Check("c2", "\"world\"", "std::string")
+ Check("d2", "\"hello\"", "Ref2")
+ Check("d2", "\"hello\"", "Ref2") % NoLldbEngine
+ Check("a3", "\"hello\"", "@QString")
+ Check("b3", "\"hello\"", "@QString &")
......@@ -4901,7 +4904,6 @@ void tst_Dumpers::dumper_data()
//+ Check("d4", "\"hello\"", "Ref4"); FIXME: We get "Foo &" instead
+ Check("d4.a", "12", "int");
QTest::newRow("DynamicReference")
<< Data("struct BaseClass { virtual ~BaseClass() {} };\n"
"struct DerivedClass : BaseClass {};\n",
......
Supports Markdown
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