Reputation: 30158
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.
Upvotes: 14
Views: 15066
Reputation: 93478
Usually with the command below when the application has finished executing:
(gdb) thread apply all bt
Of course, if you want to know the exact line you must compile your application with debugging symbols, i.e. -g
Upvotes: 9
Reputation: 12737
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, maybe break _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 the where
command to get a stack trace showing where you were when the program decided to exit.
Upvotes: 20