Next  |  Prev  |  Up  |  Top  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Preparing your Program for Debugging

If you have followed the instructions of the preceding intro, you are already prepared for debugging in gdb, and you can skip to the next section. Otherwise, before using gdb, you need to

(1)
compile your program and the STK library with symbols using the `-g' compiler switch, and
(2)
compile without optimization (no '-O', '-O2', '-O3' options, etc. -O0 explicitly turns it off).

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 your Makefile contains the following:

        CFLAGS = -O3 -Wall ...
Before running gdb, we need to change this to
        CFLAGS = -g -O0 -Wall ...
and recompile by typing ``make'' in that directory.


Next  |  Prev  |  Up  |  Top  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Download stkintro.pdf
[Comment on this page via email]

``Getting Started with the Synthesis Tool Kit (STK)'', by Julius O. Smith III, Music 420 Reader supplementing the text).
Copyright © 2013-01-13 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA