Keep in mind that the debugger interferes with the program - especially when real time behavior is involved. Read this chapter for ways...
Some useful information here. M-x speedbar could be really handy here.
The GDB Text User Interface (TUI) is a terminal interface which uses the ‘curses’ library to show the source file, the assembly output,...
Sequences User Defined Commands You can assign a name to a sequence of commands. You can allow for arguments. They are accessed using...
Prompt You can change the prompt. If yoru gdb has python scripting enabled, you have prompt extensions. Command History You can set the...
While nearly all GDB commands are available for all native and cross versions of the debugger, there are some exceptions. This chapter...
This section has information on how to do remote debugging.
This is when you want to debug remotely or on a different architecture.
To change the program you want to debug, type file FILENAME. It will look at $PATH if it doesn’t find it. You can also load .o files...
Assignment To modify x, do print x=4 You can also use set. Or set variable. Continuing at a Different Address Use jump LOCATION to...
You can do things like query which symbol is at an address (or close to it). You can demangle names. Or the information about the...
If gdb doesn’t figure out the language automatically, you can set it using set language. show language shows the current language. This...
If your program is too large to fit completely in your target system’s memory, you can sometimes use “overlays” to work around this...
In some applications, it is not feasible for the debugger to interrupt the program’s execution long enough for the developer to learn...
gdb has stuff for handling macros, but you likely need to compile your program in a way to add these to the debug symbols. See this...
Normally you would use p to examine data. You can also use a Python pretty printer. print EXPR You can use the x command to see a more...
Printing Source Lines Note: You can use GDB with Emacs, and viewing the source via Emacs is convenient. list prints 10 lines. To change...
Stack Frames GDB labels each existing stack frame with a “level”, a number that is zero for the innermost frame, one for the frame that...
On some platforms, GDB provides a special “process record and replay” target that can record a log of the process execution, and replay...
Sometimes you realize that you went past the interesting point in your program. Occasionally you can rewind if the target environment...
To break conditionally, do: break ... if COND … could be a function, location, address, etc. You can set a breakpoint such that it...
You can modify the environment so that your program runs as if in that environment (and not the environment gdb was launched under). See...
How do you repeat the last command? Just type Enter. It doesn’t work on all commands. If you want to repeat an earlier sequence of...
To attach to a running process, do: gdb PROGRAM
To start gdb on a certain program, type gdb progname. If, for whatever reason, you want to change the width of the text (to fit in your...