How to print backtrace in a freebsd machine?

1k views Asked by At

I have written a code to print backtrace in a linux machine using a backtrace function call specified in the "execinfo.h" header file. I need to get this code working on a freebsd machine as well. I am getting a compiler error for "execinfo.h" in Freebsd machines. I am thinking of using conditional macros to solve the problem, but I am not able to find a proper documentation for printing backtrace in Freebsd machines.

2

There are 2 answers

0
arved On

Up to FreeBSD 10:

libexecinfo is available as devel/libexecinfo in FreeBSD ports. If it does not work you should report the error.

Later versions have libexecinfo in the base system.

0
Felipe On

For those who come in modern times to this thread, just use -lexecinfo. See man backtrace.