diff options
author | hjk <qtc-committer@nokia.com> | 2011-07-11 14:31:02 +0200 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2011-07-13 08:56:20 +0200 |
commit | 85bdf3ece30a7afd39f06cca8267246fa2a6730b (patch) | |
tree | a03b95a6de1941e9271b218527dd83fe84e0ce5b | |
parent | c96668fe06340f861279c577f62c98457710d26a (diff) |
debugger: gracefully handle pointers to types named 'class Foo'
The code was previously taking the fallback route through
gdb.parse_and_evaluate which is slow and not available on
some targets.
Change-Id: I066d4c87c9eda168fe8019e4aaae35e58715d5c8
Reviewed-by: Friedemann Kleint
Reviewed-on: http://codereview.qt.nokia.com/1426
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
-rw-r--r-- | share/qtcreator/dumper/dumper.py | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/share/qtcreator/dumper/dumper.py b/share/qtcreator/dumper/dumper.py index e034d0bf70..a2f71d7521 100644 --- a/share/qtcreator/dumper/dumper.py +++ b/share/qtcreator/dumper/dumper.py @@ -106,58 +106,58 @@ typeInfoCache = {} def lookupType(typestring): type = typeCache.get(typestring) #warn("LOOKUP 1: %s -> %s" % (typestring, type)) - if type is None: - ts = typestring - while True: - #WARN("ts: '%s'" % ts) - if ts.startswith("class "): - ts = ts[6:] - elif ts.startswith("struct "): - ts = ts[7:] - elif ts.startswith("const "): - ts = ts[6:] - elif ts.startswith("volatile "): - ts = ts[9:] - elif ts.startswith("enum "): - ts = ts[5:] - elif ts.endswith(" const"): - ts = ts[:-6] - elif ts.endswith(" volatile"): - ts = ts[:-9] - elif ts.endswith("*const"): - ts = ts[:-5] - elif ts.endswith("*volatile"): - ts = ts[:-8] - else: - break - try: - #warn("LOOKING UP '%s'" % ts) - type = gdb.lookup_type(ts) - except RuntimeError, error: - #warn("LOOKING UP '%s': %s" % (ts, error)) - # See http://sourceware.org/bugzilla/show_bug.cgi?id=11912 - exp = "(class '%s'*)0" % ts - try: - type = parseAndEvaluate(exp).type.target() - except: - # Can throw "RuntimeError: No type named class Foo." - pass - except: - #warn("LOOKING UP '%s' FAILED" % ts) - pass - #warn(" RESULT: '%s'" % type) - #if not type is None: - # warn(" FIELDS: '%s'" % type.fields()) - typeCache[typestring] = type - if type is None and typestring.endswith('*'): - type = lookupType(typestring[0:-1]) + if not type is None: + return type + + ts = typestring + while True: + #WARN("ts: '%s'" % ts) + if ts.startswith("class "): + ts = ts[6:] + elif ts.startswith("struct "): + ts = ts[7:] + elif ts.startswith("const "): + ts = ts[6:] + elif ts.startswith("volatile "): + ts = ts[9:] + elif ts.startswith("enum "): + ts = ts[5:] + elif ts.endswith(" const"): + ts = ts[:-6] + elif ts.endswith(" volatile"): + ts = ts[:-9] + elif ts.endswith("*const"): + ts = ts[:-5] + elif ts.endswith("*volatile"): + ts = ts[:-8] + else: + break + + if ts.endswith('*'): + type = lookupType(ts[0:-1]) if not type is None: type = type.pointer() typeCache[typestring] = type - if type is None: - # could be gdb.lookup_type("char[3]") generating - # "RuntimeError: No type named char[3]" + return type + + try: + #warn("LOOKING UP '%s'" % ts) + type = gdb.lookup_type(ts) + except RuntimeError, error: + #warn("LOOKING UP '%s': %s" % (ts, error)) + # See http://sourceware.org/bugzilla/show_bug.cgi?id=11912 + exp = "(class '%s'*)0" % ts + try: + type = parseAndEvaluate(exp).type.target() + except: + # Can throw "RuntimeError: No type named class Foo." + pass + except: + #warn("LOOKING UP '%s' FAILED" % ts) pass + + # This could still be None as gdb.lookup_type("char[3]") generates + # "RuntimeError: No type named char[3]" return type def cleanAddress(addr): |