开发者

How to save settings in gdb?

Does anyone know how to save gdb settings (like "set print pretty on" or "set print elements 0", both from here)? I don't want to set my 开发者_JS百科configuration every time that I will use gdb :/

I searched in google and SO, but I found nothing.


Add any commands you want to auto run in the .gdbinit file in your home directory.


The existing answer works for commands that can run before the binary is loaded, but for example if you want to add catch throw you cannot do it in .gdbinit since that command needs to run after the binary is loaded.

But gdb can take a file with commands to run after binary loading using:

-x file
       Execute GDB commands from file file.

I automated that by creating an alias:

alias gdb='gdb -x ~/.gdbinit_x'

and added my after binary load commands in that file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜