]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/arc-decode-insn.exp
gdb/testsuite: remove use of then keyword from gdb.arch/*.exp
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / arc-decode-insn.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 2017-2022 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
19 # These tests provides certain degree of testing for arc_insn functions,
20 # however it is not a comprehensive testsuite that would go through all
21 # possible ARC instructions - instead this particular test is focused on branch
22 # instructions and whether branch targets are evaluated properly. Most of the
23 # non-branch aspects of instruction decoder are used during prologue analysis,
24 # so are indirictly tested there.
25
26 # To maintain separation of test data and test logic, all of the information
27 # about instructions, like if it has delay slot, condition code, branch target
28 # address, is all specified in the test assembly file as a symbols, while this
29 # test case reads those symbols to learn which values are right, then compares
30 # values coming from decoder with those found in symbols. More information
31 # about requirements to actual test cases can be found in corresponding
32 # assembly file of this test case (arc-decode-insn.S).
33
34 if {![istarget "arc*-*-*"]} {
35 verbose "Skipping ARC decoder test."
36 return
37 }
38
39 standard_testfile .S
40
41 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
42 return -1
43 }
44
45 if ![runto_main] {
46 return 0
47 }
48
49 # Helper function that reads properties of instruction from the ELF file via
50 # its symbols and then confirms that decoder output aligns to the expected
51 # values.
52 proc test_branch_insn { test_name } {
53
54 # Make messages for failed cases more clear, by using hex in them.
55 set pc [get_hexadecimal_valueof &${test_name}_start -1]
56
57 # Calculate instruction length, based on ${test_name}_end symbol.
58 set end_pc [get_hexadecimal_valueof &${test_name}_end -1]
59 set length [expr $end_pc - $pc]
60
61 set target_address [get_hexadecimal_valueof &${test_name}_target -1]
62
63 # Figure out if there is a delay slot, using symbol
64 # ${test_name}_has_delay_slot. Note that it should be read via &,
65 # otherwise it would try to print value at the address specified in
66 # ${test_name}_has_delay_slot, while a symbol value itself is required.
67 if { 0 == [get_integer_valueof &${test_name}_has_delay_slot 0] } {
68 set has_delay_slot 0
69 } else {
70 set has_delay_slot 1
71 }
72
73 set cc [get_hexadecimal_valueof &${test_name}_cc 0]
74
75 # Can't use {} to create a list of items, because variables will not be
76 # evaluated inside the {}.
77 gdb_test_sequence "mt print arc arc-instruction $pc" "" [list \
78 "length_with_limm = $length" \
79 "cc = $cc" \
80 "is_control_flow = 1" \
81 "has_delay_slot = $has_delay_slot" \
82 "branch_target = $target_address"]
83 }
84
85 set branch_test_list { }
86
87 # Add items in the same groups as they can be enabled/disabled in assembly
88 # file.
89 lappend branch_test_list \
90 j_c j_blink j_limm j_u6 j_s12 j_d_c j_d_blink j_d_u6
91 lappend branch_test_list \
92 jcc_c jcc_blink jcc_limm jcc_u6 jcc_d_c jcc_d_blink jcc_d_u6 \
93 jcc_eq_s_blink jcc_ne_s_blink
94 lappend branch_test_list \
95 jl_c jl_limm jl_u6 jl_s12 jl_d_c jl_d_u6 jl_d_s12 jl_s_b jl_s_d_b
96 lappend branch_test_list \
97 jlcc_c jlcc_limm jlcc_u6 jlcc_d_c jlcc_d_u6
98 lappend branch_test_list \
99 b_s25 b_d_s25 b_s_s10
100 lappend branch_test_list \
101 bbit0_nt_b_c_s9 bbit0_d_nt_b_c_s9 bbit0_t_b_c_s9 bbit0_d_t_b_c_s9 \
102 bbit0_nt_b_u6_s9 bbit0_d_nt_b_u6_s9 bbit0_t_b_u6_s9 bbit0_d_t_b_u6_s9 \
103 bbit0_nt_b_limm_s9 bbit0_t_b_limm_s9 bbit0_nt_limm_c_s9 bbit0_t_limm_c_s9 \
104 bbit0_nt_limm_u6_s9 bbit0_t_limm_u6_s9 \
105 bbit1_nt_b_c_s9 bbit1_d_nt_b_c_s9 bbit1_t_b_c_s9 bbit1_d_t_b_c_s9 \
106 bbit1_nt_b_u6_s9 bbit1_d_nt_b_u6_s9 bbit1_t_b_u6_s9 bbit1_d_t_b_u6_s9 \
107 bbit1_nt_b_limm_s9 bbit1_t_b_limm_s9 bbit1_nt_limm_c_s9 bbit1_t_limm_c_s9 \
108 bbit1_nt_limm_u6_s9 bbit1_t_limm_u6_s9
109 lappend branch_test_list \
110 bcc_s21 bcc_d_s21 \
111 beq_s_s10 bne_s_s10 bgt_s_s7 bge_s_s7 blt_s_s7 ble_s_s7 bhi_s_s7 bhs_s_s7 \
112 blo_s_s7 bls_s_s7
113 lappend branch_test_list \
114 bi_c bih_c
115 lappend branch_test_list \
116 bl_s25 bl_d_s25 bl_s_s13 \
117 blcc_s21 blcc_d_s21
118 lappend branch_test_list \
119 breq_nt_b_c_s9 breq_d_nt_b_c_s9 breq_t_b_c_s9 breq_d_t_b_c_s9 \
120 breq_nt_b_u6_s9 breq_d_nt_b_u6_s9 breq_t_b_u6_s9 breq_d_t_b_u6_s9 \
121 breq_nt_b_limm_s9 breq_t_b_limm_s9 breq_nt_limm_c_s9 breq_t_limm_c_s9 \
122 breq_nt_limm_u6_s9 breq_t_limm_u6_s9
123 # lappend branch_test_list jli_s_u10
124 lappend branch_test_list leave_s
125 lappend branch_test_list lpcc_u7
126
127 runto start_branch_tests
128 foreach test $branch_test_list {
129 test_branch_insn $test
130 }
131