Some gdb NotesWilliam T Krieger... Oct 2005 Enjoy this ever-so-brief overview of gdb, the Gnu debugger. The official documentation is at: http://www.gnu.org/software/gdb/documentation/ With a tiny learning curve, gdb will allow you to:
Compiling for gdbTo use gdb, you need to tell gcc that you want to debug your program using the -g option, like this:
Steering gdbOK, so you've assembled using -g, you've cranked up gdb, and now what... Well, you can issue commands to gdb to steer it in the direction that you want it to go. You can enter help and gdb will list all the groups of commands that it understands. Here is a list of the commands that I think you are most likely to use:
OK, a quick note on the "x" command to examine the values at memory locations. Usually, your memory location will come from some register, like -12(%ebp) or something. You'll want to use the memory location listed as the register's value when using the "x" command in the debugger. For example:
You can also use /x and /c for examining hexadecimal and character values. For more information, please enter "help x" into gdb. BTW, I have gotten gdb to crash on occasion. If it happens, try and set a different breakpoint to avoid the problem. Getting more helpGoogling this:
led me to these online gdb tutorials (like this one, but with more details and examples):
|