1 # Copyright 2017-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the gdb testsuite.
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).
24 require {istarget "powerpc*"} is_lp64_target
26 standard_testfile .c .S
28 if { [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \
33 # The test proper. DISPLACED is true if we should try with displaced
36 proc do_test { displaced } {
38 global gdb_prompt inferior_exited_re srcfile srcfile2
44 gdb_test_no_output "set displaced-stepping $displaced"
46 gdb_breakpoint "test_atomic_sequences" "Breakpoint $decimal at $hex" \
47 "set the breakpoint at the start of the test function"
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."
54 -re "Continuing.*Breakpoint $decimal.*$gdb_prompt $" {
55 pass "continue until test_atomic_sequences function"
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"
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"
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"
71 gdb_test continue "Continuing.*Breakpoint $decimal.*" \
72 "continue until lbarx/stbcx start breakpoint"
74 gdb_test nexti "bne.*1b" \
75 "step through the lbarx/stbcx sequence"
77 gdb_test continue "Continuing.*Breakpoint $decimal.*" \
78 "continue until lharx/sthcx start breakpoint"
80 gdb_test nexti "bne.*2b" \
81 "step through the lharx/sthcx sequence"
83 gdb_test continue "Continuing.*Breakpoint $decimal.*" \
84 "continue until ldqrx/stqcx start breakpoint"
86 gdb_test nexti "bne.*3b" \
87 "step through the lqarx/stqcx sequence"
90 foreach displaced { "off" "on" } {
91 with_test_prefix "displaced=$displaced" {