...

/

The GNU Project Debugger (GDB)

The GNU Project Debugger (GDB)

Learn about the GNU Debugger (GDB), which is a powerful debugging tool for C, and learn how to run it and view a stack trace with it.

Debugging is the process of identifying the source of errors or bugs in our code, and analyzing the reasons for it. It can help with fixing code crashes, removing logical mistakes, and making our program more efficient.

What is a symbolic debugger?

A debugger is a program that runs other programs, and provides the ability to control the execution of that program, for example, by stepping through one line at a time, and inspecting variables as our program runs. When our program crashes, and UNIX gives us a vague error message, a debugger helps us figure out where it’s crashing, and (with the assistance of our brain) why it’s crashing.

Why not use printf?

A quick and easy method of debugging that doesn’t require a separate debugger program, is to sprinkle your code with printf statements that write to the screen, the values of various variables that you think are relevant and related to a crash (or other error). Some people call this adding “trace code” to your program.

The disadvantages of ...