Tag gdb

In-Process Agent

Keep in mind that the debugger interferes with the program - especially when real time behavior is involved. Read this chapter for ways...

Using GDB Under Emacs

Some useful information here. M-x speedbar could be really handy here.

Text User Interface

The GDB Text User Interface (TUI) is a terminal interface which uses the ‘curses’ library to show the source file, the assembly output,...

Extending GDB

Sequences User Defined Commands You can assign a name to a sequence of commands. You can allow for arguments. They are accessed using...

Controlling GDB

Prompt You can change the prompt. If yoru gdb has python scripting enabled, you have prompt extensions. Command History You can set the...

Configuration-Specific Information

While nearly all GDB commands are available for all native and cross versions of the debugger, there are some exceptions. This chapter...

Debugging Remote Programs

This section has information on how to do remote debugging.

Specifying a Debugging Target

This is when you want to debug remotely or on a different architecture.

GDB Files

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

Altering Execution

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

Examining the Symbol Table

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

Using GDB With Different Languages

If gdb doesn’t figure out the language automatically, you can set it using set language. show language shows the current language. This...

Debugging Programs That Use Overlays

If your program is too large to fit completely in your target system’s memory, you can sometimes use “overlays” to work around this...

Tracepoints

In some applications, it is not feasible for the debugger to interrupt the program’s execution long enough for the developer to learn...

Debugging Optimized Code

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

Examining Data

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

Examining Source Files

Printing Source Lines Note: You can use GDB with Emacs, and viewing the source via Emacs is convenient. list prints 10 lines. To change...

Examining The Stack

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

Recording Inferior’s Execution and Replaying It

On some platforms, GDB provides a special “process record and replay” target that can record a log of the process execution, and replay...

Running Programs Backward

Sometimes you realize that you went past the interesting point in your program. Occasionally you can rewind if the target environment...

Stopping and Continuing

To break conditionally, do: break ... if COND … could be a function, location, address, etc. You can set a breakpoint such that it...

Running Programs Under GDB

You can modify the environment so that your program runs as if in that environment (and not the environment gdb was launched under). See...

GDB Commands

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

Invoking GDB

To attach to a running process, do: gdb PROGRAM Another way to attach is from within gdb: attach To detach, do detach. If...

Basic Info

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