]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 2017-2023 Free Software Foundation, Inc. |
183657ed ZZ |
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 | # Test the symbol needs check mechanism if it assumes that faking | |
17 | # reads from a target is a safe thing to do. | |
18 | # | |
19 | # In particular, the test uses a relative branch DWARF operation to | |
20 | # potentially cause an infinite loop, if the target reads are indeed | |
21 | # faked. | |
22 | ||
23 | load_lib dwarf.exp | |
24 | ||
25 | # This test can only be run on targets which support DWARF-2 and use gas. | |
26 | if {![dwarf2_support]} { | |
27 | return 0 | |
28 | } | |
29 | ||
30 | # Choose suitable integer registers for the test. | |
31 | ||
32 | set dwarf_regnum 0 | |
33 | ||
34 | if { [is_aarch64_target] } { | |
35 | set regname x0 | |
36 | } elseif { [is_aarch32_target] | |
37 | || [istarget "s390*-*-*" ] | |
38 | || [istarget "powerpc*-*-*"] | |
39 | || [istarget "rs6000*-*-aix*"] } { | |
40 | set regname r0 | |
41 | } elseif { [is_x86_like_target] } { | |
42 | set regname eax | |
43 | } elseif { [is_amd64_regs_target] } { | |
44 | set regname rax | |
45 | } else { | |
46 | verbose "Skipping ${gdb_test_file_name}." | |
47 | return | |
48 | } | |
49 | ||
50 | standard_testfile symbol_needs_eval.c ${gdb_test_file_name}-dw.S | |
51 | ||
52 | # Make some DWARF for the test. | |
53 | ||
54 | set asm_file [standard_output_file $srcfile2] | |
55 | Dwarf::assemble $asm_file { | |
56 | global dwarf_regnum regname | |
57 | ||
58 | set exec_mask_var [gdb_target_symbol exec_mask] | |
59 | ||
60 | cu {} { | |
61 | DW_TAG_compile_unit { | |
62 | {DW_AT_name symbol_needs_eval.c} | |
63 | {DW_AT_comp_dir /tmp} | |
64 | } { | |
65 | declare_labels int_type_label | |
66 | ||
67 | # define int type | |
68 | int_type_label: DW_TAG_base_type { | |
69 | {DW_AT_name "int"} | |
70 | {DW_AT_encoding @DW_ATE_signed} | |
71 | {DW_AT_byte_size 4 DW_FORM_sdata} | |
72 | } | |
73 | ||
74 | # add info for variable exec_mask | |
75 | DW_TAG_variable { | |
76 | {DW_AT_name exec_mask} | |
77 | {DW_AT_type :$int_type_label} | |
78 | {DW_AT_location { | |
79 | DW_OP_addr $exec_mask_var | |
80 | } SPECIAL_expr} | |
81 | {external 1 flag} | |
82 | } | |
83 | ||
84 | # add info for subprogram main | |
85 | DW_TAG_subprogram { | |
86 | {MACRO_AT_func { main }} | |
87 | {DW_AT_frame_base { | |
88 | DW_OP_regx $dwarf_regnum | |
89 | } SPECIAL_expr} | |
90 | } { | |
91 | # define artificial variable a | |
92 | DW_TAG_variable { | |
93 | {DW_AT_name a} | |
94 | {DW_AT_type :$int_type_label} | |
95 | {DW_AT_location { | |
96 | DW_OP_lit1 | |
97 | DW_OP_addr $exec_mask_var | |
98 | DW_OP_deref | |
99 | ||
100 | # jump to DW_OP_fbreg | |
101 | DW_OP_skip 4 | |
102 | DW_OP_drop | |
103 | DW_OP_fbreg 0 | |
104 | DW_OP_dup | |
105 | DW_OP_lit0 | |
106 | DW_OP_eq | |
107 | ||
108 | # conditional jump to DW_OP_drop | |
109 | DW_OP_bra -9 | |
110 | DW_OP_stack_value | |
111 | } SPECIAL_expr} | |
112 | {external 1 flag} | |
113 | } | |
114 | } | |
115 | } | |
116 | } | |
117 | } | |
118 | ||
119 | if { [prepare_for_testing ${testfile}.exp ${testfile} \ | |
120 | [list $srcfile $asm_file] {nodebug}] } { | |
121 | return -1 | |
122 | } | |
123 | ||
124 | if ![runto_main] { | |
125 | return -1 | |
126 | } | |
127 | ||
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" | |
130 | ||
131 | gdb_test "print/d a" " = 2" "a == 2" |