From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yJM0BhZyUGhiEhEAWB0awg (envelope-from ) for ; Mon, 16 Jun 2025 15:35:50 -0400 Received: by simark.ca (Postfix, from userid 112) id 177421E11C; Mon, 16 Jun 2025 15:35:50 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 ESMTPS id E14711E102 for ; Mon, 16 Jun 2025 15:35:48 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 74175389377F for ; Mon, 16 Jun 2025 19:35:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 74175389377F Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id E52D83893773 for ; Mon, 16 Jun 2025 19:34:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E52D83893773 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E52D83893773 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750102490; cv=none; b=Bz69tPMpeVXoYaYDtGhME6UhvSYPokkfMmCHdqgjMCXqI+JGP/2gpeWWyIHfcrakH7tw2KBUykCPQtXnzs/LZ7OaNK+UdM/fjOm23DUSJHaChIFyUD8RMHTgCGsUpDCv9wGAt9p5f46fGMSeMq8SZ2VQ4cACTXE7RvFhm82Rio8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750102490; c=relaxed/simple; bh=1DQET8xA2TVfat1m+mcCy4O3X4tbVxYXQG2QTdhizIM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=cEcb/VkbVYOUijR5JBtRVMOCEJW/gcO/30UDV1Ox78z9Ou+2y02bUteYbl+3dHiHbf9WqLCFyXt3ABaHArgM7WMxtKPxKA4Zwld48IHa4BZYqRzJItHPBevHzowoHR6MtRW2IXj+/FcPOnayatZdyrBaLj6DHYsAgBTeYwBLsQQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E52D83893773 Received: by simark.ca (Postfix, from userid 112) id 826851E102; Mon, 16 Jun 2025 15:34:49 -0400 (EDT) Received: from localhost.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 233921E11C; Mon, 16 Jun 2025 15:34:45 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v3 3/6] gdb/solib: add solib -> solib_ops backlink Date: Mon, 16 Jun 2025 15:33:01 -0400 Message-ID: <20250616193443.16703-3-simon.marchi@efficios.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616193443.16703-1-simon.marchi@efficios.com> References: <20250616193443.16703-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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~public-inbox=simark.ca@sourceware.org The subsequent C++ification commit makes it so that one struct solib_ops is instantiated for each program space. For some operations, it will then become necessary to be able to get the right solib_ops instance from a given solib. Add an solib -> solib_ops backlink for that. Change-Id: Ib95407b3fa5fcfba55cf874e0e9dcd2d43a402e4 --- gdb/solib-aix.c | 2 +- gdb/solib-darwin.c | 2 +- gdb/solib-dsbt.c | 2 +- gdb/solib-frv.c | 2 +- gdb/solib-rocm.c | 2 +- gdb/solib-svr4.c | 4 ++-- gdb/solib-target.c | 2 +- gdb/solib.h | 15 +++++++++++++++ 8 files changed, 23 insertions(+), 8 deletions(-) diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index 4af83de4d371..17eeba940770 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -480,7 +480,7 @@ solib_aix_current_sos () } /* Add it to the list. */ - auto &new_solib = sos.emplace_back (); + auto &new_solib = sos.emplace_back (solib_aix_so_ops); new_solib.original_name = so_name; new_solib.name = so_name; new_solib.lm_info = std::make_unique (info); diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index 4003c77748ca..88a2962f5dd5 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -250,7 +250,7 @@ darwin_current_sos () break; /* Create and fill the new struct solib element. */ - auto &newobj = sos.emplace_back (); + auto &newobj = sos.emplace_back (darwin_so_ops); auto li = std::make_unique (); diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 2b3153692805..f6748b69353a 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -584,7 +584,7 @@ dsbt_current_sos (void) break; } - auto &sop = sos.emplace_back (); + auto &sop = sos.emplace_back (dsbt_so_ops); auto li = std::make_unique (); li->map = loadmap; /* Fetch the name. */ diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index ceef72208a1b..12d3140b513c 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -367,7 +367,7 @@ frv_current_sos () break; } - auto &sop = sos.emplace_back (); + auto &sop = sos.emplace_back (frv_so_ops); auto li = std::make_unique (); li->map = loadmap; li->got_value = got_addr; diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index b27613bbf91a..a3599562e795 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -210,7 +210,7 @@ solibs_from_rocm_sos (const std::vector &sos) for (const rocm_so &so : sos) { - auto &newobj = dst.emplace_back (); + auto &newobj = dst.emplace_back (rocm_solib_ops); newobj.lm_info = std::make_unique (*so.lm_info); newobj.name = so.name; diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 48aace1feb48..deefc2578599 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1050,7 +1050,7 @@ solib_from_svr4_sos (const std::vector &sos) for (const svr4_so &so : sos) { - auto &newobj = dst.emplace_back (); + auto &newobj = dst.emplace_back (svr4_so_ops); newobj.name = so.name; newobj.original_name = so.name; @@ -1250,7 +1250,7 @@ svr4_default_sos (svr4_info *info) li->l_addr_p = 1; owning_intrusive_list sos; - auto &newobj = sos.emplace_back (); + auto &newobj = sos.emplace_back (svr4_so_ops); newobj.lm_info = std::move (li); newobj.name = info->debug_loader_name; diff --git a/gdb/solib-target.c b/gdb/solib-target.c index 68dc3cc92c0a..61b841928ff8 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -245,7 +245,7 @@ solib_target_current_sos (void) /* Build a struct solib for each entry on the list. */ for (lm_info_target_up &info : library_list) { - auto &new_solib = sos.emplace_back (); + auto &new_solib = sos.emplace_back (solib_target_so_ops); /* We don't need a copy of the name in INFO anymore. */ new_solib.name = std::move (info->name); diff --git a/gdb/solib.h b/gdb/solib.h index f5922aa5f5d6..09d56c08b953 100644 --- a/gdb/solib.h +++ b/gdb/solib.h @@ -54,8 +54,19 @@ struct lm_info using lm_info_up = std::unique_ptr; +struct solib_ops; + struct solib : intrusive_list_node { + /* Constructor + + OPS is the solib_ops implementation providing this solib. */ + explicit solib (const solib_ops &ops) : m_ops (&ops) {} + + /* Return the solib_ops implementation providing this solib. */ + const solib_ops &ops () const + { return *m_ops; } + /* Free symbol-file related contents of SO and reset for possible reloading of SO. If we have opened a BFD for SO, close it. If we have placed SO's sections in some target's section table, the caller is responsible for @@ -111,6 +122,10 @@ struct solib : intrusive_list_node that supports outputting multiple segments once the related code supports them. */ CORE_ADDR addr_low = 0, addr_high = 0; + +private: + /* The solib_ops responsible for this solib. */ + const solib_ops *m_ops; }; /* A unique pointer to an solib. */ -- 2.49.0