]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.threads/reconnect-signal.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / reconnect-signal.exp
1 # Copyright 2013-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 # Test that disconnecting and reconnecting doesn't lose signals.
17
18 set gdbserver_reconnect_p 1
19 if { [info proc gdb_reconnect] == "" } {
20 unsupported "requires gdbserver reconnect"
21 return 0
22 }
23
24 standard_testfile
25 set executable ${testfile}
26
27 if { [gdb_compile_pthreads \
28 "${srcdir}/${subdir}/${srcfile}" \
29 "${binfile}" \
30 executable {debug}] != "" } {
31 untested "failed to compile"
32 return -1
33 }
34
35 clean_restart $executable
36
37 if {![runto_main]} {
38 return 0
39 }
40
41 gdb_test "continue" "signal SIGUSR1.*" "continue to signal"
42
43 # Check that it's thread 2 that is selected.
44 gdb_test "info threads" "\\* 2 .*" "thread 2 is selected"
45
46 set msg "save \$pc after signal"
47 set saved_pc ""
48 gdb_test_multiple "print/x \$pc" $msg {
49 -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
50 set saved_pc $expect_out(1,string)
51 pass $msg
52 }
53 }
54
55 # Switch to the other thread.
56 gdb_test "thread 1" "thread 1.*" "switch to thread 1"
57
58 # Force GDB to select thread 1 on the remote end as well.
59 gdb_test "print/x \$pc"
60
61 gdb_test "disconnect" "Ending remote debugging\\." "disconnect after signal"
62
63 set test "reconnect after signal"
64
65 set res [gdb_reconnect]
66 if { [lindex $res 0] == 0 } {
67 pass $test
68 } else {
69 fail $test
70 return 0
71 }
72
73 # Check that thread 2 is re-selected.
74 gdb_test "info threads" "\\* 2 .*" "thread 2 is selected on reconnect"
75
76 # Check that the program is still alive, and stopped in the same spot.
77 gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after signal"
78
79 # Check that we didn't lose the signal.
80 gdb_test "info program" "stopped with signal SIGUSR1,.*"
81
82 # Nor does the program.
83 gdb_test "b handle" "Breakpoint .*" "set breakpoint in signal handler"
84 gdb_test "continue" "handle.*" "continue to signal handler"