fancy debugging with gdb

In emacs, you can start debugging your application with M-x gdb. If you come from a Eclipse/Visual Studio-background, you may find the experience somewhat spartan -- and the Spartans are known for many things, but debugging is not one of them. Still, I have debugged that way for years, until I only recently (really!) discovered gdb-many-windows. It's simple; start gdb inside emacs as you'd do normaly (M-x gdb), and after that, call M-x gdb-many-windows. This will split your frame ('window') in six buffers ('sub-windows'), something like the following:




gdb commandslocal variables / registers
source code
stackbreakpoints

I am usually a bit skeptical about putting too many GUI-distractions between me and my code, but this is really useful! All the information I need at my fingertips. Emacs is a place full of hidden treasures.

If we look at gdb itself, and compare it with e.g. the Visual Studio-debugger, there are still many features missing, even with gdb-many-windows. Of course, one could easily dismiss fancy debuggers as leading to bad programming practices - and there is some truth in that. But I think there is real value in at least some of the features. So, it's nice to see that there is progress in this area. One example is Python scripting support. Using that, it's much easier to have gdb print something reasonable when looking at std::string-objects or GErrors. Now if only we could use Elisp instead of Python...

If you are new to gdb, I would recommend you to read the GDB Tutorial, and after that the GDB User Manual. Gdb is a very powerful tool, but it requires some learning. Just like emacs.

No comments:

Post a Comment

Followers

Popular Posts