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