Search Physical Audio Signal Processing
Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?
If you have followed the instructions of the preceding appendix, you are already prepared for debugging in gdb, and you can skip to the next section. Otherwise, before using gdb, you need to
For (1), find the CC variable in the Makefile for your program, and add -g to it. This will cause the compiler to leave a symbol table and line-number information in the .o file.
For (2), remove `-O', `-O2', `-O3', or the like, from the CC variable's definition (or change it to `-O0'). These are optimization flags, and optimization can cause gdb's line-number information to become incorrect (when lines of code are optimized away). Furthermore, intermediate variables are also often optimized away, in which case you can no longer inspect them while single-stepping.
For example, suppose the Makefile (e.g., for projects/examples in the STK distribution) contains the following:
CFLAGS = -O3 -Wall ...
Before running gdb, we need to change this to
CFLAGS = -g -Wall ...
and recompile by typing ``make'' in that directory.
