The GNU tool chain debugger, gdb, allows you to control program execution, view and change program variables, examine program internals, and examine core files of crashed programs. You can use gdb to start an executable, debug an already running executable, or make a network connection to gdbserver. gdb and gdbserver handle and correct cross-processor issues such as big endian and little endian addressing and integer size. gdb runs as a console text application, without a GUI. Its open-source nature permits enhancements; you can get GUI tools that provide the integrated development environment (IDE) functionality that programmers have become accustomed to.
This chapter does not dive into a complete discussion of gdb's features, capabilities, and functionality. Rather, it shows you how to list an executable's source code, set a breakpoint, print a variable value, and set a variable value. You can then debug the cross-compiled executable over a network, using one of the Project Trailblazer target platforms. Table 5.1 shows the basic gdb commands that are used in this chapter.
gdb's online help provides additional command information. For example, within gdb, here's the help section for the command next:
(gdb) help next Step program, proceeding through subroutine calls. Like the "step" command as long as subroutine calls do not happen; when they do, the call is treated as one instruction. Argument N means do this N times (or till program stops for another reason). (gdb)
You can start exploring gdb's commands by typing help at the (gdb) prompt.