From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id e7qINj3z6mcHlCEAWB0awg (envelope-from ) for ; Mon, 31 Mar 2025 15:55:41 -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=eoSZJTWD; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CE8181E0C3; Mon, 31 Mar 2025 15:55: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=-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=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 1F8321E0C0 for ; Mon, 31 Mar 2025 15:55:38 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AE6E83865C2C for ; Mon, 31 Mar 2025 19:55:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE6E83865C2C 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=eoSZJTWD 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 ECC1F384605F for ; Mon, 31 Mar 2025 19:34:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ECC1F384605F 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 ECC1F384605F 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=1743449668; cv=none; b=R4ph9IebVc8P9xjhKRtQeU1QDVX1D9K3nOFU4Vs0cAiDkEF+8sX9gIPFrAnK1rxbK7sBr3bogfdBLiyUTRzYtyNOkTPTq8NchIaul4qLi2wBlVZVVmy0/COjVYrvdpRI75QOjVecOPMKNeXJD3AFLAJE2JySJma7jlA2mAP6Xts= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743449668; c=relaxed/simple; bh=U8my5fM7bS1QlE7UHBndMPgX+u5X9N+Ek7gYJdPLTh0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=SE4pHPNC/3UWa5yQgh9XC6Eshna6Su1HdKzSnHdcR1MDVmnktmgrQQVGl1J+RjKWN7NYr5ECek1XvG3Wx/7UfvW2k8xiUmcFYQbGLUOmRZxM2tMl4jgceCGYab/5ejVjXYo+lcBUaBZv0fKgsURER6wtVURQaiFCOryU6NZLu6U= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECC1F384605F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743449665; 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=U2Vurhmlqr7/07eKbIwh/gwJnhX0bY6XNFGSFyULOmE=; b=eoSZJTWD1qPepiugc1e+qvhtXrHvvB0TZP2bf+MZ+HPTxpyeaAVtp4riaYQC4hAeBdNXo/ ULB6GvATGhNUY6pvJtTTOl4Vxh2UjvIQvS/vF8OWf+UGf2FHB1WbpucI94HF61XKfd1T7r D3nvXlKzcZNLaQC5P4M26+n8OFqFelI= Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-pVAl6kr5POyJT2s42Zn3Vw-1; Mon, 31 Mar 2025 15:34:24 -0400 X-MC-Unique: pVAl6kr5POyJT2s42Zn3Vw-1 X-Mimecast-MFC-AGG-ID: pVAl6kr5POyJT2s42Zn3Vw_1743449663 Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-227e2faab6dso75127855ad.1 for ; Mon, 31 Mar 2025 12:34:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743449663; x=1744054463; 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=U2Vurhmlqr7/07eKbIwh/gwJnhX0bY6XNFGSFyULOmE=; b=SVJZhWTTYTMBuimEcjB+ZQ9fzPrYVunR2ZEhI2laV3x73n/X3XoZlQLUBPnr2kfY++ /ZxZF00e/FEZGB4yAjK+HyB1s2WJJFTWzNZXya8E6P/dZ5ef4zqlkj1vuKphpzkZ0UpA KQQFCFYTFBzeuN8wnJzzz2eTLrjMqdwp2nhIDqQeTKLqBFA6cV2IiJktI5WKwooFwatP 0cyhwfCHaBTEvy7ZQVwQTvKFdGE44RSQwKSjNXphgLQ8haRMA51QzlTGqPTAk2S5PzaG COy34qgFGOnUqLbBVkR0h6Ju1qwOfMMf58tWS11AjjmNFfkpAJ0oJdEd/XyDWa+Qdo8W WjRQ== X-Gm-Message-State: AOJu0Ywncu2HEwd5GJ8cR0JCTJBLw8mFctyxeKsN69aJlzEYcfHcY16Q CA7JlNaLL8HlKwPBt4dE55u844EAA2izVVqQsNqY/pwU9DFb8Gsb+tiH7Spl2BbQ8m4Pbpi1N/U chol5mPv/44oKUukdOlKi70JpSynSuDm+kZI6+v8ZcJXX5wHl4Z9oFnoHUG0U1U5py+hgLGKaLy rEfwCxG+2Hivp2jkpZQAko8TytTHk22dM9iDlXo1WotGd+ X-Gm-Gg: ASbGncvviOUyT4KcR2COddeBqGxZ1KMAxyK1vONJXpXXviKzY22xuVl9Ht2woa6+IXB CO7eaGRJ6u8l4ModNP30dxv+4hxHy8Pugd1LnkwqvmB8DdPz4jANMcEeH8JApwx2U2YXKB32hb+ PCR2ztGHktQ7HZa88V46Lj4GSjyyGgbmYCBK81BQ9OInMBlicB4F1Ihf0eu5zVTEdxhRTTGiQvG nBSw10UOpvL2al9MvCGd5pCSiacWVcG2NyNP1zd0DiInNTa4lO3U8Oeer3wn5vyjPznMI0upktG K29BSDXWUa1KyyYhua9kQnHVZd0= X-Received: by 2002:a05:6a00:1395:b0:736:5725:59b4 with SMTP id d2e1a72fcca58-7398034e500mr15923256b3a.3.1743449662945; Mon, 31 Mar 2025 12:34:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG346R4aW4TNv9eh42IwmvbAiJZcpaE3AQbi9uIcf0kEGIpkd763eT4XpyXEKaOqQAl/ZKgCg== X-Received: by 2002:a05:6a00:1395:b0:736:5725:59b4 with SMTP id d2e1a72fcca58-7398034e500mr15923209b3a.3.1743449662366; Mon, 31 Mar 2025 12:34:22 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:9a69::1001? ([2804:14d:8084:9a69::1001]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-739710d4da2sm7312290b3a.166.2025.03.31.12.34.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Mar 2025 12:34:21 -0700 (PDT) Message-ID: <31155101-1264-44fd-9677-b0db78a9cc0a@redhat.com> Date: Mon, 31 Mar 2025 16:34:19 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] gdb: Introduce user-friendly namespace identifier for "info shared" To: gdb-patches@sourceware.org References: <20250319123035.1563282-2-guinevere@redhat.com> <20250327171312.2768622-2-guinevere@redhat.com> From: Guinevere Larsen In-Reply-To: <20250327171312.2768622-2-guinevere@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Hiy561ZBP2TyIXINrMwG-Olj4pYL1mcpcLc41_OtZkw_1743449663 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 Linaro CI told me there was a problem in the test case in here (thanks again, linaro!). More inlined > diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp > new file mode 100644 > index 00000000000..18856dca7cc > --- /dev/null > +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp > @@ -0,0 +1,106 @@ > +# This testcase is part of GDB, the GNU debugger. > +# > +# Copyright 2025 Free Software Foundation, Inc. > +# > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > +# > +# > +# Test several things related to handling linker namespaces: > +# * That the user-facing namespace ID is consistent; > + > +require allow_dlmopen_tests > + > +standard_testfile -main.c -lib.c > + > +set srcfile_lib $srcfile2 > +set binfile_lib [standard_output_file dlmopen-lib.so] > + > +if { [build_executable "build shlib" $binfile_lib $srcfile_lib \ > + [list debug shlib]] == -1 } { > + return > +} > + > +if { [build_executable "failed to build" $testfile $srcfile \ > + [list additional_flags=-DDSO_NAME=\"$binfile_lib\" \ > + shlib_load debug]] } { > + return > +} > + > +# Run the command "info sharedlibrary" and get the first namespace > +# for the so > +proc get_first_so_ns {} { > + set ns -1 > + gdb_test_multiple "info sharedlibrary" "get SO namespace" -lbl { > + -re "From\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object Library\r\n" { > + exp_continue > + } > + -re "^$::hex\\s+$::hex\\s+\[\[($::decimal)\]\]\\s+\[^\r\n]+$::binfile_lib.*" { Turns out the literal [ and ] should be triple escaped here. I've fixed thios locally > + set ns $expect_out(1,string) > + } > + -re "^$::gdb_prompt $" { > + } > + -re "^\[^\r\n\]+\r\n" { > + exp_continue > + } > + } > + return $ns > +} > + > +# Run the tests relating to the command "info sharedlibrary", to > +# verify that the namespace ID is consistent. > +proc test_info_shared {} { > + clean_restart $::binfile > + > + if { ![runto_main] } { > + return > + } > + > + # First test that we don't print a namespace column at the start. > + gdb_test "info sharedlibrary" \ > + "From\\s+To\\s+Syms\\s+Read\\s+Shared Object Library.*" \ > + "before loading anything" > + > + gdb_breakpoint [gdb_get_line_number "TAG: first dlclose"] > + gdb_continue_to_breakpoint "TAG: first dlclose" > + > + # Next, test that we *do* print a namespace column after loading SOs. > + gdb_test "info sharedlibrary" \ > + "From\\s+To\\s+NS\\s+Syms\\s+Read\\s+Shared Object Library.*" \ > + "after loading everything" > + > + gdb_assert {[get_first_so_ns] == 1} "before closing any library" > + > + gdb_test "next" ".*second dlclose.*" "close first library" > + gdb_assert {[get_first_so_ns] == 2} "after closing one library" > + > + gdb_test "next" ".*third dlclose.*" "close second library" > + gdb_assert {[get_first_so_ns] == 3} "before closing two libraries" > + > + gdb_breakpoint [gdb_get_line_number "TAG: fourth dlclose"] > + gdb_continue_to_breakpoint "TAG: fourth dlclose" > + # As of writing this test, glibc's LMID is just an index on an array of > + # namespaces. After closing a namespace, requesting a new one will > + # return the index of the lowest-closed namespace, so this will likely > + # be namespace 1, and because of glibc's reuse of the r_debug object, > + # GDB should be able to assign the same number. > + gdb_assert {[get_first_so_ns] == [get_integer_valueof "lmid" "-1"]} \ > + "reopen a namespace" > + > + gdb_test "next" ".*return 0.*" "final namespace inactive" > + gdb_test "info sharedlibrary" \ > + "From\\s+To\\s+Syms\\s+Read\\s+Shared Object Library.*" \ > + "after unloading everything" > +} > + > +test_info_shared -- Cheers, Guinevere Larsen She/Her/Hers