Remove obsolete test from gdb.cp/var-tag.exp
[binutils-gdb.git] / gdb / testsuite / gdb.threads / pending-step.exp
blob64b421b765982ab5a08c1f69f449098c8a856021
1 # Copyright (C) 2009-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 # 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]} {
60     return 0
63 gdb_breakpoint [gdb_get_line_number "insert breakpoint here"]
64 gdb_continue_to_breakpoint "continue to first breakpoint hit"
66 set test "next in multiple threads with breakpoints"
67 set iterations 20
68 set ok 0
69 for {set i 0} {$i < $iterations} {incr i} {
70     set ok 0
71     gdb_test_multiple "next" "$test" {
72         -re " received signal SIGTRAP.*$gdb_prompt $" {
73             fail "$test (spurious SIGTRAP)"
74         }
75         -re "$gdb_prompt $" {
76             set ok 1
77         }
78     }
80     if { $ok == 0 } {
81         break
82     }
85 if { $ok  } {
86     pass "$test"