Tag Archives: linux

GDB Init Files Save Time At Startup

I can’t leave the subject of GDB alone for too long, so today I thought I’d talk about GDB init files. Each time GDB is run, it checks first your home directory and then the current directory for the existence of a file called .gdbinit. If it finds this file, it reads the contents and […]

GDB Conditional Breakpoints

Last week we looked at setting breakpoints in GDB. All well and good. But what if you have a large loop running and you only want to look at what’s happening as it nears the end? Do you really have to step through 99 iterations in a 100 item loop? Of course you don’t. Step […]

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 […]