skipper
skipper

Reputation: 255

How to dump stack trace in linux

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.

Upvotes: 1

Views: 4821

Answers (2)

dbrank0
dbrank0

Reputation: 9476

(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.

Upvotes: 1

Venkatesh K
Venkatesh K

Reputation: 4594

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

Upvotes: 3

Related Questions