yo tootles
yo tootles

Reputation: 93

Make gdb to automatically execute a command on startup

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?

Upvotes: 7

Views: 10833

Answers (2)

Andrew
Andrew

Reputation: 4751

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.

Upvotes: 9

user2133808
user2133808

Reputation: 9

GDB will run all commands in your ~/.gdbrc file each time it starts, so you can place that handle command in their to have it automatically executed each time you start gdb.

Upvotes: 0

Related Questions