I try to debug a C program using gdb (not in the interactive mode). In the program, I use signal to inspect the segmentation fault, but I use gdb to find the location of the code.
If I use
gdb -ex "handle SIGSEGV stop print pass" ./script -ex "run"
It catches the error in both gdb and the program, but I need to type continue
to debug the rest of the code.
If I use
gdb -ex "handle SIGSEGV nostop print pass" ./script -ex "run"
gdb only prints Thread 86241 "server-ev" received signal SIGSEGV, Segmentation fault.
without printing the line of code that caused the error.
I also tried config file with
define handle_sigsegv
bt
continue
end
but no luck.
How can I script gdb (with no interaction) to print the SIGSEGV, including the error line, and continue?