Introducing gdb

   


Introducing gdb

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.

Table 5.1. gdb Commands
Command Shortcut Description
list l Lists the program file
run r Starts a debugged program
break b Sets a breakpoint
next n Steps a program without entering subroutines
continue c Continues the program that is being debugged
print p Prints a variable's value

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) 

TIP

You can start exploring gdb's commands by typing help at the (gdb) prompt.



       
    Top


    Embedded LinuxR. Hardware, Software, and Interfacing
    Embedded LinuxR. Hardware, Software, and Interfacing
    ISBN: N/A
    EAN: N/A
    Year: 2001
    Pages: 103

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net