1 # Copyright (C) 2014-2016 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 an explicit "signal FOO" delivers FOO even if "handle" for
17 # that same signal is set to "nopass". Also make sure the signal is
18 # delivered to the right thread, even if GDB has to step over a
19 # breakpoint in some other thread first.
21 if [target_info exists gdb,nosignals] {
22 verbose "Skipping ${testfile}.exp because of nosignals."
28 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
29 executable { debug }] != "" } {
33 # Run the test proper. STEP_OVER indicates whether we leave in place
34 # a breakpoint that needs to be stepped over when we explicitly
35 # request a signal be delivered with the "signal" command.
37 proc test { step_over } {
38 global srcfile binfile
40 with_test_prefix "step-over $step_over" {
41 clean_restart ${binfile}
43 if ![runto_main] then {
44 fail "Can't run to main"
48 gdb_test "handle SIGUSR1 stop print nopass"
50 gdb_test "b thread_function" "Breakpoint .* at .*$srcfile.*"
51 gdb_test "continue" "thread_function.*" "stopped in thread"
53 # Thread 2 is stopped at a breakpoint. If we leave the
54 # breakpoint in place, GDB needs to move thread 2 past the
55 # breakpoint before delivering the signal to thread 1. We
56 # want to be sure that GDB doesn't mistakenly deliver the
57 # signal to thread 1 while doing that.
58 if { $step_over == "no" } {
62 gdb_test "break handler" "Breakpoint .* at .*$srcfile.*"
64 gdb_test "thread 1" "Switching to thread 1.*"
66 set pattern "\\\* 1\[ \t\]+Thread.*"
68 gdb_test "info threads" $pattern "thread 1 selected"
70 gdb_test "signal SIGUSR1" "handler .*"
72 # Make sure it was thread 1 that got the signal. Note we list
73 # all threads instead of just thread 1, so that if something
74 # goes wrong and another thread ends up selected, we can
75 # easily see which in the logs.
76 gdb_test "info threads" $pattern "thread 1 got the signal"
80 foreach stepover {"yes" "no"} {