GDB - how to find out where the program came from

When debugging a program in GDB, I get an unexpected "program that worked fine." So I wonder if there is a way to find out where (from which line) the program came from.

The program is multithreaded, if that matters.

+6
source share
3 answers

Usually with the command below when the application completed execution:

(gdb) thread apply all bt 

Of course, if you want to know the exact string, you must compile the application using debugging symbols, i.e. -g

+6
source

You can try the GDB break exit set a breakpoint when calling exit (2). If this does not help you, perhaps break _exit . You may need to run your program with "sta" before getting the last breakpoint. In any case, you should use the where command to get the stack trace where you were when the program decided to exit.

+9
source

Set a breakpoint on _exit and then view the stack.

+3
source

Source: https://habr.com/ru/post/890705/


All Articles