GDB copyright headers update after running GDB's copyright.py script.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / step-over-lands-on-breakpoint.exp
1 # Copyright (C) 2014-2016 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 gdb_breakpoint [gdb_get_line_number "set wait-thread breakpoint here"]
42 gdb_continue_to_breakpoint "run to wait-thread breakpoint"
43 gdb_test "info threads" "\\\* 1 .* 2 .*" "info threads shows all threads"
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
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.
65 gdb_test "$command" "step-over here.*"
66 }
67 }
68
69 foreach 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.031224 seconds and 4 git commands to generate.