From: Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org>
To: Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sourceware.org, Jan Kratochvil <jan@jankratochvil.net>
Subject: Re: [PATCH v2] gdb/testsuite: Add relative versus absolute LD_LIBRARY_PATH test
Date: Thu, 28 Sep 2023 12:05:45 +0100 [thread overview]
Message-ID: <20230928110545.fwldrllu4cg6n3rf@octopus> (raw)
In-Reply-To: <20230926000918.3270325-1-kevinb@redhat.com>
Hi Kevin,
FWIW, the patch looks good to me. I do have one extra small detail
inlined below.
With that small fix (tested locally),
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Best,
Lancelot.
> diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
> new file mode 100644
> index 00000000000..1be1674fab1
> --- /dev/null
> +++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
> @@ -0,0 +1,95 @@
> +# Copyright 2006-2023 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/>.
> +
> +# This test creates a shared library and a main program which uses
> +# that library, extracts the debug info of the library to a separate
> +# file, and then tests that a symbol from the shared library is
> +# accessible using both absolute and relative settings of
> +# LD_LIBRARY_PATH.
> +
> +# This test needs to change the environment in which the test program
> +# is run, specifically the setting of LD_LIBRARY_PATH. GDB can adjust
> +# this setting for both native and extended-remote targets, but not
> +# for targets to which GDB connects after the program has already
> +# started. Therefore, this test won't work for targets which use
> +# "target remote".
> +require !use_gdb_stub
> +require {have_compile_flag -std=c11}
> +
> +set testfile tls-sepdebug
> +set srcmainfile ${testfile}-main.c
> +set srcsharedfile ${testfile}-shared.c
> +
> +set binmainfile [standard_output_file ${testfile}-main]
> +set binsharedbase ${testfile}-shared.so
> +set binsharedfile [standard_output_file ${binsharedbase}]
> +
> +# Build the shared library, but use explicit -soname; otherwise the
> +# full path to the library would get encoded into ${binmainfile}
> +# making LD_LIBRARY_PATH tests useless.
> +#
> +# The compile flag -std=c11 is required because the test case uses
> +# 'thread_local' to indicate thread local storage. This is available
> +# as a macro starting in C11 and became a C-language keyword in C23.
> +if { [gdb_compile_shlib \
> + "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" \
> + [list debug \
> + ldflags=-Wl,-soname=${binsharedbase} \
> + additional_flags=-std=c11]] \
> + != "" } {
> + untested "Couldn't compile test library"
> + return -1
> +}
> +
> +# Strip debug information from $binsharedfile, placing it in
> +# ${binsharedfile}.debug. Also add a .gnu_debuglink in the former,
> +# pointing to the latter.
> +gdb_gnu_strip_debug ${binsharedfile}
> +
> +# Build main program, but do not use `shlib=' since that would
> +# automatically add -rpath for gcc.
> +if { [gdb_compile_pthreads \
> + "${srcdir}/${subdir}/${srcmainfile} ${binsharedfile}" \
> + "${binmainfile}" executable [list debug additional_flags=-std=c11]] \
> + != "" } {
> + untested "Couldn't compile test program"
> + return -1
> +}
> +
> +set absdir [file dirname [standard_output_file ${binsharedbase}]]
> +
> +foreach ld_library_path [list $absdir [relative_filename [pwd] $absdir]] \
> + name { absolute relative } {
> + with_test_prefix $name {
> +
> + # Restart, but defer loading until after setting LD_LIBRARY_PATH.
> + clean_restart
> +
> + gdb_test_no_output "set env LD_LIBRARY_PATH=$ld_library_path" \
> + "set env LD_LIBRARY_PATH"
> +
> + gdb_load ${binmainfile}
> +
> + if ![runto_main] {
> + return
> + }
> +
> + # Print a thread local variable from the shared library to be certain
> + # that its symbols were loaded from the separate debuginfo file.
> + gdb_test "print var" \
> + "\\\$1 = \[0-9\].*" \
I think here you can be more specific as you know the actual value which
is expected:
"\\\$1 = 42"
> + "print TLS variable from a shared library with separate debug info file"
> + }
> +}
> --
> 2.41.0
>
next prev parent reply other threads:[~2023-09-28 11:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 0:07 Kevin Buettner via Gdb-patches
2023-09-28 11:05 ` Lancelot SIX via Gdb-patches [this message]
2023-09-29 1:52 ` Kevin Buettner via Gdb-patches
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=20230928110545.fwldrllu4cg6n3rf@octopus \
--to=gdb-patches@sourceware.org \
--cc=jan@jankratochvil.net \
--cc=kevinb@redhat.com \
--cc=lsix@lancelotsix.com \
/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