<p>Can someone please provide an implementation of a C function that gets invoked to dump the current stack? It's for a x86 linux system.  It can be invoked in 2 ways: explicitly by another function, or after a crash (probably as a trap/int handler).  The output can be either to the screen or to a file, as indicated by a parameter (handle).  A clear explanation/comments of how the stack is unwound would obviously be very helpful.  Thank you.</p>

following on Adam's answer, the source code that shows how to perform the actual stack backtracing is in gnu libc's backtrace(), under /libc/debug/backtrace.c  - not sure if the full link below will be accepted by stackoverflow's html filters...
http://cvs.savannah.gnu.org/viewvc/*checkout*/libc/debug/backtrace.c?root=libc&revision=1.1.2.1&content-type=text%2Fplain