当我按ctrl时调试分段错误 [英] Debugging a segmentation fault when I do ctrl c

查看:126
本文介绍了当我按ctrl时调试分段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我取消我的程序时,出现分段错误。我正在使用gdb进行调试,问题是当我在调试时按下Ctrl-C时,gdb不会取消该程序,并执行它应该做的事,即停止它。



我想要的是按Ctrl-C并且不允许gdb停止它。有没有办法做到这一点?任何其他的调试建议?我无法使用printf,因为我诚恳地不知道问题来自哪里。

解决方案

gdb拦截信号。当你按下CTRL-C时,实际上是让终端驱动程序产生一个SIGINT。



你需要做的是让GDB使用信号命令。语法是
$ b



signal num


和man信号会告诉您信号编号(在这种情况下,SIGINT是信号2,所以信号2 )



更新



果然,您可以使用象征性的名字。 info signal 会告诉你所有的名字等。



哦,顺便说一下,为SIGINT安装的信号处理程序和参数不正确。


I get a segmentation fault when I cancel my program. I am using gdb for debugging, the problem is that when I press Ctrl-C while I am debugging gdb does not cancel the program and do what it is supposed to do that is stop it.

What I want is do the Ctrl-C and do not allow gdb to stop it. Is there any way to do this? Any other recommendations for debugging? I cannot use printf because sincerely I have not a clear idea where the problem comes from.

解决方案

gdb is intercepting the signal. When you press CTRL-C, you're actually causing the terminal driver to generate a SIGINT.

What you need to do is have GDB generate the SIGINT using the signal command. the syntax is

signal num

and man signal will tell you the signal number (in this case, SIGINT is signal 2, so signal 2 will do it.)

Update

Sure enough, you can use the symbolic name. info signal will tell you all the names etc.

Oh, by the way, odds are that you have a signal handler installed for SIGINT and the arguments aren't right somehow.

这篇关于当我按ctrl时调试分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆