Tom wrote:
> Thanks for that. But that is not what I am looking for really. I
> already have a die handler which traps any perl errors. I would like
> to access the stack trace from that C code and write it to log.

You mean you want a C stack when you crash in XS?

Perl doesn't know how to do that.  Perl knows how to unwind the perl stack,
which happens from the Carp modules.  Croaks from inside XS code will unwind
the perl stack just fine.

If you want a C stack to prepend to the perl stack, you need something
non-portable, like glibc's backtrace_symbols().  It won't be very
illuminating, though, as it's just function names and return addresses, and
without debugging symbols, you just get return addresses.  Something else cool
is to attach a debugger to yourself and do "backtrace full", but that, too, is
nonportable, and also requires gdb in the user's path.

http://www.gnu.org/software/libtool/manual/libc/Backtraces.html


-- 
muppet <scott at asofyet dot org>

Reply via email to