防止调试会话在每个下级退出后暂停 [英] Preventing debugging session from pausing after each inferior exits
问题描述
gdb
非常方便的多重支持: (gdb)set off-b
(gdb)在
(gdb)上设置schedule-multiple设置follow-fork-mode父
(gdb)break PostgresMain
(gdb)break PostmasterMain
现在需要让事情运行,直到我打到一些未来的断点尚未被产生
但是,如果劣势正常退出或至少阻止, gdb 似乎是有帮助的暂停清理下级,以便其父级的 wait()
可以返回:
(gdb)c
[新进程16505]
进程16505正在执行新程序:/ home / craig / pg / bdr / bin / pg_config
从/ home / craig / pg读取符号/bdr/bin/pg_config...done。
[下方2(进程16505)正常退出]
(gdb)info劣质
数量描述可执行文件
* 2< null> / home / craig / pg / bdr / bin / pg_config
1进程16501 / usr / bin / make
(gdb)inferior 1
[切换到劣等1 [进程16501](/ usr / bin / make)]
[切换到线程1(进程16501)]
#0 0x0000003bc68bc502在__libc_wait(stat_loc = 0x7fffffffbc78)at ../sysdeps/unix/sysv/linux/wait.c: 30
30返回INLINE_SYSCALL(wait4,4,WAIT_ANY,stat_loc,0,
(gdb)
所以我必须无休止地:
(gdb)劣1
(gdb)c
继续约70次,之前我在孩子的孩子的小孩身上打了所需的断点
我认为发生的是 gdb
将进程退出视为停止事件,并且由于不停止
设置为 off
(默认值),它会阻止所有下级的所有线程当一个线程但是,这个劣势已经终止,这不是一个正常的停止事件,所以你不能只是 cont
,你必须首先切换到另一个进程。
有没有办法阻止gdb在每个下级退出时暂停?我会预期 follow-fork-mode parent with schedule-multiple on
来做这个伎俩,但是 gdb
似乎仍然希望在劣势退出时停止。
我想我正在寻找像skip proc-exit或虚拟信号,我可以改变处理程序政策,因此不会停止。
设置不停在
似乎应该是正确的答案,但我怀疑它是多个下级破碎。
如果我在上使用不停,那么在第一个退出陷阱之后,
gdb
的内部状态表示劣等1正在运行:
(gdb)info劣
数量描述可执行
* 1进程20540 / usr / bin / make
(gdb)信息线程
Id目标ID框
* 1进程20540make(运行)
(gdb)cont
继续。
所选线程正在运行时无法执行此命令。
但是内核看起来在 ptrace_stop
:
$ ps -ocmd,wchan-p 20540
CMD WCHAN
/ usr / bin / make check ptrace_stop
...它直到 gdb
已分离,否则将被杀死。对该过程的信号将被忽略, gdb
中的中断
不起作用。
我在x86_64上使用了 GNU gdb(GDB)Fedora 7.7.1-18.fc20
。
绊倒一个引用它的帖子我发现失踪的魔法是设置目标异步在
旁边停止在
。
不停模式,正如预期的那样,意味着gdb不会停止一切,当一个劣质退出。需要使用 target-async
使其在gdb 7.7上正常工作;这是7.8的默认值。
所以完整的咒语是:
set detach-on-fork off
set schedule-multiple on
set follow-fork-mode parent
设置不停在
上设置target-async
对于7.8,在上删除 target-async,并减少噪音,添加
设置打印符号加载关闭
。
I'm debugging a tree of processes using gdb
's very handy multiple-inferior support:
(gdb) set detach-on-fork off
(gdb) set schedule-multiple on
(gdb) set follow-fork-mode parent
(gdb) break PostgresMain
(gdb) break PostmasterMain
and now need to let things run until I hit one of the future breakpoints in some yet to be spawned inferior.
However, gdb
seems to be "helpfully" pausing whenever an inferior exits normally, or at least blocking cleanup of the inferior so that its parent's wait()
can return:
(gdb) c
[New process 16505]
process 16505 is executing new program: /home/craig/pg/bdr/bin/pg_config
Reading symbols from /home/craig/pg/bdr/bin/pg_config...done.
[Inferior 2 (process 16505) exited normally]
(gdb) info inferior
Num Description Executable
* 2 <null> /home/craig/pg/bdr/bin/pg_config
1 process 16501 /usr/bin/make
(gdb) inferior 1
[Switching to inferior 1 [process 16501] (/usr/bin/make)]
[Switching to thread 1 (process 16501)]
#0 0x0000003bc68bc502 in __libc_wait (stat_loc=0x7fffffffbc78) at ../sysdeps/unix/sysv/linux/wait.c:30
30 return INLINE_SYSCALL (wait4, 4, WAIT_ANY, stat_loc, 0,
(gdb)
so I have to endlessly:
(gdb) inferior 1
(gdb) c
to carry on. About 70 times, before I hit the desired breakpoint in a child of a child of a child.
I think what's happening is that gdb
treats process exit as a stop event, and since non-stop
is set to off
(the default) it stops all threads in all inferiors when one thread stops. However, this inferior has terminated, it isn't a normal stop event, so you can't just cont
it, you have to switch to another process first.
Is there some way to stop gdb pausing at each inferior exit? I would've expected follow-fork-mode parent
with schedule-multiple on
to do the trick, but gdb
seems to still want to stop when an inferior exits.
I guess I'm looking for something like a "skip proc-exit", or a virtual signal I can change the handler policy on so it doesn't stop.
set non-stop on
seems like it should be the right answer, but I suspect it's broken for multiple inferiors.
If I use non-stop on
, then after the first exit trap, gdb
's internal state indicates that inferior 1 is running:
(gdb) info inferior
Num Description Executable
* 1 process 20540 /usr/bin/make
(gdb) info thread
Id Target Id Frame
* 1 process 20540 "make" (running)
(gdb) cont
Continuing.
Cannot execute this command while the selected thread is running.
but the kernel sees it as blocked on ptrace_stop
:
$ ps -o "cmd,wchan" -p 20540
CMD WCHAN
/usr/bin/make check ptrace_stop
... and it makes no progress until gdb
is detached, or it's killed. Signals to the process are ignored, and interrupt
in gdb
has no effect.
I'm using GNU gdb (GDB) Fedora 7.7.1-18.fc20
on x86_64.
After stumbling on a post that references it in passing I found that the missing magic is set target-async on
alongside set non-stop on
.
non-stop mode, as expected, means gdb won't stop everything whenever an inferior exits. target-async
is required to make it actually work correctly on gdb 7.7; it's the default on 7.8.
So the full incantation is:
set detach-on-fork off
set schedule-multiple on
set follow-fork-mode parent
set non-stop on
set target-async on
For 7.8, remove target-async on
and, to reduce noise, add set print symbol-loading off
.
这篇关于防止调试会话在每个下级退出后暂停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!