From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ejNQLC/GUWj/YBIAWB0awg (envelope-from ) for ; Tue, 17 Jun 2025 15:46:55 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Q+256OeK; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A27161E11C; Tue, 17 Jun 2025 15:46:55 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham 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 D4C7A1E089 for ; Tue, 17 Jun 2025 15:46:52 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3E61C38844EC for ; Tue, 17 Jun 2025 19:46:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E61C38844EC Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Q+256OeK Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id BD5F138844EC for ; Tue, 17 Jun 2025 19:45:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BD5F138844EC Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BD5F138844EC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750189555; cv=none; b=AFYutO4Q0vr9T7uUtcpOPk/W0m3p6YGp1xoeU/MsYeRJieGmQlkDzH0g9a28S1dBrcgvw0K+FZO/rhf78qi7oVomhtTt2j8k0Y+3ZFSpM9nyjOKR7avrCTwPcjh49qyh2UCHPIRWXrPUfuVgc4qoXz9gBz8F+JTEhbqw0N7m6XE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750189555; c=relaxed/simple; bh=9yB1Cpofymn/spc8/Nda0KlGyitNtcJa37l4l6SbcAo=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=V5f0A8tWVkcKZ4zw+mdj/NHGELoKHSQmODVFLxm83beLcvcNYO6ujdXFVFC3mFy3MYk6d6OKjE/zdAjTocznv2PM9yE9RGQpGeTGfGJFJDpsZY0D3594Dv5Cb6c4vHpeY3F+iDe/eBujXxs8vkHdQU5BlKv0gyugCqVAvoCd+7w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD5F138844EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750189555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qeEE3bOxgW9yz2DTB+coF6hEZhgT5oJEN8/f+tS1W/s=; b=Q+256OeKa3qarGRldZAqHWigPS9jg7AyVcaWI2aP7oHsbaK6tPPnlovt3aHa/zNDWDC+3G k2R2AweRFXCycDqGdVqGDfWvT8topqMei83Vggcvzp1VUAQvzphqmRIXcHrMMYmMUxIGHG yRiaSr2XuPReHoiV6CWXcIJHWMfJLOY= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-37-pC2IfvWtPni4ptVj8irFdQ-1; Tue, 17 Jun 2025 15:45:54 -0400 X-MC-Unique: pC2IfvWtPni4ptVj8irFdQ-1 X-Mimecast-MFC-AGG-ID: pC2IfvWtPni4ptVj8irFdQ_1750189553 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-4a461632999so120096931cf.1 for ; Tue, 17 Jun 2025 12:45:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750189553; x=1750794353; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qeEE3bOxgW9yz2DTB+coF6hEZhgT5oJEN8/f+tS1W/s=; b=USYXZ+EX/1GW+ldKcOyYewdY7kOpe8veHUWospHu9Yd9V00q7nlqeW14EyqQ251eCd TR4+ljJlvCC8G/iKZWMWH75FCVsYSpn1JwAW+sHBRPMP92nEMFgQC4vZ1knJSGDCEJgp QI+j6ALqZn/4gykOEbS1CrYclrBUW1k0zqC+Gwwg4Ei/U55MPFFHLlbWAPs/M6au/v6k y18sLzsHeW3epXteg8oan/sCIFYO3EROzcZipH0FpsGbDqVZC21ELfD8QPnWzeCOfUbD 8LADA//PfBYfBaTneTvCZ/qNTilO7AqnNDnuuPsnI/uMowxHu70zQjQ/HGqRG8JA9uL3 b5eA== X-Forwarded-Encrypted: i=1; AJvYcCVnWgi2yC1Owr/Y12ZgeKdjhwL58Ze3bGpl84I7uNu2YAYMtcnREAjPtO/jB279JZyW8rBWo4aIoM+ESQ==@sourceware.org X-Gm-Message-State: AOJu0YyhiLRfRmtgU8UeeofplxXzvx+ZEhtLSdiwEUps3WKV/arHPSqi CY8eLQHeHnAi3jKvDQa3F0c3z2dbNOAeFuA/3Q8PcffGlyq0+G+SwF1MNQ7TGsda7aTZg0kxEFR AE49xe2RjYZuVqE4hMUYPv1Wbz6VJDEirog1+7xBK0zojJmbbkyXqOgZdxVo8JFA= X-Gm-Gg: ASbGncvbpPIv3dKzdV3JDeyyZXev3daVGhL6pfs3efCflBinFGq2YjX/gN3mQsd55Qn 4/MVi18XwqlY9PmaTVOT+EbL17egXGKOvMBxw2RlJa56Zb3YyfHQYM2G25fXy/k6XBkOmxutMgw /sWTWMq3o9liyrTslRoQJQdtrN0l3jwotr8Hed9EXN9fVDSL1LdDtizdpZsIsx1zAU19MxLeIPe yrI2vspaYSxT4DNQFQbkZrNqWYBZPgze8he5DiI43HYHEbj7KOJGA9HyQefyAmayOpWMSnEU8Qv qS3K9QnwOWxdFj1G/qrO6qBLapwfRwToBQ== X-Received: by 2002:ac8:5948:0:b0:4a7:1460:31db with SMTP id d75a77b69052e-4a73c589974mr191253671cf.26.1750189553452; Tue, 17 Jun 2025 12:45:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQsKyJxBUd3clMtZ2ec2/KTLpt6Rkz4Mm2xls+ez17JLJq/51JSwJRBW6C1ClBBnH+imb4Hg== X-Received: by 2002:ac8:5948:0:b0:4a7:1460:31db with SMTP id d75a77b69052e-4a73c589974mr191253341cf.26.1750189552928; Tue, 17 Jun 2025 12:45:52 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:9a69::1000? ([2804:14d:8084:9a69::1000]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4a72a2e94fesm64966121cf.24.2025.06.17.12.45.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Jun 2025 12:45:52 -0700 (PDT) Message-ID: Date: Tue, 17 Jun 2025 16:45:50 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 5/6] gdb/progspace: add solib_ops pointer in program_space To: Simon Marchi , gdb-patches@sourceware.org References: <20250616193443.16703-1-simon.marchi@efficios.com> <20250616193443.16703-5-simon.marchi@efficios.com> From: Guinevere Larsen In-Reply-To: <20250616193443.16703-5-simon.marchi@efficios.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: GOc3iGUV--TVYA4QOA2MnjqLVXBenGHm7J_LwlnDm7c_1750189553 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 6/16/25 4:33 PM, Simon Marchi wrote: > New in v3: > > - add some ops nullptr checks in print_solib_list_table and > info_linker_namespace_command > > The subsequent C++ification patch in this series will allocate one > instance of solib_ops per program space. That instance will be held in > struct program_space. As a small step towards this, add an `solib_ops > *` field to `struct program_space`. This field represents the solib_ops > currently used to manage the solibs in that program space. Initialize > it with the result of `gdbarch_so_ops` in `post_create_inferior`, and > use it whenever we need to do some solib stuff, rather than using > `gdbarch_so_ops` directly. > > The difficulty here is knowing when exactly to set and unset the solib > ops. What I have here passes the testsuite on Linux, but with more > testing we will probably discover more spots where it's needed. > > The C++ification patch will turn this field into a unique pointer. > > With this patch, the message we get when running "info > linker-namespaces" becomes always the same, so update the test in > gdb.base/dlmopen-ns-ids.exp. > > Change-Id: Ide8ddc57328895720fcd645d46dc34491f84c656 Thanks for working on this series! I have one very minor nit in this patch, but with that fixes, you can feel free to add my review tag Reviewed-By: Guinevere Larsen Feel free to add it to patches 1-4 as well, as I looked over them and they all LGTM. I still don't feel qualified to offer it for patch 6, though. > --- > gdb/corelow.c | 2 +- > gdb/infcmd.c | 15 ++++--- > gdb/inferior.h | 9 +++- > gdb/infrun.c | 11 ++++- > gdb/progspace.h | 20 +++++++++ > gdb/solib.c | 55 +++++++++++++---------- > gdb/target.c | 1 + > gdb/testsuite/gdb.base/dlmopen-ns-ids.exp | 3 +- > gdb/tracectf.c | 2 +- > gdb/tracefile-tfile.c | 2 +- > 10 files changed, 83 insertions(+), 37 deletions(-) > > diff --git a/gdb/solib.c b/gdb/solib.c > index d008a72c5a38..675f64e2ae51 100644 > --- a/gdb/solib.c > +++ b/gdb/solib.c > @@ -707,7 +707,10 @@ notify_solib_unloaded (program_space *pspace, const solib &so, > void > update_solib_list (int from_tty) > { > - const solib_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); > + const solib_ops *ops = current_program_space->solib_ops (); > + > + if (ops == nullptr) > + return; > > /* We can reach here due to changing solib-search-path or the > sysroot, before having any inferior. */ > @@ -1021,16 +1024,21 @@ print_solib_list_table (std::vector solib_list, > gdbarch *gdbarch = current_inferior ()->arch (); > /* "0x", a little whitespace, and two hex digits per byte of pointers. */ > int addr_width = 4 + (gdbarch_ptr_bit (gdbarch) / 4); > - const solib_ops *ops = gdbarch_so_ops (gdbarch); > + const solib_ops *ops = current_program_space->solib_ops (); > struct ui_out *uiout = current_uiout; > bool so_missing_debug_info = false; > > + if (ops == nullptr) > + return; > + > /* There are 3 conditions for this command to print solib namespaces, > first PRINT_NAMESPACE has to be true, second the solib_ops has to > support multiple namespaces, and third there must be more than one > active namespace. Fold all these into the PRINT_NAMESPACE condition. */ > - print_namespace = print_namespace && ops->num_active_namespaces != nullptr > - && ops->num_active_namespaces () > 1; > + print_namespace = (print_namespace > + && ops != nullptr This check is redundant with the previous early exit. The only reason I bring this up is because the comment brings up "3 conditions" but there are 4 checks in this expression. The comment isn't wrong, but it does the code confusing until you figure out that checking if solib_ops is present isn't one of the conditions. -- Cheers, Guinevere Larsen She/Her/Hers > + && ops->num_active_namespaces != nullptr > + && ops->num_active_namespaces () > 1); > > int num_cols = 4; > if (print_namespace)