Hacker News new | past | comments | ask | show | jobs | submit login
Programmatic access to the call stack in C++ (thegreenplace.net)
82 points by kilimchoi on July 15, 2015 | hide | past | favorite | 9 comments



I find it pretty annoying how often things are advertised as C++ but are Unix specific. As someone who ships Windows + OS X + Linux I'm pretty biased though.

Anyhow, there's pretty good support for stack traces on Win64. For 32 bit it's less good. https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...


dwarf debug info is a part of x86_64 abi


Cool thanks for mentioning libunwind. I had used backtrace() and libexecinfo where that was not available with not as good results.


gperftools also uses libunwind and does some nice timing and performance analysis for cpu and heap. https://code.google.com/p/gperftools/


libunwind is awesome. It uses the same information for its job that the actual compiler uses for unwinding exceptions in C++, etc (DWARF .eh_frame & co). It's also much more portable these days (I believe backtrace() is glibc-specific). There are also remote unwinding capabilities I want to play with



Ah cool.

But I'm fairly sure that these days os x uses libcxx which uses libunwind


I seem to recall them implementing the unwind interface but with standard rbp/ebp unwinding. As in http://www.opensource.apple.com/source/Libc/Libc-498.1.1/gen... and http://www.opensource.apple.com/source/Libc/Libc-825.25/gen/...

My biggest problem with "standard" libunwind is how slow it is compared to a whole loop against the registers (which of course isn't reliable with -fomit-frame-pointer). IIRC, the gcc's call to backtrace actually parses DWARF to work around this (and thus is super slow).


Yes backtrace() and friends is a glibc thing, but libexecinfo tries to be compatible and portable. Back when I used backtrace(), that was about the best there was, and it was not that great really. I'm glad I know about libunwind now thanks to this post.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: