diff options
author | Samuel Bronson <naesten@gmail.com> | 2011-10-25 16:30:33 -0400 |
---|---|---|
committer | Samuel Bronson <naesten@gmail.com> | 2011-10-25 16:37:04 -0400 |
commit | cda7f728accf94818df174695facb6f7ee0147ac (patch) | |
tree | fa8e527953d4e109f340e794e8e4858d90c8ca5d /crawl-ref/source/crawl-gdb.py | |
parent | f70a5619b3d577daf08c791974537ce058504465 (diff) | |
download | crawl-ref-cda7f728accf94818df174695facb6f7ee0147ac.tar.gz crawl-ref-cda7f728accf94818df174695facb6f7ee0147ac.zip |
A couple of basic GDB pretty-printers.
Diffstat (limited to 'crawl-ref/source/crawl-gdb.py')
-rw-r--r-- | crawl-ref/source/crawl-gdb.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/crawl-ref/source/crawl-gdb.py b/crawl-ref/source/crawl-gdb.py new file mode 100644 index 0000000000..84f5bfbe60 --- /dev/null +++ b/crawl-ref/source/crawl-gdb.py @@ -0,0 +1,40 @@ +# GDB autoload file + +import gdb.printing + + +class coord_def_printer: + def __init__(self, val): + self.val = val + + def to_string(self): + return "({0[x]}, {0[y]})".format(self.val) + + +class actor_printer: + """Print an actor object.""" + + def __init__(self, val): + self.val = val + + def to_string(self): + return "{} #{:#x} at {}".format( + self.val["type"], int(self.val["mid"]), self.val["position"]) + +class FixedVector_printer: + def __init__(self, val): + self.val = val + + def to_string(self): + return self.val['mData'] + +def build_pretty_printer(): + pp = gdb.printing.RegexpCollectionPrettyPrinter("crawl") + pp.add_printer('coord_def', '^coord_def$', coord_def_printer) +# pp.add_printer('actor', '^actor$', actor_printer) + pp.add_printer('FixedVector', '^FixedVector<.*>$', FixedVector_printer) + return pp + +gdb.printing.register_pretty_printer( + gdb.current_objfile(), + build_pretty_printer()) |