使用 pid 启动 gdb

发布于 2024-08-19 02:58:24 字数 90 浏览 4 评论 0原文

一般来说,我看到进程的 pid 正在后台运行,并使用命令 dbx -a在该进程上启动 dbx,

类似地,我如何使用数据库?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

彩虹直至黑白 2024-08-26 02:58:24

除了前面的还可以直接使用

gdb -p <pid>

In addition to the previous you can directly use

gdb -p <pid>
虐人心 2024-08-26 02:58:24

有两种方法。

从命令行,在可执行文件名称后包含 pid 作为参数:

gdb /path/to/prog PID

在 gdb 中,您可以使用 Attach 命令:

gdb /path/to/prog
gdb> attach PID

虽然命令行上的指定更简洁,但如果您有 core 文件,则存在轻微风险其名称与 pid 相同(即,对于 pid 2345,核心文件必须命名为“2345”),然后 gdb 将打开该核心文件。诚然,这种情况发生的可能性微乎其微。

There are two ways.

From the command line, include the pid as an argument after the executable name:

gdb /path/to/prog PID

From within gdb, you can use the attach command:

gdb /path/to/prog
gdb> attach PID

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.

天生の放荡 2024-08-26 02:58:24

从 gdb 手册页:

如果您想调试正在运行的进程,您可以指定进程 ID 作为第二个参数:

gdb program 1234

From the gdb man page:

You can, instead, specify a process ID as a second argument, if you want to debug a running process:

gdb program 1234
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文