gdb如何设置信号的处理

来源:百度文库 编辑:神马文学网 时间:2024/04/29 15:47:36

gdb如何设置信号的处理

2008-08-12 02:02:09
  gdb调试的程序所注册的信号处理函数似乎不起作用,因此需要在gdb中设置对信号的处理,使用handle命令。可以设置stop,print,pass三种状态。(gdb) help handleSpecify how to handle a signal.Args are signals and actions to apply to those signals.Symbolic signals (e.g. SIGSEGV) are recommended but numeric signalsfrom 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 thoseused 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.(gdb) handle SIGPIPESignal        StopPrintPass to programDescriptionSIGPIPE       YesYesYesBroken pipe(gdb) handle SIGPIPE nostopSignal        StopPrintPass to programDescriptionSIGPIPE       NoYesYesBroken pipeps1:Linux内核对一个socket的fd write的时候如果另一端挂掉了,那么会出现抛出SIGPIPE信号,FreeBSD就比较酷,在05年的时候修正了这个无厘头的行为ps2:python默认会忽略SIGPIPE信号ref1:http://www.developerweb.net/forum/showthread.php?t=2953ref2:http://lists.freebsd.org/pipermail/freebsd-bugs/2005-March/011883.htmlref3:http://mail.python.org/pipermail/python-dev/2004-August/048174.html