Question

I am debugging a program under linux with GDB, the program contains bugs of course, what I want is to run the debug version of the program, and when it encounters error, dump the stack trace before it exits.

Était-ce utile?

La solution 2

(assuming you are asking how to do this in gdb)

In gdb, backtrace (or bt) is the command you want to use after you encounter an error. It will print full stack trace.

After that you can use "frame" and various "info" commands to switch frames and examine things.

Autres conseils

you can use the backtrace() functions in execinfo.h to print a stacktrace

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top