This gdb script will run the program 100 times or until it receives a signal. $_siginfo is non-empty if the program is stopped due to a signal and is invalid if the program exits. As far as I can tell, any process shutdown, including breakpoints, watchpoints and a single click, will set $_siginfo to something.
set $n = 100 while $n-- > 0 printf "starting program\n" run if $_siginfo printf "Received signal %d, stopping\n", $_siginfo.si_signo loop_break else printf "program exited\n" end end
Mark plotnick
source share