1 # Copyright 2017-2023 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 # Test the symbol needs check mechanism if it assumes that faking
17 # reads from a target is a safe thing to do.
19 # In particular, the test uses a relative branch DWARF operation to
20 # potentially cause an infinite loop, if the target reads are indeed
25 # This test can only be run on targets which support DWARF-2 and use gas.
26 if {![dwarf2_support]} {
30 # Choose suitable integer registers for the test.
34 if { [is_aarch64_target] } {
36 } elseif { [is_aarch32_target]
37 || [istarget "s390*-*-*" ]
38 || [istarget "powerpc*-*-*"]
39 || [istarget "rs6000*-*-aix*"] } {
41 } elseif { [is_x86_like_target] } {
43 } elseif { [is_amd64_regs_target] } {
46 verbose "Skipping ${gdb_test_file_name}."
50 standard_testfile symbol_needs_eval.c ${gdb_test_file_name}-dw.S
52 # Make some DWARF for the test.
54 set asm_file [standard_output_file $srcfile2]
55 Dwarf::assemble $asm_file {
56 global dwarf_regnum regname
58 set exec_mask_var [gdb_target_symbol exec_mask]
62 {DW_AT_name symbol_needs_eval.c}
65 declare_labels int_type_label
68 int_type_label: DW_TAG_base_type {
70 {DW_AT_encoding @DW_ATE_signed}
71 {DW_AT_byte_size 4 DW_FORM_sdata}
74 # add info for variable exec_mask
76 {DW_AT_name exec_mask}
77 {DW_AT_type :$int_type_label}
79 DW_OP_addr $exec_mask_var
84 # add info for subprogram main
86 {MACRO_AT_func { main }}
88 DW_OP_regx $dwarf_regnum
91 # define artificial variable a
94 {DW_AT_type :$int_type_label}
97 DW_OP_addr $exec_mask_var
100 # jump to DW_OP_fbreg
108 # conditional jump to DW_OP_drop
119 if { [prepare_for_testing ${testfile}.exp ${testfile} \
120 [list $srcfile $asm_file] {nodebug}] } {
128 gdb_test_no_output "set var \$$regname = 2" "init reg to 2"
129 gdb_test_no_output "set var exec_mask = 0" "init exec_mask to 0"
131 gdb_test "print/d a" " = 2" "a == 2"