]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gdbhooks.py: add printers for analyzer types (supernode and exploded_node)
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 7 Nov 2025 21:21:11 +0000 (16:21 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 7 Nov 2025 21:22:42 +0000 (16:22 -0500)
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 <dmalcolm@redhat.com>
gcc/gdbhooks.py

index 4735d590e4d50bc352e69a49ec3e8852c08bf5aa..a58181002fd4e1ab3cfd7ef3a746958ad3885414 100644 (file)
@@ -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)