From patchwork Wed Jul 17 03:52:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 94045 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7793D385DDC2 for ; Wed, 17 Jul 2024 04:03:24 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 4C1CC385B529 for ; Wed, 17 Jul 2024 04:02:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C1CC385B529 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4C1CC385B529 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721188965; cv=none; b=WIjscCV4ifiLbK045F+sgnUiGeWkxaS2TBIU/pjgRdWk4HsSzYgCRWYOkilSGAWtSKoi7FZdgnM9vTMW58TR9TGsXmHqHCYPxOuZKHxorSNNmhOv739mAuQtJx/mQv5uNYFV94zKyONwS/a/XuIp7kKv/0kuEFuiqQuKnNcgORs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721188965; c=relaxed/simple; bh=bUi4EJ5xzjJmcQdzxu5nXmZ2ERZyW1EElj2MHFRUq/U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=u1jvkB6qQ2+VqUkBVFOGvaWDzphjn82fPohsF3IFIqnkWCIFkGMZ8c1H+ffdEtGdVPpbRrSHZbQUpG89JDlX9X0RMgbKM8LrIryAG2sBkjSu1zL9ERjWmipU8Jdc/N5u08WlQQ2crucizJ6K9FBuHbAg5Jut/Vj7pVsKKDiMwqM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 46H42aka026942 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 00:02:41 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 46H42aka026942 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1721188962; bh=At6xOvOnn3ldOogjFuRKEOSPqOW6AnR1B+R43KHydTY=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=Kknior5+0M8S69HXOcOREM9BUJzyhfr/nkxdtlEfRAcwVvgmXtcSfEoAlFjov2Qhw 4JHbz66VeUMd5AFhfktdk3sWN6lkWEM4mTFbU3uipt9jKhVL8/AEdVN3VdS4+w7+WK xbPPpGqliarp5RhH4jDWB54+3eva+5kL989g6eic= Received: from simark.localdomain (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 1E34A1E0FF; Tue, 16 Jul 2024 23:53:09 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 6/7] gdb: add program_space parameter to lookup_minimal_symbol_linkage Date: Tue, 16 Jul 2024 23:52:04 -0400 Message-ID: <20240717035307.2299961-7-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717035307.2299961-1-simon.marchi@polymtl.ca> References: <20240717035307.2299961-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 17 Jul 2024 04:02:36 +0000 X-Spam-Status: No, score=-3188.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org Make the current_program_space reference bubble up one level. Change-Id: Ic349dc96b7d375ad7c66022d84657136f0de8c87 --- gdb/dwarf2/ada-imported.c | 4 +++- gdb/minsyms.c | 5 +++-- gdb/minsyms.h | 6 +++--- gdb/symtab.c | 11 +++++++---- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c index 9ec0d51e9205..eabbab181c97 100644 --- a/gdb/dwarf2/ada-imported.c +++ b/gdb/dwarf2/ada-imported.c @@ -20,6 +20,7 @@ #include "symtab.h" #include "value.h" #include "dwarf2/loc.h" +#include "objfiles.h" /* Helper to get the imported symbol's real name. */ static const char * @@ -34,7 +35,8 @@ static struct value * ada_imported_read_variable (struct symbol *symbol, const frame_info_ptr &frame) { const char *name = get_imported_name (symbol); - bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (name, false); + bound_minimal_symbol minsym + = lookup_minimal_symbol_linkage (symbol->objfile ()->pspace (), name, false); if (minsym.minsym == nullptr) error (_("could not find imported name %s"), name); return value_at (symbol->type (), minsym.value_address ()); diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 1670491a24ef..9c39749cbf76 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -584,9 +584,10 @@ lookup_minimal_symbol_linkage (const char *name, struct objfile *objf) /* See minsyms.h. */ bound_minimal_symbol -lookup_minimal_symbol_linkage (const char *name, bool only_main) +lookup_minimal_symbol_linkage (program_space *pspace, const char *name, + bool only_main) { - for (objfile *objfile : current_program_space->objfiles ()) + for (objfile *objfile : pspace->objfiles ()) { if (objfile->separate_debug_objfile_backlink != nullptr) continue; diff --git a/gdb/minsyms.h b/gdb/minsyms.h index 0d9b9ad51cee..f84d3e818480 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -234,11 +234,11 @@ extern bound_minimal_symbol lookup_minimal_symbol_linkage (const char *name, ATTRIBUTE_NONNULL (1) ATTRIBUTE_NONNULL (2); /* A variant of lookup_minimal_symbol_linkage that iterates over all - objfiles. If ONLY_MAIN is true, then only an objfile with + objfiles of PSPACE. If ONLY_MAIN is true, then only an objfile with OBJF_MAINLINE will be considered. */ -extern bound_minimal_symbol lookup_minimal_symbol_linkage (const char *name, - bool only_main) +extern bound_minimal_symbol lookup_minimal_symbol_linkage + (program_space *pspace, const char *name, bool only_main) ATTRIBUTE_NONNULL (1); /* Look through all the current minimal symbol tables and find the diff --git a/gdb/symtab.c b/gdb/symtab.c index c77537f121ae..9da148b3394d 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6775,10 +6775,12 @@ symbol::get_maybe_copied_address () const gdb_assert (this->aclass () == LOC_STATIC); const char *linkage_name = this->linkage_name (); - bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (linkage_name, - false); + bound_minimal_symbol minsym + = lookup_minimal_symbol_linkage (this->objfile ()->pspace (), linkage_name, + false); if (minsym.minsym != nullptr) return minsym.value_address (); + return this->m_value.address; } @@ -6791,10 +6793,11 @@ minimal_symbol::get_maybe_copied_address (objfile *objf) const gdb_assert ((objf->flags & OBJF_MAINLINE) == 0); const char *linkage_name = this->linkage_name (); - bound_minimal_symbol found = lookup_minimal_symbol_linkage (linkage_name, - true); + bound_minimal_symbol found + = lookup_minimal_symbol_linkage (objf->pspace (), linkage_name, true); if (found.minsym != nullptr) return found.value_address (); + return (this->m_value.address + objf->section_offsets[this->section_index ()]); }