I have a program written in C that runs on Linux, MacOS and Windows. Is there a way I can call a function and generate a stack trace? This would be super-useful for me. Ideally I’d like to do it on all three platforms, but Linux is the most important. (Windows is being compiled via mingw.)
Thanks.
For example, in GCC and the GNU
libcC library, you can usebacktrace().As @slugonamission suggests, Windows offers
CaptureStackBackTrace()– thanks!Other platforms may offer similar features.
(This is obviously a platform-dependent question.)
(On a related note, there also exist self-disassembly libraries.)