forked from qt-creator/qt-creator
debugger: fix reporting of type size from python dumpers
Change-Id: I46ed81d3c0bf06e8c7b6a80266ea1b833120e90e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
@@ -141,33 +141,32 @@ def expensiveDowncast(value):
|
|||||||
|
|
||||||
typeCache = {}
|
typeCache = {}
|
||||||
|
|
||||||
class TypeInfo:
|
|
||||||
def __init__(self, type):
|
|
||||||
self.type = type
|
|
||||||
self.reported = False
|
|
||||||
|
|
||||||
|
|
||||||
def lookupType(typestring):
|
def lookupType(typestring):
|
||||||
typeInfo = typeCache.get(typestring)
|
global typeCache
|
||||||
|
global typesToReport
|
||||||
|
type = typeCache.get(typestring)
|
||||||
#warn("LOOKUP 1: %s -> %s" % (typestring, type))
|
#warn("LOOKUP 1: %s -> %s" % (typestring, type))
|
||||||
if not typeInfo is None:
|
if not type is None:
|
||||||
return typeInfo.type
|
return type
|
||||||
|
|
||||||
if typestring == "void":
|
if typestring == "void":
|
||||||
type = gdb.lookup_type(typestring)
|
type = gdb.lookup_type(typestring)
|
||||||
typeCache[typestring] = TypeInfo(type)
|
typeCache[typestring] = type
|
||||||
|
typesToReport[typestring] = type
|
||||||
return type
|
return type
|
||||||
|
|
||||||
if typestring.find("(anon") != -1:
|
if typestring.find("(anon") != -1:
|
||||||
# gdb doesn't like
|
# gdb doesn't like
|
||||||
# '(anonymous namespace)::AddAnalysisMessageSuppressionComment'
|
# '(anonymous namespace)::AddAnalysisMessageSuppressionComment'
|
||||||
#typeCache[typestring] = None
|
#typeCache[typestring] = None
|
||||||
typeCache[typestring] = TypeInfo(type)
|
typeCache[typestring] = type
|
||||||
|
typesToReport[typestring] = type
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
type = gdb.parse_and_eval("{%s}&main" % typestring).type
|
type = gdb.parse_and_eval("{%s}&main" % typestring).type
|
||||||
typeCache[typestring] = TypeInfo(type)
|
typeCache[typestring] = type
|
||||||
|
typesToReport[typestring] = type
|
||||||
return type
|
return type
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@@ -207,7 +206,8 @@ def lookupType(typestring):
|
|||||||
type = lookupType(ts[0:-1])
|
type = lookupType(ts[0:-1])
|
||||||
if not type is None:
|
if not type is None:
|
||||||
type = type.pointer()
|
type = type.pointer()
|
||||||
typeCache[typestring] = TypeInfo(type)
|
typeCache[typestring] = type
|
||||||
|
typesToReport[typestring] = type
|
||||||
return type
|
return type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -233,6 +233,8 @@ def lookupType(typestring):
|
|||||||
|
|
||||||
# This could still be None as gdb.lookup_type("char[3]") generates
|
# This could still be None as gdb.lookup_type("char[3]") generates
|
||||||
# "RuntimeError: No type named char[3]"
|
# "RuntimeError: No type named char[3]"
|
||||||
|
typeCache[typestring] = type
|
||||||
|
typesToReport[typestring] = type
|
||||||
return type
|
return type
|
||||||
|
|
||||||
def cleanAddress(addr):
|
def cleanAddress(addr):
|
||||||
@@ -906,15 +908,18 @@ registerCommand("bbedit", bbedit)
|
|||||||
#
|
#
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
|
typesToReport = {}
|
||||||
|
|
||||||
def bb(args):
|
def bb(args):
|
||||||
output = 'data=[' + "".join(Dumper(args).output) + '],typeinfo=['
|
global typesToReport
|
||||||
for typeName, typeInfo in typeCache.iteritems():
|
typesToReport = {}
|
||||||
if not typeInfo.reported:
|
output = Dumper(args).output
|
||||||
output += '{name="' + base64.b64encode(typeName)
|
output.append('],typeinfo=[')
|
||||||
output += '",size="' + str(typeInfo.type.sizeof) + '"},'
|
for name, type in typesToReport.iteritems():
|
||||||
typeInfo.reported = True
|
output.append('{name="%s",size="%s"}'
|
||||||
output += ']';
|
% (base64.b64encode(name), type.sizeof))
|
||||||
return output
|
output.append(']')
|
||||||
|
return "".join(output)
|
||||||
|
|
||||||
|
|
||||||
def p1(args):
|
def p1(args):
|
||||||
@@ -960,6 +965,8 @@ class Dumper:
|
|||||||
self.formats = {}
|
self.formats = {}
|
||||||
self.expandedINames = ""
|
self.expandedINames = ""
|
||||||
|
|
||||||
|
self.output.append('data=[')
|
||||||
|
|
||||||
options = []
|
options = []
|
||||||
varList = []
|
varList = []
|
||||||
watchers = ""
|
watchers = ""
|
||||||
@@ -1351,6 +1358,7 @@ class Dumper:
|
|||||||
type = value.type.unqualified()
|
type = value.type.unqualified()
|
||||||
typeName = str(type)
|
typeName = str(type)
|
||||||
tryDynamic &= self.useDynamicType
|
tryDynamic &= self.useDynamicType
|
||||||
|
lookupType(typeName) # Fill type cache
|
||||||
|
|
||||||
# FIXME: Gui shows references stripped?
|
# FIXME: Gui shows references stripped?
|
||||||
#warn(" ")
|
#warn(" ")
|
||||||
|
Reference in New Issue
Block a user