On Thu, 23 Aug 2012, Diego Novillo wrote: > I think I would like to explore the idea of implement a stack > unwinder that's used by gcc_assert(). This way: (a) we do not > need to uglify all the APIs with these extra arguments, (b) we > can control how much of the call stack we show on an assertion. > > Would that be something difficult to implement? I don't think we > need something as generic as libunwind. Thoughts?
Stack unwinding is heavily host-specific. For example, on glibc hosts you can use backtrace () - but for many architectures this requires you to build with unwind tables enabled. To convert the addresses to function names you can use backtrace_symbols () - but that requires the program to be linked with -rdynamic so that the symbols are in the dynamic symbol table. (A plugin-enabled compiler will be linked with -rdynamic anyway.) Other hosts may or may not have such interfaces. In the presence of inlining, such interfaces may give less helpful results - and in any case they seem unlikely to give source line numbers, just function names. -- Joseph S. Myers jos...@codesourcery.com