I'd like to log the call trace during certain points, like failed assertions, or uncaught exceptions.
UPDATE: Thanks for the answers.. followup question... how do you do the same in a thread other than the main thread?
Neither method properly displayed the stack in such a case. The output is nonsensical wrt to the current context. However if I break in the debugger on the same point, I see the correct trace for that thread. Unfortunately I cannot reproduce the problem in the debugger that I need a stack trace for.