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/>. 15 16# Variant of struct-with-sig.exp where TUs are in .gnu_debugaltlink file. 17 18load_lib dwarf.exp 19 20# This test can only be run on targets which support DWARF-2 and use gas. 21require dwarf2_support 22 23standard_testfile main-foo.c .S .S 24 25set build_id [string repeat ff 20] 26 27# Make some DWARF for the dwz file. 28set asm_file [standard_output_file $srcfile2] 29Dwarf::assemble $asm_file { 30 build_id $::build_id 31 32 tu {} 0x0000000000000001 the_type_i { 33 type_unit {} { 34 declare_labels int_type 35 36 the_type_i: structure_type { 37 {name s} 38 {byte_size 4 sdata} 39 } { 40 member { 41 {name i} 42 {type :$int_type} 43 } 44 } 45 int_type: base_type { 46 {name int} 47 {encoding @DW_ATE_signed} 48 {byte_size 4 sdata} 49 } 50 } 51 } 52 53 tu {} 0x0000000000000002 the_type_j { 54 type_unit {} { 55 declare_labels int_type 56 57 the_type_j: structure_type { 58 {name s} 59 {byte_size 4 sdata} 60 } { 61 member { 62 {name j} 63 {type :$int_type} 64 } 65 } 66 int_type: base_type { 67 {name int} 68 {encoding @DW_ATE_signed} 69 {byte_size 4 sdata} 70 } 71 } 72 } 73} 74 75# We're using an object instead of executable here to keep cc-with-tweaks.sh 76# from modifying it. It also means we can set the build-id, rather than 77# having to extract it. 78if { [gdb_compile $asm_file $binfile.dwz object {nodebug}] != "" } { 79 return -1 80} 81 82set host_dwz_file [gdb_remote_download host $binfile.dwz] 83 84# Make some DWARF for the executable. 85set asm_file [standard_output_file $srcfile3] 86Dwarf::assemble $asm_file { 87 gnu_debugaltlink $::host_dwz_file $::build_id 88 89 cu {} { 90 compile_unit { 91 {DW_AT_language @DW_LANG_C} 92 {DW_AT_name main.c} 93 } { 94 structure_type { 95 {name s} 96 {signature 0x0000000000000001 ref_sig8} 97 {declaration 1 flag} 98 } 99 DW_TAG_subprogram { 100 {MACRO_AT_func {main}} 101 } 102 } 103 } 104 105 cu {} { 106 compile_unit { 107 {DW_AT_language @DW_LANG_C} 108 {DW_AT_name foo.c} 109 } { 110 structure_type { 111 {name s} 112 {signature 0x0000000000000002 ref_sig8} 113 {declaration 1 flag} 114 } 115 DW_TAG_subprogram { 116 {MACRO_AT_func {foo}} 117 } 118 } 119 } 120} 121 122save_vars { GDBFLAGS } { 123 append GDBFLAGS " -iex \"maint set dwarf synchronous on\"" 124 125 if { [prepare_for_testing "failed to prepare" ${testfile} \ 126 [list $srcfile $asm_file] {nodebug}] } { 127 return -1 128 } 129} 130 131set re "Dwarf Error: .debug_types section not supported in dwz file" 132gdb_assert { [regexp $re $gdb_file_cmd_msg] } "Dwarf Error message" 133