From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id A64363858D39; Wed, 8 Feb 2023 16:46:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A64363858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675874818; bh=9ZChJuPTLxWJuWVo1f0cxFxWkUrXKz0cndFx2kAORac=; h=From:To:Subject:Date:From; b=gQOz/pJRnUC8pTgDuEZ51pZTUrLCWxVWjLjJbPSkbIIjNpBSzAmilzwoNiR0NLxS8 YDqJ0tDdK2uIoLWx9vSJU4U7erFsjrajngIMnH6YbpSLjDJvNTrmLZ0A0q76wehOmx gMY97f/BMmmAZZAlsCBFlZ2/4JmNlCD64n6/vAMY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Remove most calls to fixup_symbol_section X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 5abbfa982215a5bcd2bf2c0b92cbb005464dc927 X-Git-Newrev: dae58e04442670270fe116ff1f2e38a2b184b4a1 Message-Id: <20230208164658.A64363858D39@sourceware.org> Date: Wed, 8 Feb 2023 16:46:58 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Ddae58e044426= 70270fe116ff1f2e38a2b184b4a1 commit dae58e04442670270fe116ff1f2e38a2b184b4a1 Author: Tom Tromey Date: Fri Jan 13 09:27:54 2023 -0700 Remove most calls to fixup_symbol_section =20 Nearly every call to fixup_symbol_section in gdb is incorrect, and if any such call has an effect, it's purely by happenstance. =20 fixup_section has a long comment explaining that the call should only be made before runtime section offsets are applied. And, the loop in this code (the fallback loop -- the minsym lookup code is "ok") is careful to remove these offsets before comparing addresses. =20 However, aside from a single call in dwarf2/read.c, every call in gdb is actually done after section offsets have been applied. So, these calls are incorrect. =20 Now, these calls could be made when the symbol is created. I considered this approach, but I reasoned that the code has been this way for many years, seemingly without ill effect. So, instead I chose to simply remove the offending calls. Diff: --- gdb/ada-lang.c | 28 +++++++--------------------- gdb/breakpoint.c | 7 ++----- gdb/infcmd.c | 1 - gdb/objfiles.c | 2 -- gdb/symtab.c | 8 +------- 5 files changed, 10 insertions(+), 36 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 40f85914a56..3cd6f73f36f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5389,9 +5389,7 @@ match_data::operator() (struct block_symbol *bsym) if (sym =3D=3D NULL) { if (!found_sym && arg_sym !=3D NULL) - add_defn_to_vec (*resultp, - fixup_symbol_section (arg_sym, objfile), - block); + add_defn_to_vec (*resultp, arg_sym, block); found_sym =3D false; arg_sym =3D NULL; } @@ -5404,9 +5402,7 @@ match_data::operator() (struct block_symbol *bsym) else { found_sym =3D true; - add_defn_to_vec (*resultp, - fixup_symbol_section (sym, objfile), - block); + add_defn_to_vec (*resultp, sym, block); } } return true; @@ -5808,9 +5804,7 @@ ada_lookup_symbol (const char *name, const struct blo= ck *block0, if (candidates.empty ()) return {}; =20 - block_symbol info =3D candidates[0]; - info.symbol =3D fixup_symbol_section (info.symbol, NULL); - return info; + return candidates[0]; } =20 =20 @@ -6098,9 +6092,7 @@ ada_add_block_symbols (std::vector &result, else { found_sym =3D true; - add_defn_to_vec (result, - fixup_symbol_section (sym, objfile), - block); + add_defn_to_vec (result, sym, block); } } } @@ -6113,9 +6105,7 @@ ada_add_block_symbols (std::vector &result, =20 if (!found_sym && arg_sym !=3D NULL) { - add_defn_to_vec (result, - fixup_symbol_section (arg_sym, objfile), - block); + add_defn_to_vec (result, arg_sym, block); } =20 if (!lookup_name.ada ().wild_match_p ()) @@ -6152,9 +6142,7 @@ ada_add_block_symbols (std::vector &result, else { found_sym =3D true; - add_defn_to_vec (result, - fixup_symbol_section (sym, objfile), - block); + add_defn_to_vec (result, sym, block); } } } @@ -6165,9 +6153,7 @@ ada_add_block_symbols (std::vector &result, They aren't parameters, right? */ if (!found_sym && arg_sym !=3D NULL) { - add_defn_to_vec (result, - fixup_symbol_section (arg_sym, objfile), - block); + add_defn_to_vec (result, arg_sym, block); } } } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index adf38e7d722..1c7ae58a23b 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -9210,11 +9210,8 @@ resolve_sal_pc (struct symtab_and_line *sal) { sym =3D block_linkage_function (b); if (sym !=3D NULL) - { - fixup_symbol_section (sym, sal->symtab->compunit ()->objfile ()); - sal->section - =3D sym->obj_section (sal->symtab->compunit ()->objfile ()); - } + sal->section + =3D sym->obj_section (sal->symtab->compunit ()->objfile ()); else { /* It really is worthwhile to have the section, so we'll diff --git a/gdb/infcmd.c b/gdb/infcmd.c index fd88b8ca328..77206fcbfe8 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1106,7 +1106,6 @@ jump_command (const char *arg, int from_tty) { struct obj_section *section; =20 - fixup_symbol_section (sfn, 0); section =3D sfn->obj_section (sfn->objfile ()); if (section_is_overlay (section) && !section_is_mapped (section)) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index bf5057e723d..ed29131d528 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -582,8 +582,6 @@ static void relocate_one_symbol (struct symbol *sym, struct objfile *objfile, const section_offsets &delta) { - fixup_symbol_section (sym, objfile); - /* The RS6000 code from which this was taken skipped any symbols in STRUCT_DOMAIN or UNDEF_DOMAIN. But I'm leaving out that test, on the theory that diff --git a/gdb/symtab.c b/gdb/symtab.c index bf3a3e3caaa..d3b2edfba9a 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2252,7 +2252,7 @@ lookup_symbol_in_block (const char *name, symbol_name= _match_type match_type, { symbol_lookup_debug_printf_v ("lookup_symbol_in_block (...) =3D %s", host_address_to_string (sym)); - return fixup_symbol_section (sym, NULL); + return sym; } =20 symbol_lookup_debug_printf_v ("lookup_symbol_in_block (...) =3D NULL"); @@ -2337,7 +2337,6 @@ lookup_symbol_in_objfile_symtabs (struct objfile *obj= file, ("lookup_symbol_in_objfile_symtabs (...) =3D %s (block %s)", host_address_to_string (other.symbol), host_address_to_string (other.block)); - other.symbol =3D fixup_symbol_section (other.symbol, objfile); return other; } =20 @@ -2443,7 +2442,6 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, host_address_to_string (result.symbol), host_address_to_string (block)); =20 - result.symbol =3D fixup_symbol_section (result.symbol, objfile); result.block =3D block; return result; } @@ -2925,7 +2923,6 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct ob= j_section *section) const struct block *b =3D bv->block (b_index); ALL_BLOCK_SYMBOLS (b, iter, sym) { - fixup_symbol_section (sym, obj_file); if (matching_obj_sections (sym->obj_section (obj_file), section)) break; @@ -3668,7 +3665,6 @@ find_function_start_sal (CORE_ADDR func_addr, obj_sec= tion *section, symtab_and_line find_function_start_sal (symbol *sym, bool funfirstline) { - fixup_symbol_section (sym, NULL); symtab_and_line sal =3D find_function_start_sal_1 (sym->value_block ()->entry_pc (), sym->obj_section (sym->objfile ()), @@ -3796,8 +3792,6 @@ skip_prologue_sal (struct symtab_and_line *sal) sym =3D find_pc_sect_function (sal->pc, sal->section); if (sym !=3D NULL) { - fixup_symbol_section (sym, NULL); - objfile =3D sym->objfile (); pc =3D sym->value_block ()->entry_pc (); section =3D sym->obj_section (objfile);