]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.threads/tls-core.exp
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / tls-core.exp
CommitLineData
4a94e368 1# Copyright 2017-2022 Free Software Foundation, Inc.
280ca31f
DT
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16standard_testfile
17
18if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
19 executable { debug }] != "" } {
20 return -1
21}
22
d9f6d7f8
MR
23# Generate a native core file.
24
25set corefile [core_find $binfile]
26set core_supported [expr {$corefile != ""}]
27
28# Generate a core file with "gcore".
280ca31f
DT
29
30clean_restart ${binfile}
31
32runto thread_proc
33
d9f6d7f8
MR
34set gcorefile [standard_output_file gcore.test]
35set gcore_supported [gdb_gcore_cmd "$gcorefile" "gcore"]
280ca31f 36
d9f6d7f8
MR
37# Restart gdb and load COREFILE as a core file. SUPPORTED is true iff
38# the core was generated successfully; otherwise, the tests are marked
39# unsupported.
280ca31f 40#
d9f6d7f8
MR
41proc tls_core_test {supported corefile} {
42 upvar target_triplet target_triplet
43 upvar host_triplet host_triplet
44 upvar binfile binfile
45
46 clean_restart ${binfile}
47
48 set test "load core file"
49 if {$supported} {
50 set core_loaded [gdb_core_cmd $corefile $test]
51 } else {
52 set core_loaded 0
53 unsupported $test
54 }
55
56 set test "print thread-local storage variable"
57 if { $core_loaded == 1 } {
58 # This fails in cross-debugging due to the use of native
59 # `libthread_db'.
60 if {![string match $host_triplet $target_triplet]} {
61 setup_kfail "threads/22381" "*-*-*"
62 }
63 gdb_test "p/x foo" "\\$\[0-9]+ = 0xdeadbeef" $test
64 } else {
65 unsupported $test
66 }
67}
280ca31f 68
d9f6d7f8
MR
69with_test_prefix "native" {
70 tls_core_test $core_supported $corefile
280ca31f
DT
71}
72
d9f6d7f8
MR
73with_test_prefix "gcore" {
74 tls_core_test $gcore_supported $gcorefile
280ca31f 75}
280ca31f
DT
76
77gdb_exit