gpt4 book ai didi

c - 如何在gdb中附加多个正在运行的进程?

转载 作者:行者123 更新时间:2023-12-05 01:33:46 25 4
gpt4 key购买 nike

如何在 gdb 中附加多个正在运行的进程?
将一个进程附加到 gdb,gdb 无法附加第二个进程。

最佳答案

您可以添加另一个劣质。
这是示例 gdb session :

ks@ks-comp:~$ sleep 1d &
[1] 2917
ks@ks-comp:~$
ks@ks-comp:~$ sleep 2d &
[2] 2919
ks@ks-comp:~$
ks@ks-comp:~$ gdb -q
(gdb) attach 2919
Attaching to process 2919
Reading symbols from /bin/sleep...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.19.so...done.
done.
Loaded symbols for /lib/x86_64-linux-gnu/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/ld-2.19.so...done.
done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
0x00007f81492999a0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) add-inferior
Added inferior 2
(gdb) inferior 2
[Switching to inferior 2 [<null>] (<noexec>)]
(gdb) attach 2917
Attaching to process 2917
Reading symbols from /bin/sleep...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.19.so...done.
done.
Loaded symbols for /lib/x86_64-linux-gnu/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/ld-2.19.so...done.
done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
0x00007f159f0d29a0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) i inferiors
Num Description Executable
* 2 process 2917 /bin/sleep
1 process 2919 /bin/sleep
(gdb)
Debugging Multiple Inferiors and Programs

关于c - 如何在gdb中附加多个正在运行的进程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27527316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com