Difference: CS255Spring09DebugCC1 (6 vs. 7)

Revision 72009-01-27 - BinBao

Line: 1 to 1
 
META TOPICPARENT name="CS255Spring09ProjectHome"
Changed:
<
<

CS255/455 Spring 2008 How to Debug your compiler

>
>

CS255/455 Spring 2009 How to Debug your compiler

 
  • Build a debuggable compiler
Changed:
<
<
Usually if we want to debug a program, we need to turn off all compiler optimizations and add '-g' flag when building the program. To build a debuggable GCC, just configure it normally and then make STAGE1_CFLAGS='-g -O0' all-stage1. However, in our project, at most time we only need to debug our own code, which is supposed to be in a single file cs255.c. So you can just build and install the compiler normally. Then each time after you modify cs255.c, build the compiler with make BOOT_CFLAGS='-O0 -g3'. This will go through the bootstrap steps. To further save compile time, you can go to OBJ_DIR/gcc directory and run make CFLAGS='-O0 -g3'.
>
>
Usually if we want to debug a program, we need to turn off all compiler optimizations and add '-g' flag when building the program. To build a debuggable GCC, just configure it normally and then make STAGE1_CFLAGS='-g -O0' all-stage1. However, in our project, at most time we only need to debug our own code, which is supposed to be in a single file gcc-4.2.2/gcc/cs255.c. So you can just build and install the compiler normally. Then each time after you modify cs255.c, build the compiler with make BOOT_CFLAGS='-O0 -g3'. This will go through the bootstrap steps. To further save compile time, you can go to obj/gcc directory and run make CFLAGS='-O0 -g3'. And don't forget to run make install.
 
  • Underneath gcc
    Actually, gcc you called when you do compilation is just a driver for real compiler cc1, assembler as and linker collect2. Use option -v you can see the exact command sequence. For direct debugging you should run gdb cc1.
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback