Tested by hand; this leads to output like this:

(gdb) p m_enode_for_diag
$1 = <ana::exploded_node 0x4e389f0 (EN 6)>

(gdb) p m_enode_for_diag->get_supernode ()
$2 = <ana::supernode 0x4da9030 (SN 1)>

Pushed to trunk as r16-5091-g90a7e657ba3f92.

gcc/ChangeLog:
        * gdbhooks.py (class AnaSupernodePrinter): New.
        (class AnaExplodedNodePrinter): New.
        (build_pretty_printer): Register the above.
---
 gcc/gdbhooks.py | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 4735d590e4d5..a58181002fd4 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -388,6 +388,32 @@ class CfgEdgePrinter:
         result += '>'
         return result
 
+######################################################################
+# Pretty-printers for -fanalyzer (namespace ana)
+######################################################################
+
+class AnaSupernodePrinter:
+    def __init__(self, gdbval):
+        self.gdbval = gdbval
+
+    def to_string (self):
+        result = '<ana::supernode 0x%x' % intptr(self.gdbval)
+        if intptr(self.gdbval):
+            result += ' (SN %i)' % intptr(self.gdbval['m_index'])
+        result += '>'
+        return result
+
+class AnaExplodedNodePrinter:
+    def __init__(self, gdbval):
+        self.gdbval = gdbval
+
+    def to_string (self):
+        result = '<ana::exploded_node 0x%x' % intptr(self.gdbval)
+        if intptr(self.gdbval):
+            result += ' (EN %i)' % intptr(self.gdbval['m_index'])
+        result += '>'
+        return result
+
 ######################################################################
 
 class Rtx:
@@ -625,6 +651,13 @@ def build_pretty_printer():
     pp.add_printer_for_types(['basic_block', 'basic_block_def *'],
                              'basic_block',
                              BasicBlockPrinter)
+    pp.add_printer_for_types(['ana::supernode *', 'const ana::supernode *'],
+                             'ana::supernode',
+                             AnaSupernodePrinter)
+    pp.add_printer_for_types(['ana::exploded_node *',
+                              'dedge<ana::eg_traits>::node_t *'],
+                             'ana::exploded_node',
+                             AnaExplodedNodePrinter)
     pp.add_printer_for_types(['edge', 'edge_def *'],
                              'edge',
                              CfgEdgePrinter)
-- 
2.26.3

Reply via email to