diff options
author | Pedro Alves <palves@redhat.com> | 2017-11-29 19:25:58 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-11-29 19:25:58 +0000 |
commit | 4024cf2b8d864279ff87af1a2ade77ab6d710d50 (patch) | |
tree | dac0340225b6677d3fecda4ebd6f64df7dcbf0d6 /gdb/symtab.c | |
parent | 5dcf52c19f7045fb179f703426d345b8a81d2210 (diff) | |
download | gdb-4024cf2b8d864279ff87af1a2ade77ab6d710d50.zip gdb-4024cf2b8d864279ff87af1a2ade77ab6d710d50.tar.gz gdb-4024cf2b8d864279ff87af1a2ade77ab6d710d50.tar.bz2 |
Fix setting-breakpoints regression on PPC64 (function descriptors)
The recent-ish commit e5f25bc5d6db ('Fix "list ambiguous_variable"')
caused a serious regression on PPC64. See
<https://sourceware.org/ml/gdb-patches/2017-11/msg00666.html>.
Basically, after that patch, GDB sets breakpoints in function
descriptors instead of where the descriptors point to, which is
incorrect.
The problem is that GDB now only runs a minsym's address through
gdbarch_convert_from_func_ptr_addr if msymbol_is_text returns true.
However, if the symbol points to a function descriptor,
msymbol_is_text is false since function descriptors are in fact
outside the text section.
The fix is to also run a non-text address through
gdbarch_convert_from_func_ptr_addr, and if that detects that it was
indeed a function descriptor, treat the resulting address as a
function.
While implementing that directly in linespec.c:minsym_found (where the
bad msymbol_is_text check is) fixes the issue, I noticed that
linespec.c:add_minsym has some code that also basically needs to do
the same checks, however it's implemented differently. Also,
add_minsym is calling find_pc_sect_line on non-function symbols, which
also doesn't look right.
So I introduced msymbol_is_function, so that we have a simple place to
consider minsyms and function descriptors.
And then, the only other use of msymbol_is_text is in
find_function_alias_target, which turns out to also be incorrect.
Changing that one to use msymbol_is_function, i.e., to consider
function descriptors too fixes (on PPC64):
-FAIL: gdb.base/symbol-alias.exp: p func_alias
-FAIL: gdb.base/symbol-alias.exp: p *func_alias()
+PASS: gdb.base/symbol-alias.exp: p func_alias
+PASS: gdb.base/symbol-alias.exp: p *func_alias()
And then after that, msymbol_is_text is no longer used anywhere, so it
can be removed.
Tested on x86_64 GNU/Linux, no regressions. Tested on PPC64 GNU/Linux
and results compared to a testrun of e5f25bc5d6db^ (before the
offending commit), also no regressions. (there's a couple new FAILs
and some new symbol name matching unit tests are crashing, but that
looks unrelated).
gdb/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* linespec.c (minsym_found, add_minsym): Use msymbol_is_function.
* minsyms.c (msymbol_is_text): Delete.
(msymbol_is_function): New function.
* minsyms.h (msymbol_is_text): Delete.
(msymbol_is_function): New declaration.
* symtab.c (find_function_alias_target): Use msymbol_is_function.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index 3d59367..a249a8d 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -3927,14 +3927,14 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr) symbol * find_function_alias_target (bound_minimal_symbol msymbol) { - if (!msymbol_is_text (msymbol.minsym)) + CORE_ADDR func_addr; + if (!msymbol_is_function (msymbol.objfile, msymbol.minsym, &func_addr)) return NULL; - CORE_ADDR addr = BMSYMBOL_VALUE_ADDRESS (msymbol); - symbol *sym = find_pc_function (addr); + symbol *sym = find_pc_function (func_addr); if (sym != NULL && SYMBOL_CLASS (sym) == LOC_BLOCK - && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == addr) + && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == func_addr) return sym; return NULL; |