1 # Copyright 2017-2024 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 # This file is part of the gdb testsuite. 17 18 # Test single stepping through POWER8/ISA 2.07 atomic sequences beginning with 19 # a lbarx/lharx/lqarx instruction and ending with a stbcx/sthcx/stqxc 20 # instruction. Note that although lbarx, lharx, stbcx and sthcx instructions 21 # were introduced in ISA 2.06, they were implemented only in POWER8 (ISA 2.07). 22 23 24 require {istarget "powerpc*"} is_lp64_target 25 26 standard_testfile .c .S 27 28 if { [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \ 29 {debug quiet}] } { 30 return -1 31 } 32 33 # The test proper. DISPLACED is true if we should try with displaced 34 # stepping. 35 36 proc do_test { displaced } { 37 global decimal hex 38 global gdb_prompt inferior_exited_re srcfile srcfile2 39 40 if {![runto_main]} { 41 return -1 42 } 43 44 gdb_test_no_output "set displaced-stepping $displaced" 45 46 gdb_breakpoint "test_atomic_sequences" "Breakpoint $decimal at $hex" \ 47 "set the breakpoint at the start of the test function" 48 49 gdb_test_multiple "continue" "Continue until lbarx/stbcx start breakpoint" { 50 -re "$inferior_exited_re with code 01.\[\r\n\]+$gdb_prompt $" { 51 unsupported "POWER8/ISA 2.07 atomic instructions not supported." 52 return -1 53 } 54 -re "Continuing.*Breakpoint $decimal.*$gdb_prompt $" { 55 pass "continue until test_atomic_sequences function" 56 } 57 } 58 59 set bp1 [gdb_get_line_number "lbarx" "$srcfile2"] 60 gdb_breakpoint "$bp1" "Breakpoint $decimal at $hex" \ 61 "set the breakpoint at the start of the lbarx/stbcx sequence" 62 63 set bp2 [gdb_get_line_number "lharx" "$srcfile2"] 64 gdb_breakpoint "$bp2" "Breakpoint $decimal at $hex" \ 65 "set the breakpoint at the start of the lharx/sthcx sequence" 66 67 set bp3 [gdb_get_line_number "lqarx" "$srcfile2"] 68 gdb_breakpoint "$bp3" "Breakpoint $decimal at $hex" \ 69 "set the breakpoint at the start of the lqarx/stqcx sequence" 70 71 gdb_test continue "Continuing.*Breakpoint $decimal.*" \ 72 "continue until lbarx/stbcx start breakpoint" 73 74 gdb_test nexti "bne.*1b" \ 75 "step through the lbarx/stbcx sequence" 76 77 gdb_test continue "Continuing.*Breakpoint $decimal.*" \ 78 "continue until lharx/sthcx start breakpoint" 79 80 gdb_test nexti "bne.*2b" \ 81 "step through the lharx/sthcx sequence" 82 83 gdb_test continue "Continuing.*Breakpoint $decimal.*" \ 84 "continue until ldqrx/stqcx start breakpoint" 85 86 gdb_test nexti "bne.*3b" \ 87 "step through the lqarx/stqcx sequence" 88 } 89 90 foreach displaced { "off" "on" } { 91 with_test_prefix "displaced=$displaced" { 92 do_test $displaced 93 } 94 } 95