سؤال

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.

هل كانت مفيدة؟

المحلول 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.

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top