public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* How do I print a tree?
@ 2000-04-08 10:24 Christian Baxmann
  2000-04-08 10:55 ` Martin v. Loewis
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Baxmann @ 2000-04-08 10:24 UTC (permalink / raw)
  To: gcc

Hi there!
I'd like to know how to print a tree (AST), generated by the g++-Front-End.

I don't know if gcc/g++ can do that by themself (via compiler options) or
somehow
have to be inctructed to do so.

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.

There has to be a routine that walks through the tree. So, my idea by now is
to use
the print_node-routine (in gcc/print-tree.c) for each node it "walks
trough".
But I guess there is a more simple or allready integrated routine in gcc/g++
that I can't find.

Hopefully yours
Christian Baxmann

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How do I print a tree?
  2000-04-08 10:24 How do I print a tree? Christian Baxmann
@ 2000-04-08 10:55 ` Martin v. Loewis
  0 siblings, 0 replies; 2+ messages in thread
From: Martin v. Loewis @ 2000-04-08 10:55 UTC (permalink / raw)
  To: klaxi; +Cc: gcc

> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-04-08 10:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-08 10:24 How do I print a tree? Christian Baxmann
2000-04-08 10:55 ` Martin v. Loewis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).