我希望启用这样的功能,即当某些程序(如我自己的 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).