From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id c/uULideFWU8NB8AWB0awg (envelope-from ) for ; Thu, 28 Sep 2023 07:06:15 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=qiCRjdWL; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B52171E0C3; Thu, 28 Sep 2023 07:06:15 -0400 (EDT) Received: from server2.sourceware.org (ip-8-43-85-97.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 A38351E028 for ; Thu, 28 Sep 2023 07:06:13 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 030443861897 for ; Thu, 28 Sep 2023 11:06:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 030443861897 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695899173; bh=/Kj8/Y5Od32ZmrabAHybl2Cr+jj0rapbhgGbCaiBWgc=; h=Date:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=qiCRjdWLfP32doryK4JMr3DaGTezZeq4c2gQKkpnGaUhLxgw1Cx8GjHwhB/ezSctu BJ3y5nxTPD/+GUG4+ZWPWgqNvOUHoAEdHJ5MbcFYFF+Wz8zWJmmGqS83XX60dnb/FA 3TmOSi1nCnz4XkCwGog1D1m9zCRymLye4f7mO440= Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id B7D14384DD3C for ; Thu, 28 Sep 2023 11:05:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B7D14384DD3C Received: from octopus (cust120-dsl54.idnet.net [212.69.54.120]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 136D2813F7; Thu, 28 Sep 2023 11:05:50 +0000 (UTC) Date: Thu, 28 Sep 2023 12:05:45 +0100 To: Kevin Buettner Cc: gdb-patches@sourceware.org, Jan Kratochvil Subject: Re: [PATCH v2] gdb/testsuite: Add relative versus absolute LD_LIBRARY_PATH test Message-ID: <20230928110545.fwldrllu4cg6n3rf@octopus> References: <20230926000918.3270325-1-kevinb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230926000918.3270325-1-kevinb@redhat.com> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (lndn.lancelotsix.com [0.0.0.0]); Thu, 28 Sep 2023 11:05:50 +0000 (UTC) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: , From: Lancelot SIX via Gdb-patches Reply-To: Lancelot SIX Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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 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 . > + > +# 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 >