You can install stop hook hook-stop
and use shell
followed by a command so it get executed when ever the debugger stops, for example running cmd
(Windows) so it echo some string from the shell on stop:
define hook-stop
shell cmd /c echo "hello"
end
Replace cmd /c echo "hello"
with the command you want, and copy it and past it in the debugger, now when my program crushes:
#include <stdio.h>
int main(int argc, char **argv) {
int *p = NULL;
printf("%d\n", *p);
return 0;
}
I should see "hello":
> gdb -q a.exe
Reading symbols from a.exe...done.
(gdb) define hook-stop
Type commands for definition of "hook-stop".
End with a line saying just "end".
> shell cmd /c echo "hello"
>end
(gdb) run
Starting program: a.exe
[New Thread 420.0x430]
Program received signal SIGSEGV, Segmentation fault.
"hello"
0x004013a6 in main ()
(gdb)