Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.threads / attach-stopped.exp
blob0421ffc3794949fa1bf9ec0f873d64c4f260b59c
1 # Copyright 2008-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This test was created by modifying attach.exp.
17 # This file was created by Jeff Johnston <jjohnstn@redhat.com>.
18 # This file was updated by Jan Kratochvil <jan.kratochvil@redhat.com>.
20 # This test only works on Linux
21 require can_spawn_for_attach
22 require isnative
23 require {!is_remote host}
24 require {istarget *-linux*}
26 standard_testfile
27 set escapedbinfile  [string_to_regexp $binfile]
29 #execute_anywhere "rm -f ${binfile}"
30 remote_exec build "rm -f ${binfile}"
31 # For debugging this test
33 #log_user 1
35 proc corefunc { threadtype } {
36     global binfile
37     global escapedbinfile
38     global gdb_prompt
40     set test_spawn_id [spawn_wait_for_attach $binfile]
41     set testpid [spawn_id_get_pid $test_spawn_id]
43     # Stop the program 
44     remote_exec build "kill -s STOP ${testpid}"
46     clean_restart $binfile
48     # Verify that we can attach to the stopped process.
49        
50     set test "$threadtype: attach2 to stopped, after setting file"
51     gdb_test_multiple "attach $testpid" "$test" {
52         -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
53             pass "$test"
54         }
55     }
57     # ".*sleep.*clone.*" would fail on s390x as bt stops at START_THREAD there.
58     set test "$threadtype: attach2 to stopped bt"
59     if {[string equal $threadtype threaded]} {
60         gdb_test "thread apply all bt" \
61             ".*sleep.*(start_thread| in \\?\\? \\(\\) from ).*" $test
62     } else {
63         gdb_test "bt" ".*sleep.*main.*" $test
64     }
66     gdb_exit
68     # Avoid some race:
69     sleep 2
71     # At this point, the process may be sleeping or T (Stopped) depending on
72     # the Linux kernel version.  The behavior is not tested as it is not
73     # dependent on GDB.
75     kill_wait_spawned_process $test_spawn_id
78 # build the test case first without threads
80 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
81     untested "attach-stopped.exp (unthreaded)"
82     return -1
85 corefunc nonthreaded
87 # build the test case first without threads
89 if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DUSE_THREADS}] != "" } {
90     untested "attach-stopped.exp (threaded)"
91     return -1
94 corefunc threaded