htop icon indicating copy to clipboard operation
htop copied to clipboard

Export symbols for --enable-debug

Open BenBE opened this issue 4 years ago • 2 comments

Please carefully review, the following patches, as I might have modified some mentions of static that should have been kept untouched.

BenBE avatar Feb 26 '21 10:02 BenBE

I am not a big fan of these changes (wrapping standard C keywords into macros).

Does anyone know if libunwind produces readable backtraces with entries for static functions?

Problem is, that as quoted in the manpages for backtrace(3) (emphasis mine):

The symbol names may be unavailable without the use of special linker options. For systems using the GNU linker, it is necessary to use the -rdynamic linker option. Note that names of static functions are not exposed, and won't be available in the backtrace.

Thus, the problem is that these symbols aren't exported if static is used. I couldn't find if this also affects libunwind so this needs to be tested.

@cgzones If you provide a patch to use libunwind when available this might be a way around exporting all symbols in debug mode. But this needs to be tested AND will need a solid fallback if libunwind is not available.

BenBE avatar Feb 28 '21 22:02 BenBE

On FreeBSD backtrace_symbols_fd(3) does not work, probably because it is not safe to use in signal handlers (see https://stackoverflow.com/questions/77005/how-to-automatically-generate-a-stacktrace-when-my-program-crashes). Going to test libunwind...

cgzones avatar May 16 '21 17:05 cgzones