简体   繁体   English

使gdb在启动时自动执行命令

[英]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? 有没有办法让它永久化或配置gdb使其在其设置中?

Create a file ~/.gdbinit containing: 创建一个包含以下内容的文件〜/ .gdbinit:

handle SIGPIPE nostop noprint pass 

the contents of this file are just standard gdb commands, and are executed each time gdb is started. 此文件的内容只是标准的gdb命令,并在每次启动gdb时执行。

It is also possible to have project specific .gdbinit files. 也可以使用项目特定的.gdbinit文件。 Imagine your project directory is: /home/user/my-project/ and this is where you start gdb from when debugging your project. 想象一下你的项目目录是: /home/user/my-project/这是你从调试项目时启动gdb的地方。 First add this line to your ~/.gdbinit: 首先将此行添加到〜/ .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. 然后创建一个文件/home/user/my-project/.gdbinit将特定于此项目的任何gdb命令放入这个新的.gdbinit文件中,并且每次在项目目录中启动gdb时都会执行它们。

GDB将在每次启动时运行〜/ .gdbrc文件中的所有命令,因此您可以将该命令放入其中,以便每次启动gdb时自动执行该命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM