This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc call tree

On Mon, 28 Jun 2004 12:07:07 +0800, Hsin-Hsien Wu
<> wrote:
> Hello,
>          I am thinking if it is possible to find a way to make GCC generate
> a call tree  ( or  call trace ) to help understand how the internal of GCC
> works.
> Does any one have the idea?

I've been using GDB for this purpose. Example session follows:

(gdb) file cc1.exe
Reading symbols from cc1.exe...done.
(gdb) b recog
Breakpoint 1 at 0x671116: file insn-recog.c, line 278.
(gdb) run test.c
Starting program: /home/jeyk/programming/gcc/bins/libexec/gcc/i686-pc-cygwin/3.4
.1/cc1.exe test.c

Breakpoint 1, recog (x0=0x1002a890, insn=0x1002d0f0, pnum_clobbers=0x22ef88)
    at insn-recog.c:278
278       rtx * const operands ATTRIBUTE_UNUSED = &recog_data.operand[0];
(gdb) bt
#0  recog (x0=0x1002a890, insn=0x1002d0f0, pnum_clobbers=0x22ef88)
    at insn-recog.c:278
#1  0x005ac7c5 in init_expmed () at ../../gcc-3.4-20040625/gcc/expmed.c:148
#2  0x0047d2aa in backend_init () at ../../gcc-3.4-20040625/gcc/toplev.c:4513
#3  0x0047d625 in do_compile () at ../../gcc-3.4-20040625/gcc/toplev.c:4638
#4  0x0047d6a5 in toplev_main (argc=2, argv=0x10011e78)
    at ../../gcc-3.4-20040625/gcc/toplev.c:4690
#5  0x00474577 in main (argc=671154176, argv=0x4)
    at ../../gcc-3.4-20040625/gcc/main.c:35

Essentially it's: load your file, set your breakpoint(s), run (with
arguments), then use the "backtrace" (bt) command to examine the call
stack as you would with any other program. Take note that I loaded
'cc1' into the debugger, not  'gcc'.

-Jey Kottalam

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]