1 # Copyright 2013-2015 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 # Test that disconnecting and reconnecting doesn't lose signals.
18 set gdbserver_reconnect_p 1
19 if { [info proc gdb_reconnect] == "" } {
24 set executable ${testfile}
26 if { [gdb_compile_pthreads \
27 "${srcdir}/${subdir}/${srcfile}" \
29 executable {debug}] != "" } {
30 untested "Couldn't compile test program."
34 clean_restart $executable
36 if ![runto_main] then {
37 fail "Can't run to main"
41 gdb_test "continue" "signal SIGUSR1.*" "continue to signal"
43 # Check that it's thread 2 that is selected.
44 gdb_test "info threads" "\\* 2 .*" "thread 2 is selected"
46 set msg "save \$pc after signal"
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)
55 # Switch to the other thread.
56 gdb_test "thread 1" "thread 1.*" "switch to thread 1"
58 # Force GDB to select thread 1 on the remote end as well.
59 gdb_test "print/x \$pc"
61 gdb_test "disconnect" "Ending remote debugging\\." "disconnect after signal"
63 set test "reconnect after signal"
65 set res [gdb_reconnect]
66 if { [lindex $res 0] == 0 } {
73 # Check that thread 2 is re-selected.
74 gdb_test "info threads" "\\* 2 .*" "thread 2 is selected on reconnect"
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"
79 # Check that we didn't lose the signal.
80 gdb_test "info program" "stopped with signal SIGUSR1,.*"
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"