Tuesday, September 21, 2004

 

Command Line GDB

The NetOS development kit comes with a Tcl/Tk GUI version of GNU Debugger (gdb). I could not figure out how to drive it, and ended up using command line gdb. While I'd toyed with gdb in the past, mainly doing post mortems on core dumps, this was the first project on which I'd used it seriously. I wish I'd started long ago. This program is phenomenal.

You can set a breakpoint, then program a bunch of stuff to happen when the breakpoint fires. The last command in that sequence can be a "continue", so you can do printf debugging without changing the executable!

These are my favorite gdb commands:

p print p structure.element
b break b file:line
c continue c
^c break execution
clear clear break clear file:line

b file:line gives you a breakpoint number e.g., 1
To set the command sequence for break 1:
commands 1
p structure.element
c
end

this sequence prints the contents of structure.element and continues execution.

Larry Martin
www.GlueLogix.com
Copyright (c) 2004 Larry Martin. All Rights reserved.

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?