mirror of
https://github.com/ianlancetaylor/libbacktrace.git
synced 2026-03-26 03:59:06 +08:00
libbacktrace: use ELF symbol table if no debug info available
PR libbacktrace/97080 * fileline.c (backtrace_syminfo_to_full_callback): New function. (backtrace_syminfo_to_full_error_callback): New function. * elf.c (elf_nodebug): Call syminfo_fn if possible. * internal.h (struct backtrace_call_full): Define. (backtrace_syminfo_to_full_callback): Declare. (backtrace_syminfo_to_full_error_callback): Declare. * mtest.c (f3): Only check all[i] if data.index permits.
This commit is contained in:
39
elf.c
39
elf.c
@@ -547,18 +547,6 @@ elf_crc32_file (struct backtrace_state *state, int descriptor,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* A dummy callback function used when we can't find any debug info. */
|
||||
|
||||
static int
|
||||
elf_nodebug (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||
uintptr_t pc ATTRIBUTE_UNUSED,
|
||||
backtrace_full_callback callback ATTRIBUTE_UNUSED,
|
||||
backtrace_error_callback error_callback, void *data)
|
||||
{
|
||||
error_callback (data, "no debug info in ELF executable", -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* A dummy callback function used when we can't find a symbol
|
||||
table. */
|
||||
|
||||
@@ -571,6 +559,33 @@ elf_nosyms (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||
error_callback (data, "no symbol table in ELF executable", -1);
|
||||
}
|
||||
|
||||
/* A callback function used when we can't find any debug info. */
|
||||
|
||||
static int
|
||||
elf_nodebug (struct backtrace_state *state, uintptr_t pc,
|
||||
backtrace_full_callback callback,
|
||||
backtrace_error_callback error_callback, void *data)
|
||||
{
|
||||
if (state->syminfo_fn != NULL && state->syminfo_fn != elf_nosyms)
|
||||
{
|
||||
struct backtrace_call_full bdata;
|
||||
|
||||
/* Fetch symbol information so that we can least get the
|
||||
function name. */
|
||||
|
||||
bdata.full_callback = callback;
|
||||
bdata.full_error_callback = error_callback;
|
||||
bdata.full_data = data;
|
||||
bdata.ret = 0;
|
||||
state->syminfo_fn (state, pc, backtrace_syminfo_to_full_callback,
|
||||
backtrace_syminfo_to_full_error_callback, &bdata);
|
||||
return bdata.ret;
|
||||
}
|
||||
|
||||
error_callback (data, "no debug info in ELF executable", -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compare struct elf_symbol for qsort. */
|
||||
|
||||
static int
|
||||
|
||||
Reference in New Issue
Block a user