Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make gdb to automatically execute a command on startup

Tags:

debugging

gdb

I always need to type:

handle SIGPIPE nostop noprint pass 

Is there a way to make it permanent or to configure gdb to have it in its settings?

like image 921
yo tootles Avatar asked Mar 05 '13 00:03

yo tootles


Video Answer


1 Answers

Create a file ~/.gdbinit containing:

handle SIGPIPE nostop noprint pass 

the contents of this file are just standard gdb commands, and are executed each time gdb is started.

It is also possible to have project specific .gdbinit files. Imagine your project directory is: /home/user/my-project/ and this is where you start gdb from when debugging your project. First add this line to your ~/.gdbinit:

add-auto-load-safe-path /home/user/my-project/.gdbinit

Then create a file /home/user/my-project/.gdbinit place any gdb commands that are specific to this project into this new .gdbinit file and they will be executed every time you start gdb in the project directory.

like image 75
Andrew Avatar answered Nov 13 '22 07:11

Andrew