From 7245589dcbc08c377f783a637deeaa09604c6213 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Thu, 28 Aug 2014 14:28:43 -0700 Subject: Compatibility with gdb 7.4 --- src/generic/dumb_ptr.py | 2 +- src/map/magic-expr.py | 6 ++++-- src/map/magic-stmt.py | 6 ++++-- src/mmo/ids.py | 6 +++++- src/mmo/strs.py | 6 +++++- tools/debug-debug.gdb | 20 +++++++++++++++++--- 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/generic/dumb_ptr.py b/src/generic/dumb_ptr.py index 7d30d6c..b7973a7 100644 --- a/src/generic/dumb_ptr.py +++ b/src/generic/dumb_ptr.py @@ -7,7 +7,7 @@ class dumb_ptr(object): self._value = value def to_string(self): - return '0x%x' % self._value['impl'].cast(gdb.parse_and_eval('(long *)0').type) + return '0x%x' % long(self._value['impl'].cast(gdb.parse_and_eval('(long *)0').type)) def children(self): try: diff --git a/src/map/magic-expr.py b/src/map/magic-expr.py index 865a175..0d9db55 100644 --- a/src/map/magic-expr.py +++ b/src/map/magic-expr.py @@ -31,6 +31,8 @@ class fun_t(object): ''' tests = [ - ('static_cast(nullptr)', '(fun_t *) nullptr'), - ('new tmwa::magic::fun_t{"name"_s, "sig"_s, \'\\0\', nullptr}', '(fun_t *) = {->name = "name", ->signature = "sig", ->ret_ty = 0 \'\\000\', ->fun = 0x0}'), + ('static_cast(nullptr)', + '(fun_t *) nullptr'), + ('new tmwa::magic::fun_t{"name"_s, "sig"_s, \'\\0\', nullptr}', + 'regex:\(fun_t \*\) = \{->name = "name", ->signature = "sig", ->ret_ty = 0 \'\\\\000\', ->fun = (0x)?0}'), ] diff --git a/src/map/magic-stmt.py b/src/map/magic-stmt.py index 70ce3ca..14289ef 100644 --- a/src/map/magic-stmt.py +++ b/src/map/magic-stmt.py @@ -30,6 +30,8 @@ class op_t(object): ''' tests = [ - ('static_cast(nullptr)', '(op_t *) nullptr'), - ('new tmwa::magic::op_t{"name"_s, "sig"_s, nullptr}', '(op_t *) = {->name = "name", ->signature = "sig", ->op = 0x0}'), + ('static_cast(nullptr)', + '(op_t *) nullptr'), + ('new tmwa::magic::op_t{"name"_s, "sig"_s, nullptr}', + 'regex:\(op_t \*\) = \{->name = "name", ->signature = "sig", ->op = (0x)?0}'), ] diff --git a/src/mmo/ids.py b/src/mmo/ids.py index 2d26215..89392b1 100644 --- a/src/mmo/ids.py +++ b/src/mmo/ids.py @@ -18,7 +18,11 @@ for s in [ value = self._value fields = value.type.fields() field0 = fields[-1] - return '%s' % (value[field0]) + if field0.is_base_class: + w = value.cast(field0.type) + else: + w = value[field0.name] + return '%s' % w tests = [ ('tmwa::wrap(123)' % s, '123'), diff --git a/src/mmo/strs.py b/src/mmo/strs.py index 3e39ef4..313ecb5 100644 --- a/src/mmo/strs.py +++ b/src/mmo/strs.py @@ -21,7 +21,11 @@ for s in [ value = self._value fields = value.type.fields() field0 = fields[-1] - return '%s' % value[field0] + if field0.is_base_class: + w = value.cast(field0.type) + else: + w = value[field0.name] + return '%s' % w test_extra = ''' #include "../strings/fwd.hpp" diff --git a/tools/debug-debug.gdb b/tools/debug-debug.gdb index 23a934c..72a45e1 100644 --- a/tools/debug-debug.gdb +++ b/tools/debug-debug.gdb @@ -1,18 +1,32 @@ # vim: ft=python -set auto-load safe-path / +# set auto-load safe-path / +python +try: + gdb.execute('set auto-load safe-path /') +except: + pass +end file bin/test-debug-debug set logging file /dev/null set logging redirect on set logging off python +import re import sys def hit_breakpoint(): sys.stdout.write('.') value = str(gdb.parse_and_eval('*&value')) expected = gdb.parse_and_eval('expected').string() - if value != expected: + if expected.startswith('regex:'): + def compare(value, expected): + m = re.match(expected[6:], value) + return m and m.end() == m.endpos + else: + def compare(value, expected): + return value == expected + if not compare(value, expected): print 'Error: mismatch, aborting ...' print 'actual: %r' % value print 'expect: %r' % str(expected) @@ -23,7 +37,7 @@ end # register a pretty-printer for 'char *' instead #set print address off set print static-members off -set print elements unlimited +set print elements 9999 set print frame-arguments none set logging on -- cgit v1.2.3-60-g2f50