Commit | Line | Data |
---|---|---|
01b088bc PA |
1 | # Copyright (C) 2014-2015 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 | # Check that GDB doesn't forget to pass SIGTRAP to the program when | |
17 | # the user explicitly passes it with the signal command. | |
18 | ||
19 | if [target_info exists gdb,nosignals] { | |
20 | verbose "Skipping ${testfile}.exp because of nosignals." | |
21 | return -1 | |
22 | } | |
23 | ||
24 | standard_testfile | |
25 | ||
26 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} { | |
27 | return -1 | |
28 | } | |
29 | ||
30 | # Run test proper. SIGTRAP_THREAD is the thread that should get the | |
31 | # SIGTRAP. | |
32 | ||
33 | proc test { sigtrap_thread } { | |
34 | global srcfile binfile | |
35 | ||
36 | with_test_prefix "sigtrap thread $sigtrap_thread" { | |
37 | clean_restart ${binfile} | |
38 | ||
39 | if ![runto "thread_function"] then { | |
40 | fail "Can't run to thread_function" | |
41 | return 0 | |
42 | } | |
43 | ||
44 | set pattern "\\\* 2\[ \t\]+Thread.*" | |
45 | gdb_test "info threads" $pattern "thread 2 hit breakpoint" | |
46 | ||
47 | gdb_test "break sigtrap_handler" "Breakpoint .* at .*$srcfile.*" | |
48 | ||
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" | |
55 | ||
56 | gdb_test "signal SIGTRAP" \ | |
57 | "Continuing with signal SIGTRAP.*Breakpoint .* sigtrap_handler .*" \ | |
58 | "signal SIGTRAP reaches handler" | |
59 | ||
60 | set pattern "\\\* $sigtrap_thread\[ \t\]+Thread.*" | |
61 | gdb_test "info threads" $pattern "right thread got the signal" | |
62 | } | |
63 | } | |
64 | ||
65 | foreach sigtrap_thread {1 2} { | |
66 | test $sigtrap_thread | |
67 | } |