使用 pid 启动 gdb
一般来说,我看到进程的 pid 正在后台运行,并使用命令 dbx -a
类似地,我如何使用数据库?
In general i see the process's pid
which is running in the background and start dbx on that process using the command dbx -a <pid>
similarly how could i do it using gdb?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除了前面的还可以直接使用
In addition to the previous you can directly use
有两种方法。
从命令行,在可执行文件名称后包含 pid 作为参数:
在 gdb 中,您可以使用 Attach 命令:
虽然命令行上的指定更简洁,但如果您有 core 文件,则存在轻微风险其名称与 pid 相同(即,对于 pid 2345,核心文件必须命名为“2345”),然后 gdb 将打开该核心文件。诚然,这种情况发生的可能性微乎其微。
There are two ways.
From the command line, include the pid as an argument after the executable name:
From within gdb, you can use the attach command:
While the specifying on the command line is more concise, there is a slight risk that if you have a core file that has a name that is the same as the pid (i.e. for pid 2345, the core file would have to be named "2345") then gdb will open the core file. Admittedly, the chance of this happening is minuscule.
从 gdb 手册页:
如果您想调试正在运行的进程,您可以指定进程 ID 作为第二个参数:
From the gdb man page:
You can, instead, specify a process ID as a second argument, if you want to debug a running process: