1 # Copyright (C) 2014-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 # Check that GDB doesn't forget to pass SIGTRAP to the program when
17 # the user explicitly passes it with the signal command.
19 if [target_info exists gdb,nosignals] {
20 verbose "Skipping ${testfile}.exp because of nosignals."
26 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} {
30 # Run test proper. SIGTRAP_THREAD is the thread that should get the
33 proc test { sigtrap_thread } {
34 global srcfile binfile
36 with_test_prefix "sigtrap thread $sigtrap_thread" {
37 clean_restart ${binfile}
39 if ![runto "thread_function"] then {
40 fail "Can't run to thread_function"
44 set pattern "\\\* 2\[ \t\]+Thread.*"
45 gdb_test "info threads" $pattern "thread 2 hit breakpoint"
47 gdb_test "break sigtrap_handler" "Breakpoint .* at .*$srcfile.*"
49 # Thread 2 is stopped at a breakpoint, which must be stepped
50 # over first. Thus if this is thread 1, then GDB will first
51 # switch back to thread 2 to step it over the breakpoint.
52 gdb_test "thread $sigtrap_thread" \
53 "Switching to thread $sigtrap_thread.*" \
54 "switch to sigtrap thread"
56 gdb_test "signal SIGTRAP" \
57 "Continuing with signal SIGTRAP.*Breakpoint .* sigtrap_handler .*" \
58 "signal SIGTRAP reaches handler"
60 set pattern "\\\* $sigtrap_thread\[ \t\]+Thread.*"
61 gdb_test "info threads" $pattern "right thread got the signal"
65 foreach sigtrap_thread {1 2} {