I am tired of dumping entire DIEs just to see what type they are. With this patch, we get:

(gdb) print context_die
$5 = <dw_die_ref 0x7ffff6de0230 DW_TAG_module <parent=0x7ffff6de0000 DW_TAG_compile_unit>>

I know it's past the end of stage1, but this debugging aid can help in fixing bugs in stage >= 3.

I am committing this to the [debug-early] branch, but I am hoping I can also commit it to mainline and avoid dragging it along.

OK for mainline?
commit e20f40f92eeba51f9a1ffb078e060366e7beb471
Author: Aldy Hernandez <al...@redhat.com>
Date:   Tue Dec 9 13:04:46 2014 -0800

        * gdbhooks.py (class DWDieRefPrinter): New class.
        (build_pretty_printer): Register dw_die_ref's.

diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index a74e712..26affd9 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -253,6 +253,26 @@ class CGraphNodePrinter:
         return result
 
 ######################################################################
+# Dwarf DIE pretty-printers
+######################################################################
+
+class DWDieRefPrinter:
+    def __init__(self, gdbval):
+        self.gdbval = gdbval
+
+    def to_string (self):
+        result = '<dw_die_ref 0x%x' % long(self.gdbval)
+        if long(self.gdbval) == 0:
+            return '<dw_die_ref 0x0>'
+        result += ' %s' % self.gdbval['die_tag']
+        if long(self.gdbval['die_parent']) != 0:
+            result += ' <parent=0x%x %s>' % (long(self.gdbval['die_parent']),
+                                             
self.gdbval['die_parent']['die_tag'])
+                                             
+        result += '>'
+        return result
+
+######################################################################
 
 class GimplePrinter:
     def __init__(self, gdbval):
@@ -455,6 +475,8 @@ def build_pretty_printer():
                              'tree', TreePrinter)
     pp.add_printer_for_types(['cgraph_node *'],
                              'cgraph_node', CGraphNodePrinter)
+    pp.add_printer_for_types(['dw_die_ref'],
+                             'dw_die_ref', DWDieRefPrinter)
     pp.add_printer_for_types(['gimple', 'gimple_statement_base *',
 
                               # Keep this in the same order as gimple.def:

Reply via email to