]>
Commit | Line | Data |
---|---|---|
8a4ac37e PA |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | # | |
1d506c26 | 3 | # Copyright 2012-2024 Free Software Foundation, Inc. |
8a4ac37e PA |
4 | # |
5 | # Contributed by Intel Corporation. | |
6 | # | |
7 | # This program is free software; you can redistribute it and/or modify | |
8 | # it under the terms of the GNU General Public License as published by | |
9 | # the Free Software Foundation; either version 3 of the License, or | |
10 | # (at your option) any later version. | |
11 | # | |
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | ||
20 | # Test gdbserver to handle qGetTLSAddr requests gracefully in case | |
21 | # libthread_db could not be loaded. | |
22 | ||
23 | load_lib gdbserver-support.exp | |
24 | ||
25 | standard_testfile | |
26 | set unresolvable_thread_db_path "/foo/bar" | |
27 | ||
cadfc59b | 28 | require allow_gdbserver_tests |
8a4ac37e PA |
29 | |
30 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
31 | return -1 | |
32 | } | |
33 | ||
8dc558a0 SM |
34 | save_vars { GDBFLAGS } { |
35 | # If GDB and GDBserver are both running locally, set the sysroot to avoid | |
36 | # reading files via the remote protocol. | |
37 | if { ![is_remote host] && ![is_remote target] } { | |
38 | set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\"" | |
39 | } | |
40 | ||
41 | clean_restart ${testfile} | |
42 | } | |
8a4ac37e PA |
43 | |
44 | # Make sure we're disconnected, in case we're testing with an | |
45 | # extended-remote board, therefore already connected. | |
46 | gdb_test "disconnect" ".*" | |
47 | ||
48 | gdbserver_run "" | |
49 | ||
50 | # Force gdbserver to fail to load libthread_db. | |
51 | gdb_test "monitor set libthread-db-search-path ${unresolvable_thread_db_path}" \ | |
52 | "libthread-db-search-path set to `${unresolvable_thread_db_path}'" \ | |
53 | "libthread-db is now unresolvable" | |
54 | ||
55 | # Continue past tls assignment to make sure tls storage is allocated. | |
498a4489 | 56 | gdb_breakpoint ${srcfile}:[gdb_get_line_number "after tls assignment"] |
8a4ac37e PA |
57 | gdb_continue_to_breakpoint "after tls assignment" |
58 | ||
59 | # Printing a tls variable should fail gracefully without a libthread_db. | |
21b61fe2 | 60 | set re_exec "\[^\r\n\]*[file tail $binfile]" |
8a4ac37e | 61 | gdb_test "print foo" \ |
21b61fe2 | 62 | "Cannot find thread-local storage for Thread \[^,\]+, executable file $re_exec:\[\r\n\]+Remote target failed to process qGetTLSAddr request" |