我如何使用gdb重新运行程序,直到发生分段错误? [英] How can I rerun a program with gdb until a segmentation fault occurs?
问题描述
所以问题是,有什么办法可以告诉GDB重新运行程序,直到出现段错误?
在程序的出口放置一个断点,触发 run
命令,并且不要忘记关闭设置分页
。关于设置命令的信息可以在断点命令列表部分gdb文档简而言之:
设置分页关闭
分页结束
命令
运行
结束
在命令
行之后,您会看到接下来的两行是bein g作为要在达到断点时执行的命令输入。
My program has a segmentation fault problem, but it faults rarely(once in 20 times or more), and to debug it in GDB, I need to manually rerun the program until the segmentation fault occurs (during a half day of reruns only once it fails :( ).
So the questions is, is there any way to tell the GDB to rerun program until some segfault?
Put a breakpoint at the exit of your program that triggers the run
command, and don't forget set pagination off
. Information on settings commands is available in the Breakpoint Command Lists section of the gdb documentation. In short:
set pagination off
break exit
commands
run
end
After the commands
line you'll see that the next two lines are being entered as the command to execute when the breakpoint is reached.
这篇关于我如何使用gdb重新运行程序,直到发生分段错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!