7

Glibc provides the very handy backtrace() and backtrace_symbols() functions, which can help getting the stack trace of the current function programmatically (see here).

Does the Windows API provide any similar functions?

1 Answers1

8

Yes, take a look at the function CaptureStackBackTrace(). Use SymFromAddr() and its counterparts to get meaningful symbol names.

2501
  • 25,460
  • 4
  • 47
  • 87
  • Nice, thanks! This is almost exactly what I'm looking for. It would also be nice to be able to convert the addresses returned by that function into corresponding symbol names. –  Oct 16 '14 at 07:04
  • 1
    @Grigory That is what SymFromAddr() does. – 2501 Oct 16 '14 at 07:06
  • 1
    Nvm, I think I found an example of how to do it in this question: http://stackoverflow.com/questions/22467604/how-can-you-use-capturestackbacktrace-to-capture-the-exception-stack-not-the-ca –  Oct 16 '14 at 07:06