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`.
tui mode is great. I would recommend this tutorial by beej [0] as an intro to gdb for those unfamiliar with it, it also has a very handy cheatsheet at the bottom [1].
One of the assignments I enjoyed the most was the "bomb lab". The bomb is a C program (w/ some Assembly required) that you have to defuse at certain phases in order for it to run to completion. It felt like a game more than an assignment, using and learning gdb along the way.
You can also use the -S flag of gcc to output assembly instead of binary, or if the program has already been compiled you can use objdump on it to read the assembly alongside the source code.
Interesting resource! I like this take on learning C.
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 quite like Eclipse's debugging support (for Java), though I haven't used it for C. I think you can get GDB integrated into Eclipse's CDT with breakpoints etc.
Haven't used DDD either but it looks interesting too:
I taught myself C as a young teenager (some time ago), only to much later learn languages with REPLs like Ruby, Scheme and Common Lisp. Using gdb in this way would have been an interesting learning experience... because back then I didn't know there was a such thing as a REPL!
This article reminded me of all the nasty headaches that C caused me back in the 80's, especially with how it handles arrays and memory management.
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.
That's really nice, being able to 'stop and look around' in ipdb for Python, node inspector for node etc has made those respectively so much easier to understand. Being able to do something similar for C is great.
> 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:
or, at any time while running gdb, press `ctrl-x ctrl-a`.