| Options for Debugging Your Program

Previous | GCC Command-Line Options | Next

GCC has various special options that are used for debugging either your program or GCC. However, this manual is not meant to explain anything about the internals of GCC, so you will have to go to the official version of this page on the internet if you want to debug GCC itself.
In order to debug TIGCC programs, you need a GDB-enabled version of the TiEmu emulator.

-g
  Produce debugging information in the operating system's native format (stabs is the default for the MC68000). GDB can work with this debugging information. Note that the `tigcc` frontend defaults to DWARF 2 debugging information instead, see Options Available in the Command Line Compiler.
  Unlike most other C compilers, GCC allows you to use '-g' with '-O'. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops.
  Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs.
  The following options are useful when GCC is generated with the capability for more than one debugging format.
-ggdb
  Produce debugging information for use by GDB. This means to use the most expressive format available, including GDB extensions if at all possible.
-gstabs
  Produce debugging information in stabs format.
-gstabs+
  Produce debugging information in stabs format, using GNU extensions understood only by the GNU debugger (GDB).
-gcoff
  Produce debugging information in COFF format.
-glevel
-ggdblevel
-gstabslevel
-gcofflevel
  Request debugging information and also use level to specify how much information. The default level is 2.
  Level 1 produces minimal information, enough for making backtraces in parts of the program that you don't plan to debug. This includes descriptions of functions and external variables, but no information about local variables and no line numbers.
  Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use '-g3'.
-p
  Generate extra code to write profile information suitable for the analysis program `prof`. You must use this option when compiling the source files you want data about, and you must also use it when linking. This option is probably useless in TIGCC.
-pg
  Generate extra code to write profile information suitable for the analysis program `gprof`. You must use this option when compiling the source files you want data about, and you must also use it when linking. This option is probably useless in TIGCC.
-Q
  Makes the compiler print out each function name as it is compiled, and print some statistics about each pass when it finishes.
-save-temps
  Store the usual "temporary" intermediate files permanently; place them in the current directory and name them based on the source file. Thus, compiling `foo.c` with '-c -save-temps' would produce files `foo.i` and `foo.s`, as well as `foo.o`. This creates a preprocessed `foo.i` output file even though the compiler now normally uses an integrated preprocessor.