diff options
author | Pedro Alves <palves@redhat.com> | 2018-04-26 13:01:27 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2018-04-26 13:08:47 +0100 |
commit | 20944a6e20324cd897bf6c4c5fd20ef7224dacaa (patch) | |
tree | 968bead0171a67545a55be23811d7ba0ee8d5439 /gdb/minsyms.h | |
parent | 1adeb822668d3bd7182ca9b8cf42a7261deb3c7f (diff) | |
download | gdb-20944a6e20324cd897bf6c4c5fd20ef7224dacaa.zip gdb-20944a6e20324cd897bf6c4c5fd20ef7224dacaa.tar.gz gdb-20944a6e20324cd897bf6c4c5fd20ef7224dacaa.tar.bz2 |
Fix stepping past GNU ifunc resolvers (introduce lookup_msym_prefer)
When we're stepping (with "step"), we want to skip trampoline-like
functions automatically, including GNU ifunc resolvers. That is done
by infrun.c calling into:
in_solib_dynsym_resolve_code
-> svr4_in_dynsym_resolve_code
-> in_gnu_ifunc_stub
A problem here is that if there's a regular text symbol at the same
address as the ifunc symbol, the minimal symbol lookup in
in_gnu_ifunc_stub may miss the GNU ifunc symbol:
(...)
41: 000000000000071a 53 FUNC GLOBAL DEFAULT 11 gnu_ifunc_resolver
(...)
50: 000000000000071a 53 IFUNC GLOBAL DEFAULT 11 gnu_ifunc
(...)
This causes this FAIL in the tests added later in the series:
(gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: resolver received HWCAP
set step-mode on
(gdb) PASS: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: set step-mode on
step
0x00007ffff7bd371a in gnu_ifunc_resolver () from build/gdb/testsuite/outputs/gdb.base/gnu-ifunc/gnu-ifunc-lib-1-0-0.so
(gdb) FAIL: gdb.base/gnu-ifunc.exp: resolver_attr=1: resolver_debug=0: final_debug=0: step
Above, GDB simply thought that it stepped into a regular function, so
it stopped stepping, while it should have continued stepping past the
resolver.
The fix is to teach minimal symbol lookup to prefer GNU ifunc symbols
if desired.
gdb/ChangeLog:
2018-04-26 Pedro Alves <palves@redhat.com>
* minsyms.c (lookup_minimal_symbol_by_pc_section_1): Rename to ...
(lookup_minimal_symbol_by_pc_section): ... this. Replace
'want_trampoline' parameter by a lookup_msym_prefer parameter.
Handle it.
(lookup_minimal_symbol_by_pc_section): Delete old implementation.
(lookup_minimal_symbol_by_pc): Adjust.
(in_gnu_ifunc_stub): Prefer GNU ifunc symbols.
(lookup_solib_trampoline_symbol_by_pc): Adjust.
* minsyms.h (lookup_msym_prefer): New enum.
(lookup_minimal_symbol_by_pc_section): Replace 'want_trampoline'
parameter by a lookup_msym_prefer parameter.
Diffstat (limited to 'gdb/minsyms.h')
-rw-r--r-- | gdb/minsyms.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/gdb/minsyms.h b/gdb/minsyms.h index 29d8283..40e69ae 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -238,6 +238,22 @@ struct bound_minimal_symbol lookup_minimal_symbol_solib_trampoline struct minimal_symbol *lookup_minimal_symbol_by_pc_name (CORE_ADDR, const char *, struct objfile *); +enum class lookup_msym_prefer +{ + /* Prefer mst_text symbols. */ + TEXT, + + /* Prefer mst_solib_trampoline symbols when there are text and + trampoline symbols at the same address. Otherwise prefer + mst_text symbols. */ + TRAMPOLINE, + + /* Prefer mst_text_gnu_ifunc symbols when there are text and ifunc + symbols at the same address. Otherwise prefer mst_text + symbols. */ + GNU_IFUNC, +}; + /* Search through the minimal symbol table for each objfile and find the symbol whose address is the largest address that is still less than or equal to PC, and which matches SECTION. @@ -246,11 +262,15 @@ struct minimal_symbol *lookup_minimal_symbol_by_pc_name instead. The result has a non-NULL 'minsym' member if such a symbol is - found, or NULL if PC is not in a suitable range. */ + found, or NULL if PC is not in a suitable range. + + See definition of lookup_msym_prefer for description of PREFER. By + default mst_text symbols are preferred. */ struct bound_minimal_symbol lookup_minimal_symbol_by_pc_section - (CORE_ADDR, - struct obj_section *); + (CORE_ADDR, + struct obj_section *, + lookup_msym_prefer prefer = lookup_msym_prefer::TEXT); /* Backward compatibility: search through the minimal symbol table for a matching PC (no section given). |