forked from qt-creator/qt-creator
debugger: move type info cache population to lookupType
This way we miss some data from types we never lookup (like 'int') but having it out of the performance path in SubItem.__exit__ is more important. Change-Id: I9ff86a7d9bf0d66e5781581d04942f29ca0e520b Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -140,31 +140,31 @@ typeCache = {}
|
|||||||
|
|
||||||
class TypeInfo:
|
class TypeInfo:
|
||||||
def __init__(self, type):
|
def __init__(self, type):
|
||||||
self.size = type.sizeof
|
self.type = type
|
||||||
self.reported = False
|
self.reported = False
|
||||||
|
|
||||||
typeInfoCache = {}
|
|
||||||
|
|
||||||
def lookupType(typestring):
|
def lookupType(typestring):
|
||||||
type = typeCache.get(typestring)
|
typeInfo = typeCache.get(typestring)
|
||||||
#warn("LOOKUP 1: %s -> %s" % (typestring, type))
|
#warn("LOOKUP 1: %s -> %s" % (typestring, type))
|
||||||
if not type is None:
|
if not typeInfo is None:
|
||||||
return type
|
return typeInfo.type
|
||||||
|
|
||||||
if typestring == "void":
|
if typestring == "void":
|
||||||
type = gdb.lookup_type(typestring)
|
type = gdb.lookup_type(typestring)
|
||||||
typeCache[typestring] = type
|
typeCache[typestring] = TypeInfo(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)
|
||||||
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] = type
|
typeCache[typestring] = TypeInfo(type)
|
||||||
return type
|
return type
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@@ -204,7 +204,7 @@ 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] = type
|
typeCache[typestring] = TypeInfo(type)
|
||||||
return type
|
return type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -371,11 +371,6 @@ class SubItem:
|
|||||||
|
|
||||||
if len(typeName) > 0 and typeName != self.d.currentChildType:
|
if len(typeName) > 0 and typeName != self.d.currentChildType:
|
||||||
self.d.put('type="%s",' % typeName) # str(type.unqualified()) ?
|
self.d.put('type="%s",' % typeName) # str(type.unqualified()) ?
|
||||||
if not typeName in typeInfoCache \
|
|
||||||
and typeName != " ": # FIXME: Move to lookupType
|
|
||||||
typeObj = lookupType(typeName)
|
|
||||||
if not typeObj is None:
|
|
||||||
typeInfoCache[typeName] = TypeInfo(typeObj)
|
|
||||||
if self.d.currentValue is None:
|
if self.d.currentValue is None:
|
||||||
self.d.put('value="<not accessible>",numchild="0",')
|
self.d.put('value="<not accessible>",numchild="0",')
|
||||||
else:
|
else:
|
||||||
@@ -853,13 +848,6 @@ qqDumpers = {}
|
|||||||
# This is a cache of all dumpers that support writing.
|
# This is a cache of all dumpers that support writing.
|
||||||
qqEditable = {}
|
qqEditable = {}
|
||||||
|
|
||||||
# This is a cache of the namespace of the currently used Qt version.
|
|
||||||
# FIXME: This is not available on 'bbsetup' time, only at 'bb' time.
|
|
||||||
|
|
||||||
# This is a cache of typenames->bool saying whether we are QObject
|
|
||||||
# derived.
|
|
||||||
qqQObjectCache = {}
|
|
||||||
|
|
||||||
# This keeps canonical forms of the typenames, without array indices etc.
|
# This keeps canonical forms of the typenames, without array indices etc.
|
||||||
qqStripForFormat = {}
|
qqStripForFormat = {}
|
||||||
|
|
||||||
@@ -884,7 +872,6 @@ def stripForFormat(typeName):
|
|||||||
return stripped
|
return stripped
|
||||||
|
|
||||||
def bbsetup(args):
|
def bbsetup(args):
|
||||||
typeInfoCache = {}
|
|
||||||
typeCache = {}
|
typeCache = {}
|
||||||
module = sys.modules[__name__]
|
module = sys.modules[__name__]
|
||||||
for key, value in module.__dict__.items():
|
for key, value in module.__dict__.items():
|
||||||
@@ -956,15 +943,14 @@ registerCommand("bbedit", bbedit)
|
|||||||
|
|
||||||
def bb(args):
|
def bb(args):
|
||||||
output = 'data=[' + "".join(Dumper(args).output) + '],typeinfo=['
|
output = 'data=[' + "".join(Dumper(args).output) + '],typeinfo=['
|
||||||
for typeName, typeInfo in typeInfoCache.iteritems():
|
for typeName, typeInfo in typeCache.iteritems():
|
||||||
if not typeInfo.reported:
|
if not typeInfo.reported:
|
||||||
output += '{name="' + base64.b64encode(typeName)
|
output += '{name="' + base64.b64encode(typeName)
|
||||||
output += '",size="' + str(typeInfo.size) + '"},'
|
output += '",size="' + str(typeInfo.type.sizeof) + '"},'
|
||||||
typeInfo.reported = True
|
typeInfo.reported = True
|
||||||
output += ']';
|
output += ']';
|
||||||
return output
|
return output
|
||||||
|
|
||||||
registerCommand("bb", bb)
|
|
||||||
|
|
||||||
def p1(args):
|
def p1(args):
|
||||||
import cProfile
|
import cProfile
|
||||||
@@ -973,13 +959,14 @@ def p1(args):
|
|||||||
pstats.Stats('/tmp/bbprof').sort_stats('time').print_stats()
|
pstats.Stats('/tmp/bbprof').sort_stats('time').print_stats()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
registerCommand("p1", p1)
|
|
||||||
|
|
||||||
def p2(args):
|
def p2(args):
|
||||||
import timeit
|
import timeit
|
||||||
return timeit.repeat('bb("%s")' % args,
|
return timeit.repeat('bb("%s")' % args,
|
||||||
'from __main__ import bb', number=10)
|
'from __main__ import bb', number=10)
|
||||||
|
|
||||||
|
registerCommand("bb", bb)
|
||||||
|
registerCommand("p1", p1)
|
||||||
registerCommand("p2", p2)
|
registerCommand("p2", p2)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user