?! HowTheFu.cc ?!
 
>> Recipe: Crepes

2022.12.27
Debugging with (C)GDB

Generally, debugging C/CPP is either incredibly slow or tedious. Plain GDB is incredibly strong and, in principle, fast, but actually using it is horrible. CGDB, a terminal-based front-end, actually shows the fucking code, so that's a (necessary) upgrade. You still need to enter GDB commands, hence this page as a quick start.

Resources:

Launching the debugger:

Commands

An empty command repeats the previous command

CGDB:

Program states:

Stepping:

Breakpoints:

"Watchpoints":

Frames:

Threads:

Printing values:

Reload files using lo or load.

Configuration

To remove the copyright dump on startup, edit/create the file ~/.config/gdb/gdbearlyinit and add the line:


set startup-quietly on

To make gdb settings persistent, edit/create the file ~/.config/gdb/gdbinit. Here is my current config:


set print pretty on
set pagination off
set confirm off
set history size 1000
set history save on
set history filename ~/.config/gdb/history
set disassembly-flavor intel


 
>> Recipe: Crepes
?! HowTheFu.cc ?!