From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id AA072385842E for ; Wed, 18 Jan 2023 15:30:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA072385842E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x12b.google.com with SMTP id f8so11088945ilj.5 for ; Wed, 18 Jan 2023 07:30:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hcAlnAh2UMu3kOA9UvEwUGdjBDxa6i1FHkcgTlrJFvs=; b=iDjmvadmuTt48dwbMyKIHz+A1YiYslUZ1aHKSh4i+vk73Gj50QLsRbRuF52vsbnAGg fQNldbZ0LXWmF1YN/1S4k6TAihHhyM4mjGXSE3ua87zQAqdpzL7G7cfVbaFK45tIUuOO iDpZwCJXoRdO6OK2icZEacXuZsPsfqdEnjaMZkPuoBD0P0P+BsaZri9wNVhlajcymFIl tRXDYDoCWomRmmOwCy9uw3cU7AR79z6buWrDxAStwEIut2XD4zeG9UQifqFVwtqsxXsi KHDZ9c4uRCl50X/oHZeLo85ZawA+nznKTzOm2zOdlrVXmwv36FH39rd5eVlytQtFSl9E Xe+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hcAlnAh2UMu3kOA9UvEwUGdjBDxa6i1FHkcgTlrJFvs=; b=MvLSUN0kUgJMU2QogBqIZpWCh40HX0RO+/hpCiGtZZx6/Q2nmBEV/kVFRVVTm1hWnh R0zUU+Qqi6UonGPIsQG732JtmrCBzO/PCaMXftZeR0zsZNDIUaI86FWYWwH1svlLPHSL mX4/SHA28s8KI14/gncyAQ76ELrseMZHUgJdaWHXxpQwYfE4VWu/NWjuTJ+Fq+06P5t1 ZjjL15+R5T30xzzeH4b8PsJhe4jBCQraQpUt0dDSRBYQAlBBilR3CCjmLBcZJqU7UCnq 1PrPEjsy3iTT1fCwr8HfaBay7zNWeEH+IN/gvDqDkW6bZ0NBDP67eOAZg9JP6KQPXTqQ bERQ== X-Gm-Message-State: AFqh2koeNtXFtnCLPtwg+hDf8WL9rKz2p6lMl8bzKhCHA9viEaJgR1IH Lj7UgoTcUcrJabpdzsZ6RAXkbnucjcZW1Fv7 X-Google-Smtp-Source: AMrXdXvaShcsAYI7Sk5c6tgUZakLpxgjKcJp3a8tU8/L8/VSCxf1KCiFgmp3ztr76+NTrgquFXrUuA== X-Received: by 2002:a05:6e02:2191:b0:30f:12c9:f767 with SMTP id j17-20020a056e02219100b0030f12c9f767mr7886114ila.11.1674055839809; Wed, 18 Jan 2023 07:30:39 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id m4-20020a056e020de400b0030bf2476c5fsm10106502ilj.25.2023.01.18.07.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 07:30:39 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 5/6] Remove most calls to fixup_symbol_section Date: Wed, 18 Jan 2023 08:30:24 -0700 Message-Id: <20230118153025.342512-6-tromey@adacore.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230118153025.342512-1-tromey@adacore.com> References: <20230118153025.342512-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Nearly every call to fixup_symbol_section in gdb is incorrect, and if any such call has an effect, it's purely by happenstance. 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. 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. 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. --- 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 == NULL) { if (!found_sym && arg_sym != NULL) - add_defn_to_vec (*resultp, - fixup_symbol_section (arg_sym, objfile), - block); + add_defn_to_vec (*resultp, arg_sym, block); found_sym = false; arg_sym = NULL; } @@ -5404,9 +5402,7 @@ match_data::operator() (struct block_symbol *bsym) else { found_sym = 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 block *block0, if (candidates.empty ()) return {}; - block_symbol info = candidates[0]; - info.symbol = fixup_symbol_section (info.symbol, NULL); - return info; + return candidates[0]; } @@ -6098,9 +6092,7 @@ ada_add_block_symbols (std::vector &result, else { found_sym = 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, if (!found_sym && arg_sym != NULL) { - add_defn_to_vec (result, - fixup_symbol_section (arg_sym, objfile), - block); + add_defn_to_vec (result, arg_sym, block); } if (!lookup_name.ada ().wild_match_p ()) @@ -6152,9 +6142,7 @@ ada_add_block_symbols (std::vector &result, else { found_sym = 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 != 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 00cc2ab401c..306c30aefac 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -9196,11 +9196,8 @@ resolve_sal_pc (struct symtab_and_line *sal) { sym = block_linkage_function (b); if (sym != NULL) - { - fixup_symbol_section (sym, sal->symtab->compunit ()->objfile ()); - sal->section - = sym->obj_section (sal->symtab->compunit ()->objfile ()); - } + sal->section + = 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 978c07f176d..fe100532454 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; - fixup_symbol_section (sfn, 0); section = 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 411bf121ede..869f955488e 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -583,8 +583,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 fe247ab70eb..2d3aafd140a 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2248,7 +2248,7 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type, { symbol_lookup_debug_printf_v ("lookup_symbol_in_block (...) = %s", host_address_to_string (sym)); - return fixup_symbol_section (sym, NULL); + return sym; } symbol_lookup_debug_printf_v ("lookup_symbol_in_block (...) = NULL"); @@ -2333,7 +2333,6 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, ("lookup_symbol_in_objfile_symtabs (...) = %s (block %s)", host_address_to_string (other.symbol), host_address_to_string (other.block)); - other.symbol = fixup_symbol_section (other.symbol, objfile); return other; } @@ -2439,7 +2438,6 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, host_address_to_string (result.symbol), host_address_to_string (block)); - result.symbol = fixup_symbol_section (result.symbol, objfile); result.block = block; return result; } @@ -2921,7 +2919,6 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) const struct block *b = 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; @@ -3664,7 +3661,6 @@ find_function_start_sal (CORE_ADDR func_addr, obj_section *section, symtab_and_line find_function_start_sal (symbol *sym, bool funfirstline) { - fixup_symbol_section (sym, NULL); symtab_and_line sal = find_function_start_sal_1 (sym->value_block ()->entry_pc (), sym->obj_section (sym->objfile ()), @@ -3792,8 +3788,6 @@ skip_prologue_sal (struct symtab_and_line *sal) sym = find_pc_sect_function (sal->pc, sal->section); if (sym != NULL) { - fixup_symbol_section (sym, NULL); - objfile = sym->objfile (); pc = sym->value_block ()->entry_pc (); section = sym->obj_section (objfile); -- 2.38.1