summaryrefslogtreecommitdiff
path: root/src/main-gdb-head.py
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-11-03 13:35:54 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-11-04 20:10:50 -0800
commit1853e964e96c41e762ca0ab97259ee4e79d86ec7 (patch)
treeedc76f58ed786263a28da79564786f4d75400092 /src/main-gdb-head.py
parent1a00fe4ea75924bfe594c4d92073cc95eaa2f32d (diff)
downloadtmwa-1853e964e96c41e762ca0ab97259ee4e79d86ec7.tar.gz
tmwa-1853e964e96c41e762ca0ab97259ee4e79d86ec7.tar.bz2
tmwa-1853e964e96c41e762ca0ab97259ee4e79d86ec7.tar.xz
tmwa-1853e964e96c41e762ca0ab97259ee4e79d86ec7.zip
Use the new ASTs
Diffstat (limited to 'src/main-gdb-head.py')
-rw-r--r--src/main-gdb-head.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main-gdb-head.py b/src/main-gdb-head.py
index 3a05917..a465c97 100644
--- a/src/main-gdb-head.py
+++ b/src/main-gdb-head.py
@@ -134,20 +134,30 @@ class PointerPrinter(object):
def to_string(self):
v = self._value
- addr = int(v.cast(gdb.lookup_type('uintptr_t')))
+ uptr = gdb.lookup_type('uintptr_t')
+ addr = int(v.cast(uptr))
if not addr:
s = 'nullptr'
else:
try:
sym, off, sec, lib = info_symbol(addr)
- except:
- s = '(%s)<heap/stack 0x%x>' % (v.type, addr)
+ except TypeError:
+ sp = gdb.parse_and_eval('$sp')
+ sp = int(sp.cast(uptr))
+ LOTS = 8 * 1024 * 1024
+ diff = addr - sp
+ if +diff >= 0 and +diff <= LOTS:
+ a = '<$sp+0x%x>' % +diff
+ elif -diff >= 0 and -diff <= LOTS:
+ a = '<$sp-0x%x>' % -diff
+ else:
+ a = '<heap 0x%x>' % addr
+ s = '(%s)%s' % (v.type, a)
else:
if off:
s = '<%s+%d>' % off
else:
s = '<%s>' % sym
- # TODO should I add (type *) ?
return s