]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / fission-multi-cu.exp
1 # Copyright 2012-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 # This test checks that GDB can load DWARF information from two
17 # separate split .DWO files.
18
19 load_lib dwarf.exp
20
21 # We run objcopy locally to split out the .dwo file.
22 require {!is_remote host}
23
24 # This test can only be run on targets which support DWARF-2 and use gas.
25 require dwarf2_support
26
27 # We place the entire source code for the test into a single .c file,
28 # but we generate the DWARF in two separate .S files. Each .S is
29 # compiled to a .o, then the DWARF is split into a .dwo file. Finally
30 # the all three .o files are merged into a single executable that will
31 # reference the two .dwo files.
32 standard_testfile .c -1-dw.S -2-cw.S
33
34 # Generate the first .S file.
35 set asm_file_1 [standard_output_file $srcfile2]
36 Dwarf::assemble $asm_file_1 {
37 global srcfile binfile objdir srcdir subdir
38
39 get_func_info func
40
41 declare_labels int4_type lines_table
42
43 set debug_addr_lbl ".unknown!!"
44
45 # The information that will be split out into the .dwo file.
46 cu {fission 1} {
47
48 # Capture a label to the current start of the .debug_addr
49 # section. This will be passed to DW_AT_GNU_addr_base in the
50 # non-split CU later.
51 set debug_addr_lbl [debug_addr_label]
52
53 compile_unit {
54 {language @DW_LANG_C}
55 {name ${srcfile}}
56 {DW_AT_comp_dir ${objdir}}
57 {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
58 } {
59 int4_type: DW_TAG_base_type {
60 {DW_AT_byte_size 4 DW_FORM_sdata}
61 {DW_AT_encoding @DW_ATE_signed}
62 {DW_AT_name int}
63 }
64
65 subprogram {
66 {external 1 flag}
67 {DW_AT_name func DW_FORM_string}
68 {MACRO_AT_func {func}}
69 {DW_AT_type :$int4_type}
70 } {
71 DW_TAG_formal_parameter {
72 {DW_AT_name arg}
73 {DW_AT_type :$int4_type}
74 {DW_AT_location {
75 DW_OP_GNU_addr_index [gdb_target_symbol global_param]
76 } SPECIAL_expr}
77 }
78 }
79 }
80 }
81
82 lines {version 2} lines_table {
83 include_dir "${srcdir}/${subdir}"
84 file_name "$srcfile" 1
85
86 program {
87 DW_LNE_set_address $func_start
88 DW_LNS_advance_line 24
89 DW_LNS_copy
90
91 DW_LNE_set_address line_label_4
92 DW_LNS_advance_line 3
93 DW_LNS_copy
94
95 DW_LNE_set_address $func_end
96 DW_LNS_advance_line 1
97 DW_LNS_copy
98 DW_LNE_end_sequence
99 }
100 }
101
102 # The information that will remain in the .o file.
103 cu {} {
104 compile_unit {
105 {DW_AT_GNU_dwo_name ${binfile}-1-dw.dwo DW_FORM_strp}
106 {DW_AT_comp_dir ${objdir}}
107 {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
108 {DW_AT_GNU_addr_base $debug_addr_lbl}
109 {stmt_list $lines_table DW_FORM_sec_offset}
110 } {
111 # Nothing.
112 }
113 }
114 }
115
116 # Generate the second .S file.
117 set asm_file_2 [standard_output_file $srcfile3]
118 Dwarf::assemble $asm_file_2 {
119 global srcfile binfile objdir srcdir subdir
120
121 set debug_addr_lbl ".unknown!!"
122
123 declare_labels int4_type lines_table
124
125 get_func_info main
126
127 # The information that will be split out into the .dwo file.
128 cu {fission 1} {
129
130 # Capture a label to the current start of the .debug_addr
131 # section. This will be passed to DW_AT_GNU_addr_base in the
132 # non-split CU later.
133 set debug_addr_lbl [debug_addr_label]
134
135 compile_unit {
136 {language @DW_LANG_C}
137 {name ${srcfile}}
138 {DW_AT_comp_dir ${objdir}}
139 {DW_AT_GNU_dwo_id 0x4567 DW_FORM_data8}
140 } {
141 int4_type: DW_TAG_base_type {
142 {DW_AT_byte_size 4 DW_FORM_sdata}
143 {DW_AT_encoding @DW_ATE_signed}
144 {DW_AT_name int}
145 }
146
147 subprogram {
148 {external 1 flag}
149 {DW_AT_name main DW_FORM_string}
150 {MACRO_AT_func {main}}
151 {DW_AT_type :$int4_type}
152 {DW_AT_decl_file 1 data1}
153 {DW_AT_decl_line 29 data1}
154 }
155 }
156 }
157
158 lines {version 2} lines_table {
159 include_dir "${srcdir}/${subdir}"
160 file_name "$srcfile" 1
161
162 program {
163 DW_LNE_set_address $main_start
164 DW_LNS_advance_line 32
165 DW_LNS_copy
166
167 DW_LNE_set_address line_label_1
168 DW_LNS_advance_line 3
169 DW_LNS_copy
170
171 DW_LNE_set_address line_label_2
172 DW_LNS_advance_line 2
173 DW_LNS_copy
174
175 DW_LNE_set_address line_label_3
176 DW_LNS_advance_line 2
177 DW_LNS_copy
178
179 DW_LNE_set_address $main_end
180 DW_LNS_advance_line 2
181 DW_LNS_copy
182 DW_LNE_end_sequence
183 }
184 }
185
186 # The information that will remain in the .o file.
187 cu {} {
188 compile_unit {
189 {DW_AT_GNU_dwo_name ${binfile}-2-dw.dwo DW_FORM_strp}
190 {DW_AT_comp_dir ${objdir}}
191 {DW_AT_GNU_dwo_id 0x4567 DW_FORM_data8}
192 {DW_AT_GNU_addr_base $debug_addr_lbl}
193 {stmt_list $lines_table DW_FORM_sec_offset}
194 } {
195 # Nothing.
196 }
197 }
198 }
199
200 # Compile all of the input files, split the DWARF into the .dwo files.
201 set obj1 [standard_output_file "${testfile}-1-dw.o"]
202 set obj2 [standard_output_file "${testfile}-2-dw.o"]
203 if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" {nodebug} \
204 [list $asm_file_1 [list nodebug split-dwo] $obj1] \
205 [list $asm_file_2 [list nodebug split-dwo] $obj2] \
206 [list $srcfile [list nodebug]]] {
207 return -1
208 }
209
210 clean_restart $binfile
211
212 if ![runto_main] {
213 return -1
214 }
215
216 # Do a few basic things to verify we're finding the DWO debug info.
217
218 gdb_test "ptype main" "type = int \\(\\)"
219 gdb_test "ptype func" "type = int \\(int\\)"
220
221 gdb_test "frame" "#0 *main \\(\\) at \[^\r\n\]+${srcfile}:$decimal.*" \
222 "frame in main"
223
224 gdb_test "break func" "Breakpoint.*at.* file .*${srcfile}, line .*"
225
226 gdb_test "continue" "Breakpoint.* func \\(arg=-1\\).*" \
227 "continue to func"
228
229 gdb_test "frame" "#0 *func \\(arg=-1\\) at \[^\r\n\]+${srcfile}:$decimal.*" \
230 "frame in func"