-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-gdb.py
33 lines (25 loc) · 1006 Bytes
/
test-gdb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# GDB's default pretty printer barfs up something unreadable for flx,
# thanks to my use of unions and bitfields.
import gdb.printing
class FlxPrinter:
def __init__(self, val):
self.val = val
def to_string(self):
return '{0x%08x:%s %s, %s}' % (int(self.val['pt'] << 3),
str(self.val['nil']),
str(self.val['st']),
str(self.val['gen']))
class AtomicFlxPrinter:
def __init__(self, val):
self.val = val
def to_string(self):
return self.val['_M_i']
def lookup_type (val):
if val.type.unqualified().strip_typedefs().tag == 'flx':
return FlxPrinter(val)
if val.type.unqualified().strip_typedefs().tag == 'flx_na':
return FlxPrinter(val)
if val.type.unqualified().strip_typedefs().tag == 'half_atomic_flx':
return AtomicFlxPrinter(val)
return None
gdb.pretty_printers.append(lookup_type)