forked from qt-creator/qt-creator
debugger: also report sizes of anonymous structs
Change-Id: Ibd7397ddf9b70db599befe8cc99fcf7147b959e6 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -155,28 +155,33 @@ def lookupType(typestring):
|
||||
typesToReport[typestring] = type
|
||||
return type
|
||||
|
||||
if typestring.find("(anon") != -1:
|
||||
# gdb doesn't like
|
||||
# '(anonymous namespace)::AddAnalysisMessageSuppressionComment'
|
||||
#typeCache[typestring] = None
|
||||
typeCache[typestring] = type
|
||||
typesToReport[typestring] = type
|
||||
return None
|
||||
|
||||
try:
|
||||
type = gdb.parse_and_eval("{%s}&main" % typestring).type
|
||||
typeCache[typestring] = type
|
||||
typesToReport[typestring] = type
|
||||
return type
|
||||
if not type is None:
|
||||
typeCache[typestring] = type
|
||||
typesToReport[typestring] = type
|
||||
return type
|
||||
except:
|
||||
pass
|
||||
|
||||
# See http://sourceware.org/bugzilla/show_bug.cgi?id=13269
|
||||
# gcc produces "{anonymous}", gdb "(anonymous namespace)"
|
||||
# "<unnamed>" has been seen too. The only thing gdb
|
||||
# understands when reading things back is "(anonymous namespace)"
|
||||
if typestring.find("{anonymous}") != -1:
|
||||
ts = typestring
|
||||
ts = ts.replace("{anonymous}", "(anonymous namespace)")
|
||||
type = lookupType(ts)
|
||||
if not type is None:
|
||||
typeCache[typestring] = type
|
||||
typesToReport[typestring] = type
|
||||
return type
|
||||
|
||||
#warn(" RESULT FOR 7.2: '%s': %s" % (typestring, type))
|
||||
#typeCache[typestring] = type
|
||||
#return None
|
||||
|
||||
# This part should only trigger for
|
||||
# gdb 7.1 for types with namespace separators.
|
||||
# And anonymous namespaces.
|
||||
|
||||
ts = typestring
|
||||
while True:
|
||||
@@ -215,11 +220,6 @@ def lookupType(typestring):
|
||||
type = gdb.lookup_type(ts)
|
||||
except RuntimeError, error:
|
||||
#warn("LOOKING UP '%s': %s" % (ts, error))
|
||||
if type is None:
|
||||
pos = typestring.find("<unnamed>")
|
||||
if pos != -1:
|
||||
# See http://sourceware.org/bugzilla/show_bug.cgi?id=13269
|
||||
return lookupType(typestring.replace("<unnamed>", "(anonymous namespace)"))
|
||||
# See http://sourceware.org/bugzilla/show_bug.cgi?id=11912
|
||||
exp = "(class '%s'*)0" % ts
|
||||
try:
|
||||
@@ -231,6 +231,11 @@ def lookupType(typestring):
|
||||
#warn("LOOKING UP '%s' FAILED" % ts)
|
||||
pass
|
||||
|
||||
if not type is None:
|
||||
typeCache[typestring] = type
|
||||
typesToReport[typestring] = type
|
||||
return type
|
||||
|
||||
# This could still be None as gdb.lookup_type("char[3]") generates
|
||||
# "RuntimeError: No type named char[3]"
|
||||
typeCache[typestring] = type
|
||||
@@ -912,13 +917,15 @@ typesToReport = {}
|
||||
|
||||
def bb(args):
|
||||
global typesToReport
|
||||
typesToReport = {}
|
||||
output = Dumper(args).output
|
||||
output.append('],typeinfo=[')
|
||||
for name, type in typesToReport.iteritems():
|
||||
output.append('{name="%s",size="%s"}'
|
||||
% (base64.b64encode(name), type.sizeof))
|
||||
# Happens e.g. for '(anonymous namespace)::InsertDefOperation'
|
||||
if not type is None:
|
||||
output.append('{name="%s",size="%s"}'
|
||||
% (base64.b64encode(name), type.sizeof))
|
||||
output.append(']')
|
||||
typesToReport = {}
|
||||
return "".join(output)
|
||||
|
||||
|
||||
|
||||
@@ -537,6 +537,7 @@ namespace anon {
|
||||
a.i = 1;
|
||||
a.i = 2;
|
||||
a.i = 3;
|
||||
|
||||
Something s;
|
||||
BREAK_HERE;
|
||||
// Expand s.
|
||||
@@ -544,13 +545,20 @@ namespace anon {
|
||||
// Check s.a 1 int.
|
||||
// Check s.b 1 int.
|
||||
// Continue.
|
||||
|
||||
s.foo();
|
||||
BREAK_HERE;
|
||||
// Expand s.
|
||||
// Check s.a 42 int.
|
||||
// Check s.b 43 int.
|
||||
// Continue.
|
||||
dummyStatement(&a, &s);
|
||||
|
||||
std::map<int, Something> m;
|
||||
BREAK_HERE;
|
||||
// CheckType m std::map<int, anon::{anonymous}::Something>.
|
||||
// Continue.
|
||||
|
||||
dummyStatement(&a, &s, &m);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user