(gdb) break *0x972

Debugging, GNU± Linux and WebHosting and ... and ...

Run GDB until the Application Segfaults

I'm trying to debug a race condition that crashes the application only once every ~15 runs of 3-4 minutes. I want a GDB prompt on that crash, and not only a core dump.

The naive way is to start gdb, run the application, wait for its termination, and restart it if it didn't crash.

A better alternative is to automatize it:

(gdb) py gdb.events.exited.connect(lambda evt : gdb.post_event(lambda : gdb.execute("run")))

Step-by-step, gdb.events.exited.connect() registers an exit-event callback, that posts an asynchronous command gdb.post_event() (otherwise that would create a recursion, and maybe end up with a stack overflow), that restarts the execution gdb.execute("run").