This is the mail archive of the gcc@gcc.gnu.org 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: Debugging gcc front end


Guilherme Puglia wrote:
> Hi!
> 
> or better, hello again! I have posted a question (with my class friend
> Eduardo) about 2 or 3 weeks ago. My question was about the grammar
> wich gcc C front end use.

  Yeh!  Hi again you guys :)

> To solve my problem I wanna debug the C front end. I was trying to
> debug the gcc main function, toplev_main. Unfortunately, I can't
> insert a break point in this line.
> 
> I saw the site http://gcc.gnu.org/wiki/DebuggingGCC and
> http://gcc.gnu.org/ml/gcc/2004-03/msg01195.html
> 
> But I don't understand where is "my path". And how to insert the break point.

  Ok, sounds like you're not much familiar with using the shell?  When it says
your path, it means the $PATH variable used to look for command-line
executables.  About setting the breakpoint: if you're using gdb, the command
would be "b toplev_main", it's all in the manual.

  The main thing I'm not sure if you're fully aware of is that when you run
"gcc" at the command-line you're just invoking a simple driver program that
then invokes the preprocessor, compiler, assembler and linker as separate
processes, so you don't want to debug gcc itself.

  If you add "-v" to the gcc command-line, you will see (among other debug
info) the separate individual commands it issues to run these other processes.
 You'll see that the first two commands both invoke "cc1" (or "cc1plus in C++)
- the first time, with the "-E" option to do the preprocessing on the source
file, the second time without "-E" to process the generated .i file.  It's
that second command-line that you want to actually run under the debugger to
inspect the compilation process.


    cheers,
      DaveK


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