如何使gdb每次启动时都运行用户定义的函数(在.gdbinit中定义)?

TCS*_*rad 7 debugging gdb

setup在.gdbinit 中的用户定义的fn 中定义了一组基本断点.所以,每次我启动gdb,我都必须执行那个fn.在开始调试之前设置我的所有brkpoints.我可以配置我的.gdbinit,以便每当它启动时,它首先执行我的用户定义的fn setup吗?

Kim*_*ais 11

只需按功能名称调用它:

我的.gdbinit:

define setup    
  echo Foobar\n
end   

setup #This is the function call
Run Code Online (Sandbox Code Playgroud)

当我运行它:

$ gdb
GNU gdb Fedora (6.8-37.el5)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Foobar
(gdb) 
Run Code Online (Sandbox Code Playgroud)