If you really can't call gdb, but want the backtrace, like the ones it provides, you could just copy the gdb source bit that is needed for this to your project. Obviously, just calling gdb will be easier, more maintainable, and less eyebrow, so maybe you just need to do this.
John zwinck
source share