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