From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id vZE2MWFw2GesBxMAWB0awg (envelope-from ) for ; Mon, 17 Mar 2025 14:56:33 -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=WPu0xwkF; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B994E1E100; Mon, 17 Mar 2025 14:56:33 -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.4 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 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 283431E0C0 for ; Mon, 17 Mar 2025 14:56:33 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C0BEA3857432 for ; Mon, 17 Mar 2025 18:56:32 +0000 (GMT) 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 752CA3858CDB for ; Mon, 17 Mar 2025 17:07:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 752CA3858CDB 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 752CA3858CDB 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=1742231274; cv=none; b=TwJAqYOMskcrtfY25w+DMBdbb+XizxbSYj4mdA+ELFC1xipM66AaFoCdVO7YNLwHskf2XDx5PQjqoT7GaLLEqOA6hJrU+slRuZIObdfdDWvcSSSYwjLyMwf4erGM+YvN3wr52fqJ8QIuMuArL1R1w8KnXAUG4t49GRpW+MyaIoY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742231274; c=relaxed/simple; bh=ncovz1CDG/MxiDkoBDpYgxPZMeGLl64AX+GNIuh2LsE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=BRzm0PxZDvXNvJG7nS42VFKPwz1jbpyJJsFT+NwQ9L3Z4ra25SNCD3nT8p5GIRGNlIW2bnEUmAcu8ZczBWXTCGUBitfBDXaRnbjKbI+tTMgGJPXY/Tx1tMcqSqTip3D/sBggfJb5BdP3ikbL9WY4iUGmmoZLSXcJW+BMq6R7REE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 752CA3858CDB 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=WPu0xwkF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742231274; 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=bUWPqGkjwAu7F8e0gHSk8Z9bx0nGaYhf2R93dNli0oA=; b=WPu0xwkFH/gyRfceUcbeIgduw0qP3w0NEXGz7/ErfV0s2hxPg2Tey6XvFqeHtTn6Sx7Mvc 1rg7tWKUyUlB7RjYJ+RNGhYmONxy/EzX4gzttwIO61oUelfVgm3dVWn5o3VPG0NaGXsCJ7 sIp1bRcuxLIEAJUfakExt1ifcG72tBA= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-2LN4gw-DNlKDzLkBcawJuQ-1; Mon, 17 Mar 2025 13:07:52 -0400 X-MC-Unique: 2LN4gw-DNlKDzLkBcawJuQ-1 X-Mimecast-MFC-AGG-ID: 2LN4gw-DNlKDzLkBcawJuQ_1742231272 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-2ff798e8c3bso3993652a91.2 for ; Mon, 17 Mar 2025 10:07:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742231271; x=1742836071; 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=bUWPqGkjwAu7F8e0gHSk8Z9bx0nGaYhf2R93dNli0oA=; b=qWJU4dZM1oVcP2tG7YaV0yzdWTNzIwpgIg55gs/AbnwRCybbzzf2OAB08zDW3pvm8a T9qXy6FXG53z8koAkQelTmLHWygPpwK3bXacmZJRRPpwNti0sUOq2H8hOow83gOhQtAJ ZuESmBwRSIvuBEb9gvK+f4qMY5bzpu+Gw86z0zFsKVLWny6pj2ZZwF5cY15fqeB5xLe4 1oeTv4XRzSfVdQ2F34Ka2mN3+pYDJXzTmrq+JYTgg5gpLtkxnhhEErwsXVjg5zkww+Lz 997wMNUUTe6gzmQDeyGl4No4wR02hSL4dKnvYVto4+H/JZeln2/66rJj/6ZpQdjGgBdp chLA== X-Forwarded-Encrypted: i=1; AJvYcCXhCQ6z+w5FTSe1L+fEpe2RxoBssunCp56+2ED9FISFFUHAdmHXTu6kJPb3cOSF7fmk08RL2LkCaWCkOw==@sourceware.org X-Gm-Message-State: AOJu0YxabTfhpHAixwzUBKVipdGWMkMqiB/EQiKs1CkWaJ3LQaGkKaiC WcsI1YEE2H6eyrKt2/LtLemtTDrAzHfDjToLTsKbcVY+vt602NRnbXM0xo7nYVZXzynBOwUpTtd MraTS4lFrDWmAUTZvwyaYGbaRCqzXAyhQmxMMp1Cv3xmr3pYI3oD4bmYNoLw= X-Gm-Gg: ASbGnct0FZUaiDKAVm3CduV5Iho87MQXjRQ6wyhCciCAGJmKcbghG+/EYthzVHdwK7Z jwxd/Phxn99mB6dOQDqHPJxh1Onu9KsmIOxWAJzE40AEyLbhhTLzP0OKLv0BngVRFK0POXmK4nY RlRp/rlJRmhP3IMuta9x9GYdvC4JjrkS0vHUf//3c5wIHSIuCniyLzERK4uFdKrt/B2ttUFFEzA NGdG422/l9LtuOUkz6EWutuDAJ17CLtqkTYiwXdPGPF5CZW+vIUguY0MQ1T3bZ4Z9NDh8xXVDH7 oiER+gwRQYmHcbAGg+x3i6CDEfU= X-Received: by 2002:a17:90b:254e:b0:2f1:2fa5:1924 with SMTP id 98e67ed59e1d1-30151d3d755mr13557137a91.26.1742231271642; Mon, 17 Mar 2025 10:07:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRoBhJNCDvHAuHivUQCrw/3wtW47czhwmPG0/+VtOoNBvynmQjcVBACrhLldkJhKo0hCZ2Cg== X-Received: by 2002:a17:90b:254e:b0:2f1:2fa5:1924 with SMTP id 98e67ed59e1d1-30151d3d755mr13557107a91.26.1742231271164; Mon, 17 Mar 2025 10:07:51 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:9a69::1001? ([2804:14d:8084:9a69::1001]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3015363274csm6319028a91.38.2025.03.17.10.07.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Mar 2025 10:07:50 -0700 (PDT) Message-ID: <4fa90990-09d0-450d-9006-f0a296b2dad9@redhat.com> Date: Mon, 17 Mar 2025 14:07:47 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb: Introduce user-friendly namespace identifier for "info shared" To: Simon Marchi , gdb-patches@sourceware.org References: <20250313170004.3362207-2-guinevere@redhat.com> <3ae8ab32-8633-4a07-bc4f-5bdab899aa31@simark.ca> From: Guinevere Larsen In-Reply-To: <3ae8ab32-8633-4a07-bc4f-5bdab899aa31@simark.ca> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: xq5188rp6bH-xap6McEb4C3noyH58WBnSQSZtEh5bfw_1742231272 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 3/17/25 12:36 PM, Simon Marchi wrote: > I didn't do a full review, I can review more in depth a future version > (since you'll probably change the behavior of the "info shared" column > anyway). I noted some high level things: > > On 3/13/25 1:00 PM, Guinevere Larsen wrote: >> diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c >> index 8378ecaff40..dabbd68d02e 100644 >> --- a/gdb/solib-svr4.c >> +++ b/gdb/solib-svr4.c >> @@ -405,11 +405,59 @@ struct svr4_info >> The special entry zero is reserved for a linear list to support >> gdbstubs that do not support namespaces. */ >> std::map> solib_lists; >> + >> + /* Mapping between r_debug[_ext] addresses and a user-friendly >> + identifier for the namespace. We use both a vector and an unordered >> + map for a couple of reasons. The vector is used to make it >> + easy to assign new internal IDs to namespaces, and to double check >> + which namespaces are still active. The map is used when we're >> + rewriting the solib_lists, to make sure that IDs remain consistent >> + as SOs get dlclosed and deactivate namespaces. >> + >> + For gdbservers that don't support namespaces, the first entry of the >> + vector will be nullptr, and the map will be empty. >> + >> + A note on consistency. We can't make the IDs be consistent before >> + and after the initial relocation of the inferior (when the global >> + _r_debug is relocated, as mentioned in the previous comment). It is >> + likely that this is a non-issue, since the inferior can't have called >> + dlmopen yet, but I think it is worth noting. >> + >> + The only issue I am aware at this point is that, if when parsing an >> + XML file, we read an LMID that given by an XML file (and read in >> + library_list_start_library) is the identifier obtained with dlinfo >> + instead of the address of r_debug[_ext], and after attaching the >> + inferior adds another SO to that namespace, we might double-count it >> + since we won't have access to the LMID later on. However, this is >> + already a problem with the existing solib_lists code. */ >> + std::vector namespace_id_vec; >> + std::unordered_map namespace_id_map; > Since the count of namespaces is always expected to be small, you could > consider just maintaining just a vector. For example, glibc only > supports a max of 16 namespaces today. Maintaining one data structure > is usually easier than maintaining two in parallel. The issue here is handling dlclose calls. When svr4 detects a dlclose call, it will clear the solib_lists object, and read all the SOs again. So if the dlclose call has deactivated a namespace, we don't have an easy way to identify which namespaces were deactivated, and the way to handle this is to deactivate them all and reactivate them in svr4_maybe_add_namespace. And we need all the data to reactivate namespaces to be stored in svr4_info, because if the target is a gdbserver, we're reading everything through svr4_current_sos_via_xfer_libraries, and it doesn't sound like a good idea to modify the xml parsing code to pass some context that would only be useful for solib-svr4. While writing this, I realized I might be able to simplify this, having just a set of namespace IDs that are active, which will make the synchronization much simpler. > >> diff --git a/gdb/solist.h b/gdb/solist.h >> index 9a157a4bbae..a6822877770 100644 >> --- a/gdb/solist.h >> +++ b/gdb/solist.h >> @@ -180,6 +180,17 @@ struct solib_ops >> name). */ >> >> std::optional (*find_solib_addr) (solib &so); >> + >> + /* Return which linker namespace contains the current so. > "the current so", or just "SO" (... which linker namespace contains SO)? > >> + If the linker or libc does not support linkage namespaces at all >> + (which is basically all of them but solib-svr4), this function should >> + be set to nullptr, so that "info shared" won't add an unnecessary >> + column. > I would not put a statement like "which is basically all of them but > solib" in the interface here. It is true until it isn't. I think it's > fine to sometimes mention a specific implementation in the interface > documentation to explain why a certain method exists or to give an > example, which helps the reader understand what the method does. But in > this case I don't think mentioning solib-svr4 helps understand what > find_solib_ns does. > > Simon > I'll fix these other comments. -- Cheers, Guinevere Larsen She/Her/Hers