Difference: CS255Spring09DebugCC1 (4 vs. 5)

Revision 52009-01-27 - BinBao

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

CS255/455 Spring 2008 How to Debug your compiler

  • Build a debuggable compiler
Line: 8 to 8
  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.

  • Write a gdb command file
Changed:
<
<
After getting the command sequence by using gcc -v, you can write a gdb command file to save the typing when starting gdb. Here is an example of such file (your file location and parameters may be different). Let's name this file as gdbfile, and then you can run gdb -x gdbfile to start debugging.
>
>
After getting the command sequence by using gcc -v, you can write a gdb command file to save the typing when starting gdb. Here is an example of such file (your file location and parameters may be different).
  file /localdisk/bao/gcc/obj/gcc/cc1 b rest_of_handle_cs255 r -quiet -v ab.c -quiet -dumpbase ab.c -mtune=generic -auxbase-strip ab.o -O2 -version -fcs255 -fdump-tree-gimple -fdump-cs255-tree-gimple -o /tmp/cceaerqF.s
Changed:
<
<
>
>
Let's name this file as gdbfile, and then you can run gdb -x gdbfile to start debugging.
 
Deleted:
<
<

 
  • Get familiar with gdb commands
    Refer to gdb documentation on how to set break points, print the current call stack, examine variable values, and so on.
    • break [file:]func_name to set a break point; break [filename:]linenum to set a break point at a line; break ... if cond to stop only when cond evaluates to true; info break to print all breakpoints.
Line: 28 to 26
 
  • Run gdb in Emacs
    A nice feature of running gdb in Emacs is it can link a gdb window and source code window together. Stepping in gdb will move the cursor on the source code window as well. A useful trick is to create a soft link to your cc1 on your test case directory, and then you don't need to change your working directory in gdb back and forth.
Changed:
<
<
    • M-x gdb
    • gdb --annotate=3 cc1.
    • gdb has been started, so you can use it normally.
>
>
    1. M-x gdb
    2. gdb --annotate=3 cc1.
    3. gdb has been started, so you can use it normally.
 
Changed:
<
<
  1. gimple tree
  2. node

  • Dumping gimple-node
>
>
* Dump gimple tree node tree-dump.c.
 
 
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