gdb控制/屏蔽信号

来源:互联网 发布:梦幻西游mac版快捷键 编辑:程序博客网 时间:2024/04/29 22:08

http://blog.sina.com.cn/s/blog_48ebca64010005a6.html

gdb中如何屏蔽信号
 
某些涉及到信号处理的程序该如何用gdb来调试呢?例如,进程需要捕捉SIGINT信号,但是在gdb中直接按“ctrl C"肯定不行,因为缺省情况下只有gdb接收到该信号,那么,该怎么办呢?
在gdb中,看一下帮助吧:
(gdb) help handle
Specify how to handle a signal.
Args are signals and actions to apply to those signals.
Symbolic signals (e.g. SIGSEGV) are recommended but numeric signals
from 1-15 are allowed for compatibility with old versions of GDB.
Numeric ranges may be specified with the form LOW-HIGH (e.g. 1-5).
The special arg "all" is recognized to mean all signals except those
used by the debugger, typically SIGTRAP and SIGINT.
Recognized actions include "stop", "nostop", "print", "noprint",
"pass", "nopass", "ignore", or "noignore".
Stop means reenter debugger if this signal happens (implies print).
Print means print a message if this signal happens.
Pass means let program see this signal; otherwise program doesn't know.
Ignore is a synonym for nopass and noignore is a synonym for pass.
Pass and Stop may be combined.
 
缺省情况下,是stop/nopass/print的,如前所述,如果我们需要在被调试进程中捕捉SIGINT信号,那么这样做:
handle SIGINT pass
handle SIGINT nostop

原创粉丝点击