1 # Copyright (C) 2014-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 # Check that GDB doesn't forget to pass SIGTRAP to the program when
17 # the user explicitly passes it with the signal command.
21 require {!target_info exists gdb,nosignals}
23 if {[build_executable "failed to prepare" $testfile $srcfile \
28 # Run test proper. SIGTRAP_THREAD is the thread that should get the
31 proc test { sigtrap_thread } {
32 global srcfile binfile tdlabel_re
34 with_test_prefix "sigtrap thread $sigtrap_thread" {
35 clean_restart ${binfile}
37 if {![runto "thread_function"]} {
41 set pattern "\\\* 2\[ \t\]+${tdlabel_re}.*"
42 gdb_test "info threads" $pattern "thread 2 hit breakpoint"
44 gdb_test "break sigtrap_handler" "Breakpoint .* at .*$srcfile.*"
46 # Thread 2 is stopped at a breakpoint, which must be stepped
47 # over first. Thus if this is thread 1, then GDB will first
48 # switch back to thread 2 to step it over the breakpoint.
49 gdb_test "thread $sigtrap_thread" \
50 "Switching to thread $sigtrap_thread.*" \
51 "switch to sigtrap thread"
53 gdb_test "signal SIGTRAP" \
54 "Continuing with signal SIGTRAP.*Breakpoint .* sigtrap_handler .*" \
55 "signal SIGTRAP reaches handler"
57 set pattern "\\\* $sigtrap_thread\[ \t\]+${tdlabel_re}.*"
58 gdb_test "info threads" $pattern "right thread got the signal"
62 foreach sigtrap_thread {1 2} {