MINOR: tools: add resolve_sym_name() to resolve function pointers
authorWilly Tarreau <w@1wt.eu>
Tue, 3 Mar 2020 16:09:08 +0000 (17:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 May 2020 15:09:20 +0000 (17:09 +0200)
commit5bcc63f5b372d467847c16da116cb84ec3e79de2
treeb7d4ce232e7bb7ab48542e2e78354e9aaa3b71cb
parent77526f6728faad43f25359d107419081640b2b18
MINOR: tools: add resolve_sym_name() to resolve function pointers

We use various hacks at a few places to try to identify known function
pointers in debugging outputs (show threads & show fd). Let's centralize
this into a new function dedicated to this. It already knows about the
functions matched by "show threads" and "show fd", and when built with
USE_DL, it can rely on dladdr1() to resolve other functions. There are
some limitations, as static functions are not resolved, linking with
-rdynamic is mandatory, and even then some functions will not necessarily
appear. It's possible to do a better job by rebuilding the whole symbol
table from the ELF headers in memory but it's less portable and the gains
are still limited, so this solution remains a reasonable tradeoff.

(cherry picked from commit eb8b1ca3eb4c8d4688e1a4a1d9c1b91f68324e09)
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/common/standard.h
src/standard.c