I'm trying to get the stack backtrace of a running process (PID and binary path are known) from another program. The program in question is written in C++ and compiled with g++ with gdb debugging symbols.
I'm looking for a C or C++ library that works across Linux, HP-UX and Solaris that produces an output similar to the output of calling popen() with something like this:
gdb -batch -x /dev/stdin <BINARY> <PID> << EOF
thread apply all bt
EOF
I have found lsstack ( http://sourceforge.net/projects/lsstack/ ), which is Linux only and know the pstack program for Solaris.
Does anyone know of a reliable way of doing this cross Unix / POSIX?