Files
binutils-gdb/gdb/testsuite/gdb.base/tls-common.exp.tcl
Kevin Buettner de893f31c1 New test - gdb.base/tls-nothreads.exp
This commit introduces a new test, gdb.base/tls-nothreads.exp.

It has a test case, a C file, which has several TLS variables in the
main program, which, once compiled and linked, should end up (in ELF
files) in .tdata and .tbss.  The test compiles the program in a number
of different ways, making sure that each variable is accessible
regardless of how it was compiled.

Note that some of the compilation scenarios end up with a statically
linked executable.  Prior to this series of commits, accessing TLS
variables from a statically linked program on Linux did not work.
For certain targets (x86_64, aarch64, s390x, riscv, and ppc64),
all on Linux, support has been added to GDB for accessing thread
local storage in statically linked executables.  This test is
important for testing those build scenarios.

But it's also important to make sure that GDB's internal TLS support
works for other scenarios too.  In order to accomplish that, the
tests are also run in a mode which forces the internal support to
be used.

It also adds a new file, gdb.base/tls-common.exp.tcl, which includes
some common definitions used by the three new TLS tests, including
the one added by this commit.  In particular, it sets a TCL variable,
'internal_tls_linux_targets' which list the targets mentioned earlier.
This means that as internal TLS support is added for other targets,
the target should be listed in just one file as opposed to three
(or more if other tests using tls-common.exp.tcl are added).

Tested-By: Luis Machado <luis.machado@arm.com>
Approved-By: Luis Machado <luis.machado@arm.com>
2025-04-24 09:54:43 -07:00

51 lines
1.8 KiB
Tcl

# Copyright 2024 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.
# Require statement, variables and procs used by tls-nothreads.exp,
# tls-multiobj.exp, and tls-dlobj.exp.
# The tests listed above are known to work for the targets listed on
# the 'require' line, below.
#
# At the moment, only the Linux target is listed, but, ideally, these
# tests should be run on other targets too. E.g, testing on FreeBSD
# shows many failures which should be addressed in some fashion before
# enabling it for that target.
require {is_any_target "*-*-linux*"}
# These are the targets which have support for internal TLS lookup:
set internal_tls_linux_targets {"x86_64-*-linux*" "aarch64-*-linux*"
"riscv*-*-linux*" "powerpc64*-*-linux*"
"s390x*-*-linux*"}
# The "maint set force-internal-tls-address-lookup" command is only
# available for certain Linux architectures. Don't attempt to force
# use of internal TLS support for architectures which don't support
# it.
if [is_any_target {*}$internal_tls_linux_targets] {
set internal_tls_iters { false true }
} else {
set internal_tls_iters { false }
}
# Set up a kfail with message KFAIL_MSG when KFAIL_COND holds, then
# issue gdb_test with command CMD and regular expression RE.
proc gdb_test_with_kfail {cmd re kfail_cond kfail_msg} {
if [uplevel 1 [list expr $kfail_cond]] {
setup_kfail $kfail_msg *-*-*
}
gdb_test $cmd $re
}