Commit 9040c408 authored by hjk's avatar hjk

Debugger: Use less GDB inferior calls in normal field extraction

They are not usable in core files.

Change-Id: I2134b61f27c27862c12a679d0acf7bebc9fcc7a2
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarhjk <hjk@qt.io>
parent ffe30552
This diff is collapsed.
This diff is collapsed.
......@@ -225,17 +225,11 @@ class Dumper(DumperBase):
return align
def listMembers(self, nativeType, value):
if value.laddress is not None:
sbaddr = lldb.SBAddress(value.laddress, self.target)
nativeValue = self.target.CreateValueFromAddress('x', sbaddr, nativeType)
else:
try:
nativeValue = self.target.CreateValueFromData('x', value.data(), nativeType)
except:
return
nativeValue.SetPreferSyntheticValue(False)
nativeType = nativeValue.GetType()
#warn("ADDR: 0x%x" % self.fakeAddress)
fakeAddress = self.fakeAddress if value.laddress is None else value.laddress
sbaddr = lldb.SBAddress(fakeAddress, self.target)
fakeValue = self.target.CreateValueFromAddress('x', sbaddr, nativeType)
fakeValue.SetPreferSyntheticValue(False)
baseNames = {}
for i in range(nativeType.GetNumberOfDirectBaseClasses()):
......@@ -253,25 +247,44 @@ class Dumper(DumperBase):
if bitsize > 0:
#bitpos = bitpos % bitsize
bitpos = bitpos % 8 # Reported type is always wrapping type!
#warn("BIT SIZE: %s POS: %s NAME: %s" % (bitsize, bitpos, f.name))
fieldBits[f.name] = (bitsize, bitpos)
# Normal members and non-empty base classes.
for i in range(nativeValue.GetNumChildren()):
fieldObj = nativeValue.GetChildAtIndex(i)
fieldObj.SetPreferSyntheticValue(False)
fieldName = fieldObj.GetName()
member = self.fromNativeValue(fieldObj)
member.name = fieldName
if fieldName in baseNames:
member.isBaseClass = True
if fieldName in fieldBits:
(member.lbitsize, member.lbitpos) = fieldBits[fieldName]
for i in range(fakeValue.GetNumChildren()):
nativeField = fakeValue.GetChildAtIndex(i)
nativeField.SetPreferSyntheticValue(False)
field = self.Field(self)
field.name = nativeField.GetName()
nativeFieldType = nativeField.GetType()
if field.name in fieldBits:
(field.lbitsize, field.lbitpos) = fieldBits[field.name]
else:
member.lbitsize = fieldObj.GetType().GetByteSize() * 8
#member.lbitpos = (caddr - addr) * 8
#warn("MEMBER: %s" % member)
yield member
field.lbitsize = nativeFieldType.GetByteSize() * 8
if field.lbitsize != nativeFieldType.GetByteSize() * 8:
field.ltype = self.createBitfieldType(self.typeName(nativeFieldType), field.lbitsize)
else:
fakeMember = fakeValue.GetChildAtIndex(i)
#try:
fakeMemberAddress = fakeMember.GetLoadAddress()
#except:
# # Happens in the BoostList dumper for a 'const bool'
# # item named 'constant_time_size'. There isn't anything we can do
# # in this case.
# continue
offset = fakeMemberAddress - fakeAddress
field.lbitpos = 8 * offset
field.ltype = self.fromNativeType(nativeFieldType)
if field.name in baseNames:
field.isBaseClass = True
field.baseIndex = baseNames[field.name]
yield field
# Empty bases are not covered above.
for i in range(nativeType.GetNumberOfDirectBaseClasses()):
......@@ -357,10 +370,7 @@ class Dumper(DumperBase):
return self.createTypedefedType(targetType, nativeType.GetName())
nativeType = nativeType.GetUnqualifiedType()
if hasattr(nativeType, 'GetDisplayTypeName'):
typeName = nativeType.GetDisplayTypeName() # Xcode 6 (lldb-320)
else:
typeName = nativeType.GetName() # Xcode 5 (lldb-310)
typeName = self.typeName(nativeType)
if code in (lldb.eTypeClassArray, lldb.eTypeClassVector):
#warn('ARRAY: %s' % nativeType.GetName())
......@@ -480,11 +490,16 @@ class Dumper(DumperBase):
#warn('TARGS: %s %s' % (nativeType.GetName(), [str(x) for x in targs]))
return targs
def nativeTypeId(self, nativeType):
def typeName(self, nativeType):
if hasattr(nativeType, 'GetDisplayTypeName'):
name = nativeType.GetDisplayTypeName() # Xcode 6 (lldb-320)
else:
name = nativeType.GetName() # Xcode 5 (lldb-310)
return nativeType.GetDisplayTypeName() # Xcode 6 (lldb-320)
return nativeType.GetName() # Xcode 5 (lldb-310)
def nativeTypeId(self, nativeType):
name = self.typeName(nativeType)
def nativeTypeId(self, nativeType):
name = self.typeName(nativeType)
if name is None or len(name) == 0:
c = '0'
elif name == '(anonymous struct)' and nativeType.GetTypeClass() == lldb.eTypeClassStruct:
......@@ -1048,6 +1063,10 @@ class Dumper(DumperBase):
self.setVariableFetchingOptions(args)
anyModule = self.target.GetModuleAtIndex(0)
anySymbol = anyModule.GetSymbolAtIndex(0)
self.fakeAddress = int(anySymbol.GetStartAddress())
frame = self.currentFrame()
if frame is None:
self.reportResult('error="No frame"', args)
......
......@@ -1632,6 +1632,7 @@ def qdump__QVariant(d, value):
else:
#warn('DIRECT ITEM 1: %s' % innerType)
val = d.createValue(data, innerType)
val.laddress = value.laddress
d.putEmptyValue(-99)
d.putItem(val)
......
......@@ -1374,7 +1374,7 @@ void tst_Dumpers::dumper()
"python theDumper.fetchVariables({"
"'token':2,'fancy':1,'forcens':1,"
"'autoderef':1,'dyntype':1,'passexceptions':1,"
"'qobjectnames':1,"
"'testing':1,'qobjectnames':1,"
"'expanded':[" + expandedq + "]})\n";
cmds += "quit\n";
......@@ -1398,7 +1398,7 @@ void tst_Dumpers::dumper()
"!qtcreatorcdbext.script -t 42 theDumper.fetchVariables({"
"'token':2,'fancy':1,'forcens':1,"
"'autoderef':1,'dyntype':1,'passexceptions':0,"
"'qobjectnames':1,"
"'testing':1,'qobjectnames':1,"
"'expanded':[" + expandedq + "]})\n"
"q\n";
} else if (m_debuggerEngine == LldbEngine) {
......@@ -1413,7 +1413,7 @@ void tst_Dumpers::dumper()
// "sc print(dir())\n"
"sc Tester('" + t->buildPath.toLatin1() + "/doit', {'fancy':1,'forcens':1,"
"'autoderef':1,'dyntype':1,'passexceptions':1,"
"'qobjectnames':1,"
"'testing':1,'qobjectnames':1,"
"'expanded':[" + expandedq + "]})\n"
"quit\n";
......@@ -5943,7 +5943,12 @@ void tst_Dumpers::dumper_data()
" { T1() : i1(1) {} int i1; };\n"
"struct T2 : virtual VEmpty, virtual VData\n"
" { T2() : i2(1) {} int i2; };\n"
"struct TT : T1, T2 { TT() : c(1) {} int c; };\n";
"struct TT : T1, T2 { TT() : c(1) {} int c; };\n"
"struct A { int a = 1; char aa = 'a'; };\n"
"struct B : virtual A { int b = 2; float bb = 2; };\n"
"struct C : virtual A { int c = 3; double cc = 3; };\n"
"struct D : virtual B, virtual C { int d = 4; };\n";
QTest::newRow("Inheritance")
<< Data(inheritanceData,
......@@ -5956,7 +5961,11 @@ void tst_Dumpers::dumper_data()
"TT tt;\n"
"tt.T1::v = 44;\n"
"tt.T2::v = 45;\n"
"unused(&tt.T2::v);\n")
"unused(&tt.T2::v);\n"
"D dd; unused(&dd);\n"
"D *dp = new D; unused(&dp);\n"
"D &dr = dd; unused(&dr);\n")
+ Cxx11Profile()
+ Check("c.c", "1", "int")
+ Check("c.@1.@2.a", "42", "int") % NoLldbEngine
+ Check("c.@1.@4.v", "45", "int") % NoLldbEngine
......@@ -5970,7 +5979,26 @@ void tst_Dumpers::dumper_data()
+ Check("tt.@1.@2.v", "45", "int") % NoLldbEngine
+ Check("tt.@2.@2.v", "45", "int") % NoLldbEngine
+ Check("tt.@1.@1.v", "45", "int") % LldbEngine
+ Check("tt.@2.@1.v", "45", "int") % LldbEngine;
+ Check("tt.@2.@1.v", "45", "int") % LldbEngine
+ Check("dd.@1.@1.a", "1", "int") // B::a
+ Check("dd.@2.@1.a", "1", "int") // C::a
+ Check("dd.@1.b", "2", "int")
+ Check("dd.@2.c", "3", "int")
+ Check("dd.d", "4", "int")
+ Check("dp.@1.@1.a", "1", "int") // B::a
+ Check("dp.@2.@1.a", "1", "int") // C::a
+ Check("dp.@1.b", "2", "int")
+ Check("dp.@2.c", "3", "int")
+ Check("dp.d", "4", "int")
+ Check("dr.@1.@1.a", "1", "int") // B::a
+ Check("dr.@2.@1.a", "1", "int") // C::a
+ Check("dr.@1.b", "2", "int")
+ Check("dr.@2.c", "3", "int")
+ Check("dr.d", "4", "int");
QTest::newRow("Gdb13393")
<< Data(
......
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