JustKernel

Ray Of Hope

To get stacktrace for the program in execution.

Many times its required to get the stack trace during the execution of a program eg . you suspect a particular point in the code to be a possible crash point or whenever you create or kill a thread you want a stack trace or normally you want stack trace at different points of a program execution.

 

backtrace and backtrace_symbol is the command that will come to your rescue.

backtrace() returns a backtrace for the calling program, in the array pointed to by the buffer. Given the set of addresses returned by backtrace() in buffer, backtrace_symbols() translates the addresses into an array of string that describes the addresses symbolically.

You can’t always use gdb to with the program, in that scenario the above two calls will definitely provide you with the similar functionality.

Anshul Makkar, anshul_makkar@justkernel.com

Originally Posted On: 2011-04-02 13:11:02


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.