Get backtrack of the running process stack

I am trying to get the backtrace stack of a running process (PID and binary path are known) from another program. This program is written in C ++ and compiled with g ++ using gdb debugging symbols.

I am looking for a C or C ++ library that works on Linux, HP-UX, and Solaris, which produces output similar to the output of a popen () call, with something like this:

gdb -batch -x /dev/stdin <BINARY> <PID> << EOF thread apply all bt EOF 

I found lsstack ( http://sourceforge.net/projects/lsstack/ ), which is Linux only and knows the pstack program for Solaris.

Does anyone know of a reliable way to execute this Unix / POSIX cross?

+6
c ++ c stack-trace unix
source share
1 answer

Do you need libunwind

+2
source share

All Articles