From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SPbHKzE5R2iDawcAWB0awg (envelope-from ) for ; Mon, 09 Jun 2025 15:42:41 -0400 Received: by simark.ca (Postfix, from userid 112) id B11691E11C; Mon, 9 Jun 2025 15:42:41 -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 438BF1E0C2 for ; Mon, 9 Jun 2025 15:42:41 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F20593858424 for ; Mon, 9 Jun 2025 19:42:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F20593858424 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 0357B3858C39 for ; Mon, 9 Jun 2025 19:41:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0357B3858C39 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 0357B3858C39 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=1749498113; cv=none; b=oOnaGyZufWfbScW1s6aFJJQsBPjy0wwcB6EUjAOHzHhZabxDD2bwWH/8MYg2CCOA7ka1p9UETMpoRQYBbKMo+OXtjoahts0uPiv136W0/NIrUN9OWx9ZRS11051355uLNQtDrM6ncBS73smvH3m4VSdWHG7b7WRBDnfyiJHB5Oc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749498113; c=relaxed/simple; bh=JC1DGF39OV7B3nk1J/8O/z3JNd0Sda1pX6oj11dIftQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=geIhv9JNUMqpl/Y/4JvkbB35uO3E9qWPhI8UGdW73ual9DJPQ9K3xej9IwZv4BPW3vY2FLc9skpVQQPQwbkwzSUyQ6FYSb5KTec1WDR/dXfm711Qcl703QsKKQi8wZjaiqPZxM6zmQ2HFaltLRDdPjxqcIFQopeh+WPsow/u0bE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0357B3858C39 Received: by simark.ca (Postfix, from userid 112) id 942CA1E128; Mon, 9 Jun 2025 15:41:52 -0400 (EDT) Received: from smarchi-efficios.internal.efficios.com (192-222-132-26.qc.cable.ebox.net [192.222.132.26]) (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 C48EA1E100; Mon, 9 Jun 2025 15:41:48 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 2/4] gdb/solib: use solib::ops for operations that concern a single solib Date: Mon, 9 Jun 2025 15:40:56 -0400 Message-ID: <20250609194146.137730-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250609194146.137730-1-simon.marchi@efficios.com> References: <20250609194146.137730-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 For operations that concern a single solib, use the solib_ops backlink added in the previous patch (solib::ops), instead of using the solib_ops from the gdbarch. This is a small / easy step towards not using gdbarch_so_ops, which is necessary for the C++ification patch later in this series. There is no change in behavior expected. Change-Id: If80e9ea717a2788bada1cf0940cda3c73933bcff --- gdb/solib.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/gdb/solib.c b/gdb/solib.c index 7721fd673ae3..de3469da6e91 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -482,10 +482,8 @@ solib_bfd_open (const char *pathname) static int solib_map_sections (solib &so) { - const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); - gdb::unique_xmalloc_ptr filename (tilde_expand (so.name.c_str ())); - gdb_bfd_ref_ptr abfd (ops->bfd_open (filename.get ())); + gdb_bfd_ref_ptr abfd (so.ops ().bfd_open (filename.get ())); /* If we have a core target then the core target might have some helpful information (i.e. build-ids) about the shared libraries we are trying @@ -495,7 +493,7 @@ solib_map_sections (solib &so) If we don't have a core target then this will return an empty struct with no hint information, we then lookup the shared library based on its filename. */ - std::optional solib_addr = ops->find_solib_addr (so); + std::optional solib_addr = so.ops ().find_solib_addr (so); std::optional mapped_file_info = core_target_find_mapped_file (so.name.c_str (), solib_addr); @@ -519,7 +517,7 @@ solib_map_sections (solib &so) However, if it was good enough during the mapped file processing, we assume it's good enough now. */ if (!mapped_file_info->filename ().empty ()) - abfd = ops->bfd_open (mapped_file_info->filename ().c_str ()); + abfd = so.ops ().bfd_open (mapped_file_info->filename ().c_str ()); else abfd = nullptr; @@ -559,7 +557,7 @@ solib_map_sections (solib &so) /* Relocate the section binding addresses as recorded in the shared object's file by the base address to which the object was actually mapped. */ - ops->relocate_section_addresses (so, &p); + so.ops ().relocate_section_addresses (so, &p); /* If the target didn't provide information about the address range of the shared object, assume we want the location of @@ -586,8 +584,6 @@ solib_map_sections (solib &so) void solib::clear () { - const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); - this->sections.clear (); this->abfd = nullptr; @@ -602,8 +598,8 @@ solib::clear () this->name = this->original_name; /* Do the same for target-specific data. */ - if (ops->clear_so != NULL) - ops->clear_so (*this); + if (this->ops ().clear_so != NULL) + this->ops ().clear_so (*this); } lm_info::~lm_info () = default; @@ -1827,19 +1823,17 @@ static value * linker_namespace_make_value (gdbarch *gdbarch, internalvar *var, void *ignore) { - const solib_ops *ops = gdbarch_so_ops (gdbarch); int nsid = 0; - if (ops->find_solib_ns != nullptr) - { - CORE_ADDR curr_pc = get_frame_pc (get_selected_frame ()); - for (const solib &so : current_program_space->solibs ()) - if (solib_contains_address_p (so, curr_pc)) - { - nsid = ops->find_solib_ns (so); - break; - } - } + CORE_ADDR curr_pc = get_frame_pc (get_selected_frame ()); + for (const solib &so : current_program_space->solibs ()) + if (solib_contains_address_p (so, curr_pc)) + { + if (so.ops ().find_solib_ns != nullptr) + nsid = so.ops ().find_solib_ns (so); + + break; + } /* If the PC is not in an SO, or the solib_ops doesn't support linker namespaces, the inferior is in the default namespace. */ -- 2.49.0