Archive for the ‘gdb’ Category

Debugging with gdb: a couple of notes

July 14, 2011 Leave a comment

While debugging with gdb, one can use the following gdb command to instruct gdb to continue when a SIGPIPE signal is sent to the program being debugged.

(gdb) handle SIGPIPE nostop

Every time when a SIGPIPE command is fired, one will see the following on the gdb console

Program received signal SIGPIPE, Broken pipe.

The nostop gdb command should take care of most of the situations where user interaction is not required. However if the information to be printed by gdb exceeds one screen, the following prompt will appear

---Type <return> to continue, or q <return> to quit---

due to the fact that gdb has pagination on by default, meaning if the erroneous output from gdb exceeds a screen, gdb will ask user for actions.

The reason behind that, I guess, is that gdb doesn’t want the important information to be missed since the top most lines will be scrolled out of the screen (default number lines per screen is 68 in gdb). This is useful when debugging in interactive mode, however it’ll also pause the program. If this is not desired, simply use the following gdb command to turn off pagination:

(gdb) set pagination off

Or alternatively,

(gdb) set height 0


Categories: debugging, gdb