Automatic date update in version.in
[binutils-gdb.git] / gdb / testsuite / gdb.trace / unavailable-dwarf-piece.exp
blobce0165c3d1028d4c240b594d3eacd0256cdf1f5b
1 # Copyright (C) 2013-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 load_lib "trace-support.exp"
17 load_lib dwarf.exp
19 require dwarf2_support
21 standard_testfile .c -dbg.S
23 set asm_file [standard_output_file $srcfile2]
24 set opts {}
26 if  { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
27            object {nodebug}] != "" } {
28     return -1
31 Dwarf::assemble $asm_file {
32     declare_labels uchar_label struct_s_label foo_label struct_t_label bar_label
34     cu {} {
35         compile_unit {{language @DW_LANG_C}} {
36             uchar_label: DW_TAG_base_type {
37                 {name "unsigned char"}
38                 {byte_size 1 DW_FORM_sdata}
39                 {encoding @DW_ATE_unsigned_char}
40             }
42             struct_s_label: DW_TAG_structure_type {
43                 {name s}
44                 {byte_size 3 DW_FORM_sdata}
45                 {decl_file 0 DW_FORM_udata}
46                 {decl_line 1 DW_FORM_udata}
47             } {
48                 DW_TAG_member {
49                     {name a}
50                     {type :$uchar_label}
51                     {data_member_location {
52                         DW_OP_plus_uconst 0
53                     } SPECIAL_expr}
54                 }
55                 DW_TAG_member {
56                     {name b}
57                     {type :$uchar_label}
58                     {data_member_location {
59                         DW_OP_plus_uconst 1
60                     } SPECIAL_expr}
61                 }
62                 DW_TAG_member {
63                     {name c}
64                     {type :$uchar_label}
65                     {data_member_location {
66                         DW_OP_plus_uconst 2
67                     } SPECIAL_expr}
68                 }
69             }
71             struct_t_label: DW_TAG_structure_type {
72                 {name t}
73                 {byte_size 3 DW_FORM_sdata}
74                 {decl_file 0 DW_FORM_udata}
75                 {decl_line 1 DW_FORM_udata}
76             } {
77                 DW_TAG_member {
78                     {name a}
79                     {type :$uchar_label}
80                     {data_member_location {
81                         DW_OP_plus_uconst 0
82                     } SPECIAL_expr}
83                 }
84                 DW_TAG_member {
85                     {name b}
86                     {type :$uchar_label}
87                     {byte_size 1 DW_FORM_sdata}
88                     {bit_size 1 DW_FORM_sdata}
89                     {bit_offset 7 DW_FORM_sdata}
90                     {data_member_location {
91                         DW_OP_plus_uconst 1
92                     } SPECIAL_expr}
93                 }
94                 DW_TAG_member {
95                     {name c}
96                     {type :$uchar_label}
97                     {byte_size 1 DW_FORM_sdata}
98                     {bit_size 1 DW_FORM_sdata}
99                     {bit_offset 6 DW_FORM_sdata}
100                     {data_member_location {
101                         DW_OP_plus_uconst 1
102                     } SPECIAL_expr}
103                 }
104                 DW_TAG_member {
105                     {name d}
106                     {type :$uchar_label}
107                     {byte_size 1 DW_FORM_sdata}
108                     {bit_size 1 DW_FORM_sdata}
109                     {bit_offset 5 DW_FORM_sdata}
110                     {data_member_location {
111                         DW_OP_plus_uconst 1
112                     } SPECIAL_expr}
113                 }
114                 DW_TAG_member {
115                     {name e}
116                     {type :$uchar_label}
117                     {byte_size 1 DW_FORM_sdata}
118                     {bit_size 1 DW_FORM_sdata}
119                     {bit_offset 4 DW_FORM_sdata}
120                     {data_member_location {
121                         DW_OP_plus_uconst 1
122                     } SPECIAL_expr}
123                 }
124                 DW_TAG_member {
125                     {name f}
126                     {type :$uchar_label}
127                     {byte_size 1 DW_FORM_sdata}
128                     {bit_size 1 DW_FORM_sdata}
129                     {bit_offset 3 DW_FORM_sdata}
130                     {data_member_location {
131                         DW_OP_plus_uconst 1
132                     } SPECIAL_expr}
133                 }
134                 DW_TAG_member {
135                     {name g}
136                     {type :$uchar_label}
137                     {byte_size 1 DW_FORM_sdata}
138                     {bit_size 1 DW_FORM_sdata}
139                     {bit_offset 2 DW_FORM_sdata}
140                     {data_member_location {
141                         DW_OP_plus_uconst 1
142                     } SPECIAL_expr}
143                 }
144                 DW_TAG_member {
145                     {name h}
146                     {type :$uchar_label}
147                     {byte_size 1 DW_FORM_sdata}
148                     {bit_size 1 DW_FORM_sdata}
149                     {bit_offset 1 DW_FORM_sdata}
150                     {data_member_location {
151                         DW_OP_plus_uconst 1
152                     } SPECIAL_expr}
153                 }
154                 DW_TAG_member {
155                     {name i}
156                     {type :$uchar_label}
157                     {byte_size 1 DW_FORM_sdata}
158                     {bit_size 1 DW_FORM_sdata}
159                     {bit_offset 0 DW_FORM_sdata}
160                     {data_member_location {
161                         DW_OP_plus_uconst 1
162                     } SPECIAL_expr}
163                 }
164                 DW_TAG_member {
165                     {name j}
166                     {type :$uchar_label}
167                     {data_member_location {
168                         DW_OP_plus_uconst 2
169                     } SPECIAL_expr}
170                 }
171             }
173             DW_TAG_subprogram {
174                 {name foo}
175                 {decl_file 0 udata}
176                 {low_pc foo_start_lbl addr}
177                 {high_pc foo_end_lbl addr}
178             } {
179                 DW_TAG_formal_parameter {
180                     {type :$struct_s_label}
181                     {name x}
182                     {location {
183                         DW_OP_lit0
184                         DW_OP_stack_value
185                         DW_OP_piece 2
186                         DW_OP_reg0
187                         DW_OP_piece 1
188                     } SPECIAL_expr}
189                 }
190                 DW_TAG_formal_parameter {
191                     {type :$struct_s_label}
192                     {name y}
193                     {location {
194                         DW_OP_lit0
195                         DW_OP_stack_value
196                         DW_OP_piece 1
197                         DW_OP_reg0
198                         DW_OP_piece 1
199                         DW_OP_lit0
200                         DW_OP_stack_value
201                         DW_OP_piece 1
202                     } SPECIAL_expr}
203                 }
204                 DW_TAG_formal_parameter {
205                     {type :$struct_s_label}
206                     {name z}
207                     {location {
208                         DW_OP_reg0
209                         DW_OP_piece 1
210                         DW_OP_lit0
211                         DW_OP_stack_value
212                         DW_OP_piece 2
213                     } SPECIAL_expr}
214                 }
215             }
218             DW_TAG_subprogram {
219                 {name bar}
220                 {decl_file 0 udata}
221                 {low_pc bar_start_lbl addr}
222                 {high_pc bar_end_lbl addr}
223             } {
224                 DW_TAG_formal_parameter {
225                     {type :$struct_t_label}
226                     {name x}
227                     {location {
228                         DW_OP_lit0
229                         DW_OP_stack_value
230                         DW_OP_piece 1
231                         DW_OP_reg0
232                         DW_OP_bit_piece 1 0
233                         DW_OP_lit0
234                         DW_OP_stack_value
235                         DW_OP_bit_piece 7 0
236                         DW_OP_lit0
237                         DW_OP_stack_value
238                         DW_OP_piece 1
239                     } SPECIAL_expr}
240                 }
241                 DW_TAG_formal_parameter {
242                     {type :$struct_t_label}
243                     {name y}
244                     {location {
245                         DW_OP_lit0
246                         DW_OP_stack_value
247                         DW_OP_piece 1
248                         DW_OP_lit0
249                         DW_OP_stack_value
250                         DW_OP_bit_piece 3 0
251                         DW_OP_reg0
252                         DW_OP_bit_piece 1 0
253                         DW_OP_lit0
254                         DW_OP_stack_value
255                         DW_OP_bit_piece 4 0
256                         DW_OP_lit0
257                         DW_OP_stack_value
258                         DW_OP_piece 1
259                     } SPECIAL_expr}
260                 }
261                 DW_TAG_formal_parameter {
262                     {type :$struct_t_label}
263                     {name z}
264                     {location {
265                         DW_OP_lit0
266                         DW_OP_stack_value
267                         DW_OP_piece 1
268                         DW_OP_lit0
269                         DW_OP_stack_value
270                         DW_OP_bit_piece 7 0
271                         DW_OP_reg0
272                         DW_OP_bit_piece 1 0
273                         DW_OP_lit0
274                         DW_OP_stack_value
275                         DW_OP_piece 1
276                     } SPECIAL_expr}
277                 }
278             }
280         }
281     }
284 if  { [gdb_compile ${asm_file} ${binfile}2.o object {nodebug}] != "" } {
285     return -1
288 if  { [gdb_compile [list ${binfile}1.o ${binfile}2.o] ${binfile} \
289            executable {}] != "" } {
290     return -1
293 clean_restart ${testfile}
295 if ![runto_main] {
296     return -1
299 if ![gdb_target_supports_trace] {
300     unsupported "target does not support trace"
301     return -1
304 gdb_breakpoint "end" qualified
306 with_test_prefix "tracing foo" {
307     gdb_test "trace *foo_start_lbl" ".*"
308     gdb_test_no_output "tstart"
309     gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
310     gdb_test_no_output "tstop"
312     gdb_test "tfind 0" "Found trace frame 0, tracepoint .*"
313     gdb_test "p/d x" "\\\$${decimal} = {a = 0, b = 0, c = <unavailable>}"
314     gdb_test "p/d y" "\\\$${decimal} = {a = 0, b = <unavailable>, c = 0}"
315     gdb_test "p/d z" "\\\$${decimal} = {a = <unavailable>, b = 0, c = 0}"
317     gdb_test "tfind none" "No longer looking at any trace frame.*"
320 with_test_prefix "tracing bar" {
321     gdb_test "trace *bar_start_lbl" ".*"
322     gdb_test_no_output "tstart"
323     gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
324     gdb_test_no_output "tstop"
326     set endian [get_endianness]
328     gdb_test "tfind 0" "Found trace frame 0, tracepoint .*"
329     if { $endian == "little" } {
330         gdb_test "p/d x" "\\\$${decimal} = {a = 0, b = <unavailable>, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0}"
331         gdb_test "p/d y" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = <unavailable>, f = 0, g = 0, h = 0, i = 0, j = 0}"
332         gdb_test "p/d z" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = <unavailable>, j = 0}"
333     } else {
334         gdb_test "p/d x" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = <unavailable>, j = 0}"
335         gdb_test "p/d y" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = <unavailable>, g = 0, h = 0, i = 0, j = 0}"
336         gdb_test "p/d z" "\\\$${decimal} = {a = 0, b = <unavailable>, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0}"
337     }
339     gdb_test "tfind none" "No longer looking at any trace frame.*"