If you start your program through gdb with a command like gdb myprogram, you'll have gdb monitoring your program throughout its execution. Since gdb catches signals, you can just let your program run and let gdb catch it when it SEGFAULTs.