https://gcc.gnu.org/g:90a7e657ba3f922eae90d7f5497e3bf22b9520ab

commit r16-5091-g90a7e657ba3f922eae90d7f5497e3bf22b9520ab
Author: David Malcolm <[email protected]>
Date:   Fri Nov 7 16:21:11 2025 -0500

    gdbhooks.py: add printers for analyzer types (supernode and exploded_node)
    
    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)>
    
    gcc/ChangeLog:
            * gdbhooks.py (class AnaSupernodePrinter): New.
            (class AnaExplodedNodePrinter): New.
            (build_pretty_printer): Register the above.
    
    Signed-off-by: David Malcolm <[email protected]>

Diff:
---
 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)

Reply via email to