1 1.9 christos # Copyright (C) 2014-2024 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos # Test that when a step-over lands on a breakpoint, that breakpoint 17 1.1 christos # hit is reported. 18 1.1 christos 19 1.1 christos standard_testfile 20 1.1 christos set executable ${testfile} 21 1.1 christos 22 1.1 christos if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ 23 1.1 christos executable [list debug "incdir=${objdir}"]] != "" } { 24 1.1 christos return -1 25 1.1 christos } 26 1.1 christos 27 1.3 christos # The test proper. DISPLACED is true if we should try with displaced 28 1.3 christos # stepping. COMMAND is the execution command to test. 29 1.3 christos proc do_test {displaced command} { 30 1.3 christos global executable 31 1.3 christos 32 1.3 christos with_test_prefix "displaced=$displaced: $command" { 33 1.1 christos clean_restart $executable 34 1.1 christos 35 1.1 christos if ![runto_main] { 36 1.8 christos return 37 1.1 christos } 38 1.1 christos 39 1.3 christos gdb_test_no_output "set displaced-stepping $displaced" 40 1.3 christos 41 1.7 christos set line [gdb_get_line_number "set wait-thread breakpoint here"] 42 1.7 christos if { ![gdb_breakpoint $line] } { 43 1.7 christos return 44 1.7 christos } 45 1.1 christos gdb_continue_to_breakpoint "run to wait-thread breakpoint" 46 1.4 christos gdb_test "info threads" "\\\* 1 .* 2 .*" "info threads shows all threads" 47 1.1 christos 48 1.1 christos gdb_test_no_output "set scheduler-locking on" 49 1.1 christos 50 1.1 christos delete_breakpoints 51 1.1 christos 52 1.1 christos gdb_breakpoint [gdb_get_line_number "set breakpoint child here"] 53 1.1 christos gdb_test "thread 2" "Switching to .*" 54 1.1 christos gdb_continue_to_breakpoint "run to breakpoint in thread 2" 55 1.1 christos gdb_test "p counter = 0" " = 0" "unbreak loop in thread 2" 56 1.1 christos 57 1.1 christos # Set a breakpoint exactly where the step-over will land. 58 1.1 christos gdb_breakpoint [gdb_get_line_number "breakpoint after step-over here"] 59 1.1 christos 60 1.1 christos # Switch back to thread 1 and disable scheduler locking. 61 1.1 christos gdb_test "thread 1" "Switching to .*" 62 1.1 christos gdb_test_no_output "set scheduler-locking off" 63 1.1 christos 64 1.1 christos # Thread 2 is still stopped at a breakpoint that needs to be 65 1.4 christos # stepped over. However, right where the step-over lands 66 1.4 christos # there's another breakpoint installed, which should trap and 67 1.4 christos # be reported to the user. 68 1.1 christos gdb_test "$command" "step-over here.*" 69 1.1 christos } 70 1.1 christos } 71 1.3 christos 72 1.3 christos foreach displaced { "off" "on" } { 73 1.3 christos if { $displaced != "off" && ![support_displaced_stepping] } { 74 1.3 christos continue 75 1.3 christos } 76 1.3 christos 77 1.3 christos # Cover both stepping and non-stepping execution commands. 78 1.3 christos foreach command { "step" "next" "continue" } { 79 1.3 christos do_test $displaced $command 80 1.3 christos } 81 1.3 christos } 82