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
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.