1 1.1.1.4 christos # Copyright 2018-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 # This testcase is a regression test for a regression in the in-line 17 1.1 christos # step-over machinery. If a resumption that starts a step-over 18 1.1 christos # failed, a following resumption would make GDB hang forever: 19 1.1 christos # 20 1.1 christos # (gdb) b *0 21 1.1 christos # Breakpoint 2 at 0x0 22 1.1 christos # continue 23 1.1 christos # Continuing. 24 1.1 christos # Warning: 25 1.1 christos # Cannot insert breakpoint 2. 26 1.1 christos # Cannot access memory at address 0x0 27 1.1 christos # 28 1.1 christos # Command aborted. 29 1.1 christos # delete breakpoints 30 1.1.1.4 christos # Delete all breakpoints, watchpoints, tracepoints, and catchpoints? (y or n) y 31 1.1 christos # (gdb) b function 32 1.1 christos # Breakpoint 3 at 0x40048b: file test.c, line 33. 33 1.1 christos # continue 34 1.1 christos # Continuing. 35 1.1 christos # *GDB hangs forever* 36 1.1 christos 37 1.1 christos standard_testfile 38 1.1 christos 39 1.1 christos if {[build_executable "failed to prepare" $testfile $srcfile debug]} { 40 1.1 christos return -1 41 1.1 christos } 42 1.1 christos 43 1.1 christos # DISPLACED indicates whether to use displaced-stepping. 44 1.1.1.3 christos proc do_test {displaced breakpoint_always_inserted} { 45 1.1 christos global gdb_prompt decimal 46 1.1 christos global srcfile binfile 47 1.1 christos 48 1.1 christos clean_restart $binfile 49 1.1 christos 50 1.1 christos gdb_test_no_output "set displaced-stepping $displaced" 51 1.1.1.3 christos gdb_test_no_output "set breakpoint always-inserted $breakpoint_always_inserted" 52 1.1 christos 53 1.1 christos if ![runto_main] { 54 1.1 christos return -1 55 1.1 christos } 56 1.1 christos 57 1.1 christos # We rely on not being able to set a breakpoint at 0, as proxy for 58 1.1 christos # any kind of breakpoint insertion failure. If we can examine 59 1.1 christos # what's at memory address 0, it is possible that we could also 60 1.1 christos # execute it. 61 1.1 christos if [is_address_zero_readable] { 62 1.1 christos untested "memory at address 0 is possibly executable" 63 1.1 christos return 64 1.1 christos } 65 1.1 christos 66 1.1 christos # Set a breakpoint that fails to insert. 67 1.1.1.3 christos if { $breakpoint_always_inserted == "on" } { 68 1.1.1.3 christos gdb_test "b *0" "Breakpoint $decimal at 0x0.*" 69 1.1.1.3 christos } else { 70 1.1.1.3 christos gdb_test "b *0" "Breakpoint $decimal at 0x0" 71 1.1.1.3 christos } 72 1.1 christos 73 1.1 christos gdb_test "continue" \ 74 1.1 christos "Command aborted\\." \ 75 1.1 christos "continue aborts" 76 1.1 christos 77 1.1 christos # Delete the "bad" breakpoint and try continuing again. 78 1.1 christos delete_breakpoints 79 1.1 christos gdb_test "b function" "Breakpoint $decimal .*$srcfile.*" 80 1.1 christos 81 1.1 christos gdb_test "continue" \ 82 1.1 christos "Breakpoint $decimal, function \\(\\) at .*$srcfile:.*" \ 83 1.1 christos "continue to function" 84 1.1 christos } 85 1.1 christos 86 1.1 christos # This testcase exercises a regression with the in-line step-over 87 1.1 christos # machinery. So make sure this runs with displaced stepping disabled, 88 1.1 christos # and for good measure, also try with displaced stepping enabled. 89 1.1 christos foreach_with_prefix displaced-stepping {"off" "on"} { 90 1.1.1.3 christos foreach_with_prefix breakpoint-always-inserted {"off" "on"} { 91 1.1.1.3 christos do_test ${displaced-stepping} ${breakpoint-always-inserted} 92 1.1.1.3 christos } 93 1.1 christos } 94