Exercise 4. Using a Debugger

This is a video-focused exercise where I show you how to use the debugger that comes with your computer to debug your programs, detect errors, and even debug processes that are currently running. Please watch the accompanying video to learn more about this topic.

GDB Tricks

Here’s a list of simple tricks you can do with GNU Debugger (GDB):

gdb --args Normally, gdb takes arguments you give it and assumes they are for itself. Using --args passes them to the program.

thread apply all bt Dump a backtrace for all threads. It’s very useful.

gdb --batch --ex r --ex bt --ex q --args Run the program so that if it bombs, you get a backtrace.

GDB Quick Reference

The video is good for learning how to use a debugger, but you’ll ...

Get Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.