acda961380d7fc8a8ce8a2a013cb1614dd3db3cc
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / ppc64-isa207-atomic-inst.exp
1 # Copyright 2017-2021 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 if {![istarget "powerpc*"] || ![is_lp64_target]} {
25 untested "skipping powerpc isa 207 atomic sequences test"
26 return
27 }
28
29 standard_testfile .c .S
30
31 if { [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \
32 {debug quiet}] } {
33 return -1
34 }
35
36 # The test proper. DISPLACED is true if we should try with displaced
37 # stepping.
38
39 proc do_test { displaced } {
40 global decimal hex
41 global gdb_prompt inferior_exited_re srcfile srcfile2
42
43 if ![runto_main] then {
44 untested "could not run to main"
45 return -1
46 }
47
48 gdb_test_no_output "set displaced-stepping $displaced"
49
50 gdb_breakpoint "test_atomic_sequences" "Breakpoint $decimal at $hex" \
51 "set the breakpoint at the start of the test function"
52
53 gdb_test_multiple "continue" "Continue until lbarx/stbcx start breakpoint" {
54 -re "$inferior_exited_re with code 01.\[\r\n\]+$gdb_prompt $" {
55 unsupported "POWER8/ISA 2.07 atomic instructions not supported."
56 return -1
57 }
58 -re "Continuing.*Breakpoint $decimal.*$gdb_prompt $" {
59 pass "continue until test_atomic_sequences function"
60 }
61 }
62
63 set bp1 [gdb_get_line_number "lbarx" "$srcfile2"]
64 gdb_breakpoint "$bp1" "Breakpoint $decimal at $hex" \
65 "set the breakpoint at the start of the lbarx/stbcx sequence"
66
67 set bp2 [gdb_get_line_number "lharx" "$srcfile2"]
68 gdb_breakpoint "$bp2" "Breakpoint $decimal at $hex" \
69 "set the breakpoint at the start of the lharx/sthcx sequence"
70
71 set bp3 [gdb_get_line_number "lqarx" "$srcfile2"]
72 gdb_breakpoint "$bp3" "Breakpoint $decimal at $hex" \
73 "set the breakpoint at the start of the lqarx/stqcx sequence"
74
75 gdb_test continue "Continuing.*Breakpoint $decimal.*" \
76 "continue until lbarx/stbcx start breakpoint"
77
78 gdb_test nexti "bne.*1b" \
79 "step through the lbarx/stbcx sequence"
80
81 gdb_test continue "Continuing.*Breakpoint $decimal.*" \
82 "continue until lharx/sthcx start breakpoint"
83
84 gdb_test nexti "bne.*2b" \
85 "step through the lharx/sthcx sequence"
86
87 gdb_test continue "Continuing.*Breakpoint $decimal.*" \
88 "continue until ldqrx/stqcx start breakpoint"
89
90 gdb_test nexti "bne.*3b" \
91 "step through the lqarx/stqcx sequence"
92 }
93
94 foreach displaced { "off" "on" } {
95 with_test_prefix "displaced=$displaced" {
96 do_test $displaced
97 }
98 }
This page took 0.033977 seconds and 3 git commands to generate.