1# Copyright 2020-2024 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/>. 15load_lib dwarf.exp 16 17# This test can only be run on targets which support DWARF-2 and use gas. 18require dwarf2_support 19 20standard_testfile main-foo.c .S 21 22# Make some DWARF for the test. 23set asm_file [standard_output_file $srcfile2] 24Dwarf::assemble $asm_file { 25 cu {} { 26 compile_unit { 27 {DW_AT_language @DW_LANG_C} 28 {DW_AT_name main.c} 29 } { 30 structure_type { 31 {name s} 32 {signature 0x0000000000000001 ref_sig8} 33 {declaration 1 flag} 34 } 35 DW_TAG_subprogram { 36 {MACRO_AT_func {main}} 37 } 38 } 39 } 40 41 cu {} { 42 compile_unit { 43 {DW_AT_language @DW_LANG_C} 44 {DW_AT_name foo.c} 45 } { 46 structure_type { 47 {name s} 48 {signature 0x0000000000000002 ref_sig8} 49 {declaration 1 flag} 50 } 51 DW_TAG_subprogram { 52 {MACRO_AT_func {foo}} 53 } 54 } 55 } 56 57 tu {} 0x0000000000000001 the_type_i { 58 type_unit {} { 59 declare_labels int_type 60 61 the_type_i: structure_type { 62 {name s} 63 {byte_size 4 sdata} 64 } { 65 member { 66 {name i} 67 {type :$int_type} 68 } 69 } 70 int_type: base_type { 71 {name int} 72 {encoding @DW_ATE_signed} 73 {byte_size 4 sdata} 74 } 75 } 76 } 77 78 tu {} 0x0000000000000002 the_type_j { 79 type_unit {} { 80 declare_labels int_type 81 82 the_type_j: structure_type { 83 {name s} 84 {byte_size 4 sdata} 85 } { 86 member { 87 {name j} 88 {type :$int_type} 89 } 90 } 91 int_type: base_type { 92 {name int} 93 {encoding @DW_ATE_signed} 94 {byte_size 4 sdata} 95 } 96 } 97 } 98} 99 100if { [prepare_for_testing "failed to prepare" ${testfile} \ 101 [list $srcfile $asm_file] {nodebug}] } { 102 return -1 103} 104 105set struct_s_i_re \ 106 [multi_line \ 107 "type = struct s {" \ 108 " int i;" \ 109 "}"] 110set struct_s_j_re \ 111 [multi_line \ 112 "type = struct s {" \ 113 " int j;" \ 114 "}"] 115 116if ![runto_main] { 117 return -1 118} 119 120gdb_test "ptype struct s" $struct_s_i_re \ 121 "struct s with int i" 122 123gdb_breakpoint "foo" 124gdb_continue_to_breakpoint "foo" 125 126gdb_test "ptype struct s" $struct_s_j_re \ 127 "struct s with int j" 128