Linux:如何设置 gdb 和可执行文件之间的关联?

标签 linux debugging process gdb associate

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

相关文章:

html - 在 chrome 中调试 http 请求

java - 如何在 Visual Studio Code 中修复 "Build failed, do you want to continue?"?

Python 多处理在连接处挂起

linux - 在 Linux 中获取日期的 Shell 脚本

c - 调试缓冲区溢出引起的段错误

c - 信号量权限被拒绝

c# - 如何 - 从进程列表中取消列出我的程序..?

linux - 如何在 Linux 中操作窗口

php - 如何设置php-fpm多线程工作?

python - 如何使用 setuptools 安装可写共享和用户特定数据文件?