This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How do I print a tree?
- To: klaxi at t-online dot de
- Subject: Re: How do I print a tree?
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sat, 8 Apr 2000 19:51:08 +0200
- CC: gcc at gcc dot gnu dot org
- References: <002601bfa17f$55a294a0$0200a8c0@Home.de>
> There are several print-routines (print_node, print_lang_identifier,
> print_lang_type etc.), but I can't figure out where in gcc/g++ they
> are used to print a tree (AST). I searched and tried to understand
> the source code, but still can't say where to "activate" or
> integrate it.
The primary interface to this is debug_tree. This is not called in gcc
itself; the typical way to call it is from within a debugger.
(gdb) p decl1
$1 = 0x40105b00
(gdb) p debug_tree(decl1)
<function_decl 0x40105b00 main
type <function_type 0x40100800
type <integer_type 0x4001a380 int SI
size <integer_cst 0x400195e0 constant 32>
unit size <integer_cst 0x40019600 constant 4>
align 32 symtab 0 alias set -1 precision 32
min <integer_cst 0x400195a0 constant -2147483648>
max <integer_cst 0x400195c0 constant 2147483647>
pointer_to_this <pointer_type 0x40100600>>
DI
size <integer_cst 0x40019d00 constant 64>
unit size <integer_cst 0x40019d20 constant 8>
align 64 symtab 0 alias set -1>
public external QI file a.c line 4>
In fact, if you use the .gdbinit that comes with gcc, you could have
used
(gdb) p decl1
$1 = 0x40105b00
(gdb) pt
Hope this helps,
Martin