Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright (C) 2009-2015 Free Software Foundation, Inc. |
c35fafde PA |
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 | # Test that a resume cancels a previously unfinished or unreported | |
17 | # single-step correctly. | |
18 | # | |
19 | # The test consists of several threads all running the same loop. | |
20 | # There is a breakpoint set in the loop, hence all threads may hit it. | |
21 | # The test then issues several "next" commands in a loop. | |
22 | # | |
23 | # scheduler-locking must be set to the default of "off". | |
24 | # | |
25 | # Here's what would happen in gdbserver: | |
26 | # | |
27 | # 1) We issue a "continue", and wait until a thread hits the | |
28 | # breakpoint. Could be any thread, but assume thread 1 hits it. | |
29 | # | |
30 | # 2) We issue a "next" --- this single-steps thread 1, and resumes all | |
31 | # other threads. | |
32 | # | |
33 | # 3) thread 2, due to scheduler-locking off, hits the breakpoint. | |
34 | # gdbserver stops all other threads by sending them SIGSTOPs. | |
35 | # | |
36 | # 4) While being stopped in step 3, thread 1 reports a SIGTRAP, that | |
37 | # corresponds to the finished single-step of step 2. gdbserver | |
38 | # leaves the SIGTRAP pending to report later. | |
39 | # | |
40 | # 5) We issue another "next" --- this requests thread 2 to | |
41 | # single-step, and all other threads to continue, including thread | |
42 | # 1. Before resuming any thread, gdbserver notices that it | |
43 | # remembers from step 4 a pending SIGTRAP to report for thread 1, | |
44 | # so reports it now. | |
45 | # | |
46 | # 6) From GDB's perpective, this SIGTRAP can't represent a finished | |
47 | # single-step, since thread 1 was not single-stepping (it was | |
48 | # continued in step 5). Neither does this SIGTRAP correspond to a | |
49 | # breakpoint hit. GDB reports to the user a spurious SIGTRAP. | |
50 | ||
0efbbabc | 51 | standard_testfile |
c35fafde | 52 | |
0efbbabc | 53 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } { |
c35fafde PA |
54 | return -1 |
55 | } | |
56 | ||
0efbbabc | 57 | clean_restart ${binfile} |
c35fafde PA |
58 | |
59 | if ![runto_main] then { | |
60 | fail "Can't run to main" | |
61 | return 0 | |
62 | } | |
63 | ||
64 | gdb_breakpoint [gdb_get_line_number "insert breakpoint here"] | |
65 | gdb_continue_to_breakpoint "continue to first breakpoint hit" | |
66 | ||
67 | set test "next in multiple threads with breakpoints" | |
68 | set iterations 20 | |
69 | set ok 0 | |
70 | for {set i 0} {$i < $iterations} {incr i} { | |
71 | set ok 0 | |
72 | gdb_test_multiple "next" "$test" { | |
9f47e254 | 73 | -re "Program received signal SIGTRAP.*$gdb_prompt $" { |
c35fafde PA |
74 | fail "$test (spurious SIGTRAP)" |
75 | } | |
76 | -re "$gdb_prompt $" { | |
77 | set ok 1 | |
78 | } | |
79 | } | |
80 | ||
81 | if { $ok == 0 } { | |
82 | break | |
83 | } | |
84 | } | |
85 | ||
86 | if { $ok } { | |
87 | pass "$test" | |
88 | } |