How can I rerun a program with gdb until a segmentation fault occurs?

Viewed 22379

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?

2 Answers
(gdb) set pagination off
(gdb) break exit
(gdb) commands
>run
>end
(gdb) run
Related