From: Guinevere Larsen <guinevere@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH v3] gdb: Introduce user-friendly namespace identifier for "info shared"
Date: Mon, 31 Mar 2025 16:34:19 -0300 [thread overview]
Message-ID: <31155101-1264-44fd-9677-b0db78a9cc0a@redhat.com> (raw)
In-Reply-To: <20250327171312.2768622-2-guinevere@redhat.com>
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 <http://www.gnu.org/licenses/>.
> +#
> +#
> +# 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
next prev parent reply other threads:[~2025-03-31 19:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 17:00 [PATCH] " Guinevere Larsen
2025-03-13 19:19 ` Eli Zaretskii
2025-03-13 19:27 ` Guinevere Larsen
2025-03-15 2:51 ` Kevin Buettner
2025-03-15 3:11 ` Kevin Buettner
2025-03-17 11:55 ` Guinevere Larsen
2025-03-17 15:36 ` Simon Marchi
2025-03-18 1:07 ` Kevin Buettner
2025-03-17 15:36 ` Simon Marchi
2025-03-17 17:07 ` Guinevere Larsen
2025-03-17 17:54 ` Simon Marchi
2025-03-19 12:30 ` [PATCH v2] " Guinevere Larsen
2025-03-21 17:55 ` Guinevere Larsen
2025-03-27 17:13 ` [PATCH v3] " Guinevere Larsen
2025-03-31 19:34 ` Guinevere Larsen [this message]
2025-04-05 20:17 ` Kevin Buettner
2025-04-07 13:07 ` Guinevere Larsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=31155101-1264-44fd-9677-b0db78a9cc0a@redhat.com \
--to=guinevere@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox