Sample Video Frame

Created by Zed A. Shaw Updated 2024-07-21 04:57:00

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 Quick Reference

The video is good for learning how to use a debugger, but you'll need to refer back to the commands as you work. Here is a quick reference to the GDB commands that I used in the video so you can use them later in the book:

LLDB Quick Reference

In OS X, you no longer have GDB and instead must use a similar program called LLDB Debugger (LLDB). The commands are almost the same, but here's a quick reference for LLDB:

You can also search online for quick reference cards and tutorials for both GDB and LLDB.

Valgrind

In the videos I will frequently use a tool called Valgrind, or a similar tool to perform memory checks of my code. I don't explicitly use this tool in the book and instead say "the debugger" to refer to GDB, LLDB, Valgrind, anything you can use to analyze your code. Watch the videos to see me use Valgrind and many other tools to check my C source code, and especially the video for this exercise.

Previous Lesson Next Lesson

Register for Learn C the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.