ignore invalid DOF provider sections
[binutils-gdb.git] / gdb / testsuite / gdb.threads / pending-step.exp
blobe087e56cfdc3adc0e72c60e811a418f76f20d879
1 # Copyright (C) 2009-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 # Test that a resume cancels a previously unfinished or unreported
17 # single-step correctly.
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.
23 # scheduler-locking must be set to the default of "off".
25 # Here's what would happen in gdbserver:
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.
30 # 2) We issue a "next" --- this single-steps thread 1, and resumes all
31 #    other threads.
33 # 3) thread 2, due to scheduler-locking off, hits the breakpoint.
34 #    gdbserver stops all other threads by sending them SIGSTOPs.
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.
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.
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.
51 standard_testfile
53 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } {
54     return -1
57 clean_restart ${binfile}
59 if ![runto_main] then {
60     fail "Can't run to main"
61     return 0
64 gdb_breakpoint [gdb_get_line_number "insert breakpoint here"]
65 gdb_continue_to_breakpoint "continue to first breakpoint hit"
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" {
73         -re "Program received signal SIGTRAP.*$gdb_prompt $" {
74             fail "$test (spurious SIGTRAP)"
75         }
76         -re "$gdb_prompt $" {
77             set ok 1
78         }
79     }
81     if { $ok == 0 } {
82         break
83     }
86 if { $ok  } {
87     pass "$test"