Tag Archives: unix

GDB Breakpoints

Today we’re going to take a quick look at the humble breakpoint in GDB. You can set a breakpoint: before you run the program in GDB if you interrupt GDB with CTRL-C Positioning your breakpoints Set a breakpoint using the handy shortcut ‘b’ followed by the location. There are lots of ways to specify the […]

GDB Tutorial Command Line Walkthrough : Part 3

Infinite loop Well, the segfault is gone, but now the code just runs in a continuous loop, which is arguably worse. Run the invader program from GDB and press Ctrl-C to halt execution. View a backtrace by typing bt to see where we are in the code (screenshot below). Note that in a larger, multi-threaded program, when […]

GDB Tutorial Command Line Walkthrough : Part 2

Track down those segfaults Now we’ve got an idea of how GDB works, lets look at a more complex example. The program in Listing 2 (see bottom of page) should print out a familiar character in your terminal window. It uses a C array called template to determine where to print out a character versus a space. […]

GDB Tutorial Command Line Walkthrough : Part 1

Master command line debugging with GDB Whether you’ve spent hours fine-tuning printf statements to track down a persistent bug, or you just fancy impressing someone with your command line skills, GDB has the answers. Introduction This tutorial will take a walk-through approach to finding the bugs in two short C programs, covering around two dozen […]