Learning C with gdb
recurse.com
recurse.com
> Check out gdb’s “tui” mode
But that should be in the first paragraph. TUI mode shows the source code and the current line. This is like the difference between `ed` and `vi`: you can see the source code that you're debugging instead of mashing `bt` or whatever again and again.
To use gdb's TUI mode, simply include the `-tui` argument at the command line:
gdb -tui path/to/bin
or, at any time while running gdb, press `ctrl-x ctrl-a`.This isn't the oourse I took, but here's a good example of the lab: http://condor.depaul.edu/glancast/373class/docs/lab2.html
http://coursera.org/course/hwswinterface
The course takes a similar approach of starting with analyzing how C interacts with memory.
On another note, I LOVE gdb. One of my prof's begged and pleaded for us to use gdb with all of our assignments because he claimed it would make life easier. For our first two computer org classes, you might be able to skate by without it (except for the buffer bomb and binary bomb), but once you reached the third semester and beyond, those that didn't spend a little time acclimating themselves with gdb began to hate life.
I really do love gdb. It saved my ass more times than I can remember.
(I'm thinking specifically for C-on-Unix, but whatever you wish...)
I'm not saying gdb is not a great tool. It is especially useful when you don't have a debugger at all.
Haven't used DDD either but it looks interesting too:
Say what you will about PHP but even with all the inconsistencies of the language and syntax, the way it handles complex arrays is nothing short of magical when coming from a C background.
Edit: -O0 to disable most optimizations is also helpful when debugging.