How to Debug GCC Internals!?
charfi asma
charfiasma@yahoo.fr
Fri Oct 22 08:32:00 GMT 2010
----- Message d'origine ----
De : Hadi Hajimiri <hadi@cise.ufl.edu>
À : gcc-help@gcc.gnu.org
Envoyé le : Ven 22 octobre 2010, 9h 21min 57s
Objet : How to Debug GCC Internals!?
Hi,
I'm a newbie on GCC debugging and I need to modify some of the source codes (the
part for manipulating control flow graph - cfg) for my project. I was wondering
if there's a way to set break points on GCC internals using GDB.
For instance, I'm able to add some lines in the method init_flow() in file
"cfg.c" to just create a new file to see when I'm reaching to this method at
run-time; and it creates the file when executing gcc. But I'm not able to set a
breakpoint at any point of this file when running gcc with GDB!! I guess this
code is dynamically linked and when setting any breakpoint gdb suggests (after
"No source file named cfg.c") "Make breakpoint pending on future shared library
load? (y or [n])".
Thanks in advance
-- Hadi
Hi Hadi,
I am actually debugging my new gcc front end and I can set breakpoint at any
points of the gcc files :
- I configure normally
- I call make with STAGE1_CFLAGS="g -O1"
- I call make install
- I specify my compiler path to the gdb: gdb --args
/usr/local/libexec/gcc/i686-pc-linux-gnu/4.6.0/my_compiler1 ( if you are
interested in compiling c files specify the path of cc1 , if c++ files specify
the path of cc1plus, etc) and then you can add breakpoints at any gcc files:
for example, here I added a breakpoint at line 11 of the main.c file
[root@is010178 test_gcalc]# gdb --args
/usr/local/libexec/gcc/i686-pc-linux-gnu/4.6.0/my_compiler1
GNU gdb 6.8-7mdv2010.0 (Mandriva Linux release 2010.0)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i586-mandriva-linux-gnu"...
(gdb) break main.c:11
Breakpoint 1 at 0x80b52d0: file ../../gcc-dev/gcc/main.c, line 11.
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x080b52d0 in main at
../../gcc-dev/gcc/main.c:11
(gdb)
hope it helps ;)
Asma
More information about the Gcc-help
mailing list