Not Really a Blog

October 3, 2006

Mini tutorial on gdb

Filed under: Programming — Tags: , , , — jesus @ 02:43

Thanks to Matthew:

gdb --args program/to/debug --whatever
break Foo.c:532
# to put a breakpoint at line 532 of Foo.c
run # to run it, until it hits that line
bt # to display the stacktrace (backtrace)
frame 2 # to change the stack frame you're looking at
list # to list the sourcecode for that stack frame
step # to step into the next command for that frame
next # to run the code to the next command
continue # to continue onwards
print bar # to print the contents of variable bar
printf  "%08x", bar # standard printf for bar
delete 2 # to remove the 2nd breakpoint

Obviously, you need to compile things with -g as an argument to GCC.

The Shocking Blue Green Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 2,872 other followers