Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / step-over-lands-on-breakpoint.exp
1 # Copyright (C) 2014-2022 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 # Test that when a step-over lands on a breakpoint, that breakpoint
17 # hit is reported.
18
19 standard_testfile
20 set executable ${testfile}
21
22 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
23 executable [list debug "incdir=${objdir}"]] != "" } {
24 return -1
25 }
26
27 # The test proper. DISPLACED is true if we should try with displaced
28 # stepping. COMMAND is the execution command to test.
29 proc do_test {displaced command} {
30 global executable
31
32 with_test_prefix "displaced=$displaced: $command" {
33 clean_restart $executable
34
35 if ![runto_main] {
36 continue
37 }
38
39 gdb_test_no_output "set displaced-stepping $displaced"
40
41 set line [gdb_get_line_number "set wait-thread breakpoint here"]
42 if { ![gdb_breakpoint $line] } {
43 return
44 }
45 gdb_continue_to_breakpoint "run to wait-thread breakpoint"
46 gdb_test "info threads" "\\\* 1 .* 2 .*" "info threads shows all threads"
47
48 gdb_test_no_output "set scheduler-locking on"
49
50 delete_breakpoints
51
52 gdb_breakpoint [gdb_get_line_number "set breakpoint child here"]
53 gdb_test "thread 2" "Switching to .*"
54 gdb_continue_to_breakpoint "run to breakpoint in thread 2"
55 gdb_test "p counter = 0" " = 0" "unbreak loop in thread 2"
56
57 # Set a breakpoint exactly where the step-over will land.
58 gdb_breakpoint [gdb_get_line_number "breakpoint after step-over here"]
59
60 # Switch back to thread 1 and disable scheduler locking.
61 gdb_test "thread 1" "Switching to .*"
62 gdb_test_no_output "set scheduler-locking off"
63
64 # Thread 2 is still stopped at a breakpoint that needs to be
65 # stepped over. However, right where the step-over lands
66 # there's another breakpoint installed, which should trap and
67 # be reported to the user.
68 gdb_test "$command" "step-over here.*"
69 }
70 }
71
72 foreach displaced { "off" "on" } {
73 if { $displaced != "off" && ![support_displaced_stepping] } {
74 continue
75 }
76
77 # Cover both stepping and non-stepping execution commands.
78 foreach command { "step" "next" "continue" } {
79 do_test $displaced $command
80 }
81 }
This page took 0.040705 seconds and 4 git commands to generate.