Commit cce8521c authored by hjk's avatar hjk Committed by hjk

debugger: more robust detection of types with vtables

Needed to get the "dynamicType" deduction right.

Change-Id: I30ea14f95110fa405abb3a1cb15293d57be87fa3
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 7a9ed9b7
......@@ -89,20 +89,29 @@ def hasInferiorThreadList():
except:
return False
def hasVTable(type):
fields = type.fields()
if len(fields) == 0:
return False
if fields[0].is_base_class:
return hasVTable(fields[0].type)
return str(fields[0].type) == "int (**)(void)"
def dynamicTypeName(value):
#vtbl = str(parseAndEvaluate("{int(*)(int)}%s" % long(value.address)))
try:
# Fails on 7.1 due to the missing to_string.
vtbl = gdb.execute("info symbol {int*}%s" % long(value.address),
to_string = True)
pos1 = vtbl.find("vtable ")
if pos1 != -1:
pos1 += 11
pos2 = vtbl.find(" +", pos1)
if pos2 != -1:
return vtbl[pos1 : pos2]
except:
pass
if hasVTable(value.type):
#vtbl = str(parseAndEvaluate("{int(*)(int)}%s" % long(value.address)))
try:
# Fails on 7.1 due to the missing to_string.
vtbl = gdb.execute("info symbol {int*}%s" % long(value.address),
to_string = True)
pos1 = vtbl.find("vtable ")
if pos1 != -1:
pos1 += 11
pos2 = vtbl.find(" +", pos1)
if pos2 != -1:
return vtbl[pos1 : pos2]
except:
pass
return str(value.type)
def upcast(value):
......
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