title: c++ stack trace from unhandled exception?
body: <p>This question has been asked before and there have been windows-specific answers but no satisfactory gcc answer. I can use <code>set_terminate()</code> to set a function that will be called (in place of <code>terminate()</code>) when an unhandled exception is thrown. I know how to use the backtrace library to generate a stack trace from a given point in the program. However, this won't help when my terminate-replacement is called since at that point the stack has been unwound. </p>
  
  <p>Yet if I simply allow the program to <code>abort()</code>, it will produce a core-dump which contains the full stack information from the point at which the exception was thrown.  So the information is there -- but is there a programmatic way to get it, for example so it can be logged, rather than having to examine a core file?</p>