Debugging with gdb

When programming with C on Unix systems, the debugger of choice is gdb. It provides a robust command-line interface, allowing you to run a program while maintaining full control. For example, you may set breakpoints in the execution of the program and monitor the contents of memory or registers at any point you like. For this reason, debuggers like gdb are invaluable to programmers and hackers alike.

gdb Basics

Commonly used commands in gdb are shown in Table 6-6.

Table 6-6. Common gdb Commands
CommandDescription
b functionSets a breakpoint at function
b *memSets a breakpoint at absolute memory location
info bDisplays information about breakpoints
delete bRemoves a breakpoint
umrun <args>Starts debugging program from within gdb ...

Get Gray Hat Hacking, Second Edition, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.