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