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?
Best Answer
Put a breakpoint at the exit of your program that triggers the
run
command, and don't forgetset pagination off
. Information on settings commands is available in the Breakpoint Command Lists section of the gdb documentation. In short: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.