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