Calling "debug (const tree_node *ptr)" does nothing.  Change it to
call debug_tree so that we can do this in gdb:

(gdb) whatis type
type = const_tree
(gdb) call debug (type)
 <real_type 0x7fffe982f2a0 float sizes-gimplified SF
    size <integer_cst 0x7fffe98204e0 type <integer_type 0x7fffe98280a8 bitsizety
pe> constant 32>
    unit-size <integer_cst 0x7fffe98204f8 type <integer_type 0x7fffe9828000 size
type> constant 4>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe982
f2a0 precision:32
    pointer_to_this <pointer_type 0x7fffe982f930>>
(gdb)

PR debug/120902
* print-tree.cc (debug with const tree_node *): Call debug_tree
instead of debug.


-- 
H.J.
From 2b074fbb159feecc609e731e22bad7f4340b4456 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.to...@gmail.com>
Date: Tue, 1 Jul 2025 08:14:09 +0800
Subject: [PATCH] Fix "void debug (const tree_node *ptr)"

Calling "debug (const tree_node *ptr)" does nothing.  Change it to
call debug_tree so that we can do this in gdb:

(gdb) whatis type
type = const_tree
(gdb) call debug (type)
 <real_type 0x7fffe982f2a0 float sizes-gimplified SF
    size <integer_cst 0x7fffe98204e0 type <integer_type 0x7fffe98280a8 bitsizetype> constant 32>
    unit-size <integer_cst 0x7fffe98204f8 type <integer_type 0x7fffe9828000 sizetype> constant 4>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe982f2a0 precision:32
    pointer_to_this <pointer_type 0x7fffe982f930>>
(gdb)

	PR debug/120902
	* print-tree.cc (debug with const tree_node *): Call debug_tree
	instead of debug.

Signed-off-by: H.J. Lu <hjl.to...@gmail.com>
---
 gcc/print-tree.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/print-tree.cc b/gcc/print-tree.cc
index 6ec96f0ba17..f84be762741 100644
--- a/gcc/print-tree.cc
+++ b/gcc/print-tree.cc
@@ -1193,7 +1193,7 @@ DEBUG_FUNCTION void
 debug (const tree_node *ptr)
 {
   if (ptr)
-    debug (*ptr);
+    debug_tree (const_cast <tree> (ptr));
   else
     fprintf (stderr, "<nil>\n");
 }
-- 
2.50.0

Reply via email to