]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/traced-thread.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / traced-thread.exp
1 # Copyright 2023-2024 Free Software Foundation, Inc.
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
16 # This test only works on GNU/Linux.
17 require !use_gdb_stub isnative
18 require {!is_remote host}
19 require {istarget *-linux*}
20
21 standard_testfile
22
23 if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
24 {debug pthreads}]} {
25 return -1
26 }
27
28 if {![runto "parent_stop"]} {
29 return -1
30 }
31
32 # We don't want to be bothered.
33 gdb_test_no_output "set confirm off"
34
35 set child_pid [get_integer_valueof child_thread_pid -1 "get child pid"]
36
37 # We should not be able to attach to the child at all, because one
38 # thread is being traced. The bug here was that gdb would get into an
39 # infinite loop trying to attach to this thread.
40 gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2"
41 gdb_test "inferior 2" "Switching to inferior 2.*" "switch to inferior 2"
42 # Recognize failures from either gdb or gdbserver.
43 gdb_test "attach $child_pid" \
44 "(Cannot attach to|Attaching to process $decimal failed).*" \
45 "should not attach to child process"
46
47
48 # Now kill the parent process, ending the trace.
49 gdb_test "inferior 1" "Switching to inferior 1.*" "switch to inferior 1"
50 gdb_test "kill" ".*" "kill the parent process"
51
52 # Kill the child process as well. Use the shell to avoid funny
53 # business with gdbserver testing.
54 remote_exec target "kill -9 $child_pid"