我希望启用这样的功能,即当某些程序(比如我自己的 prog1、prog2 等)被 linux 作为服务守护进程启动时,或在 shell 中启动时,gdb 会自动启动以运行这些程序程序。
在 Windows 上,我可以使用 gflags 将可执行文件与调试器相关联。如何在 Linux 上执行此操作?我正在运行 ubuntu 16.04
谢谢!
最佳答案
您可以考虑编写一个简单的包装器以在启动守护进程后自动运行 gdb。
请查看 man gdb
。
You can, instead, specify a process ID as a second argument, if you want to debug a running process:
gdb program 1234
would attach GDB to process 1234 (unless you also have a file named 1234; GDB does check for a core file first).
关于Linux:如何设置 gdb 和可执行文件之间的关联?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39739557/