While debugging a program in GDB, I get an unexpected "program exited normally". So I'm wondering if is there a way to find out from where (which line) the program exited.
Program is multi-threaded, if that matters.
gdb
While debugging a program in GDB, I get an unexpected "program exited normally". So I'm wondering if is there a way to find out from where (which line) the program exited.
Program is multi-threaded, if that matters.
Best Answer
You could try the GDB command
break exit
to set a breakpoint on the exit(2) library call. If that doesn't get you what you need, maybebreak _exit
. You might need to start your program with 'sta' before getting the latter breakpoint to take. In either case, you should then be able to use thewhere
command to get a stack trace showing where you were when the program decided to exit.