llvm.org GIT mirror llvm / 3887a90
Add support for some missing DW_FORM_*. TODO: Fix code duplication and coding style. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162525 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 7 years ago
2 changed file(s) with 77 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
125125 switch (form) {
126126 // Blocks if inlined data that have a length field and the data bytes
127127 // inlined in the .debug_info.
128 case DW_FORM_exprloc:
128129 case DW_FORM_block:
129130 form_size = debug_info_data.getULEB128(&offset);
130131 break;
147148 case DW_FORM_addr:
148149 case DW_FORM_ref_addr:
149150 form_size = cu->getAddressByteSize();
151 break;
152
153 // 0 sized form.
154 case DW_FORM_flag_present:
155 form_size = 0;
150156 break;
151157
152158 // 1 byte values
172178 // 8 byte values
173179 case DW_FORM_data8:
174180 case DW_FORM_ref8:
181 case DW_FORM_ref_sig8:
175182 form_size = 8;
176183 break;
177184
185192 case DW_FORM_indirect:
186193 form_is_indirect = true;
187194 form = debug_info_data.getULEB128(&offset);
195 break;
196
197 case DW_FORM_sec_offset:
198 if (cu->getAddressByteSize() == 4)
199 debug_info_data.getU32(offset_ptr);
200 else
201 debug_info_data.getU64(offset_ptr);
188202 break;
189203
190204 default:
248262 switch (form) {
249263 // Blocks if inlined data that have a length field and the data
250264 // bytes // inlined in the .debug_info
265 case DW_FORM_exprloc:
251266 case DW_FORM_block:
252267 form_size = debug_info_data.getULEB128(&offset);
253268 break;
270285 case DW_FORM_addr:
271286 case DW_FORM_ref_addr:
272287 form_size = cu_addr_size;
288 break;
289
290 // 0 byte value
291 case DW_FORM_flag_present:
292 form_size = 0;
273293 break;
274294
275295 // 1 byte values
298318 // 8 byte values
299319 case DW_FORM_data8:
300320 case DW_FORM_ref8:
321 case DW_FORM_ref_sig8:
301322 form_size = 8;
302323 break;
303324
313334 form_is_indirect = true;
314335 break;
315336
337 case DW_FORM_sec_offset:
338 if (cu->getAddressByteSize() == 4)
339 debug_info_data.getU32(offset_ptr);
340 else
341 debug_info_data.getU64(offset_ptr);
342 break;
343
316344 default:
317345 *offset_ptr = offset;
318346 return false;
4040 8, // 0x14 DW_FORM_ref8
4141 0, // 0x15 DW_FORM_ref_udata
4242 0, // 0x16 DW_FORM_indirect
43 4, // 0x17 DW_FORM_sec_offset
44 0, // 0x18 DW_FORM_exprloc
45 0, // 0x19 DW_FORM_flag_present
46 8, // 0x20 DW_FORM_ref_sig8
4347 };
4448
4549 static const uint8_t form_sizes_addr8[] = {
6670 8, // 0x14 DW_FORM_ref8
6771 0, // 0x15 DW_FORM_ref_udata
6872 0, // 0x16 DW_FORM_indirect
73 8, // 0x17 DW_FORM_sec_offset
74 0, // 0x18 DW_FORM_exprloc
75 0, // 0x19 DW_FORM_flag_present
76 8, // 0x20 DW_FORM_ref_sig8
6977 };
7078
7179 const uint8_t *
92100 case DW_FORM_ref_addr:
93101 Value.uval = data.getUnsigned(offset_ptr, cu->getAddressByteSize());
94102 break;
103 case DW_FORM_exprloc:
95104 case DW_FORM_block:
96105 Value.uval = data.getULEB128(offset_ptr);
97106 is_block = true;
145154 case DW_FORM_indirect:
146155 Form = data.getULEB128(offset_ptr);
147156 indirect = true;
157 break;
158 case DW_FORM_sec_offset:
159 if (cu->getAddressByteSize() == 4)
160 Value.uval = data.getU32(offset_ptr);
161 else
162 Value.uval = data.getU64(offset_ptr);
163 break;
164 case DW_FORM_flag_present:
165 Value.uval = 1;
166 break;
167 case DW_FORM_ref_sig8:
168 Value.uval = data.getU64(offset_ptr);
148169 break;
149170 default:
150171 return false;
178199 switch (form) {
179200 // Blocks if inlined data that have a length field and the data bytes
180201 // inlined in the .debug_info
202 case DW_FORM_exprloc:
181203 case DW_FORM_block: {
182204 uint64_t size = debug_info_data.getULEB128(offset_ptr);
183205 *offset_ptr += size;
210232 *offset_ptr += cu->getAddressByteSize();
211233 return true;
212234
235 // 0 byte values - implied from the form.
236 case DW_FORM_flag_present:
237 return true;
238
213239 // 1 byte values
214240 case DW_FORM_data1:
215241 case DW_FORM_flag:
233259 // 8 byte values
234260 case DW_FORM_data8:
235261 case DW_FORM_ref8:
262 case DW_FORM_ref_sig8:
236263 *offset_ptr += 8;
237264 return true;
238265
248275 indirect = true;
249276 form = debug_info_data.getULEB128(offset_ptr);
250277 break;
278
279 // 4 for DWARF32, 8 for DWARF64.
280 case DW_FORM_sec_offset:
281 if (cu->getAddressByteSize() == 4)
282 *offset_ptr += 4;
283 else
284 *offset_ptr += 8;
285 return true;
286
251287 default:
252288 return false;
253289 }
263299
264300 switch (Form) {
265301 case DW_FORM_addr: OS << format("0x%016" PRIx64, uvalue); break;
302 case DW_FORM_flag_present: OS << "true"; break;
266303 case DW_FORM_flag:
267304 case DW_FORM_data1: OS << format("0x%02x", (uint8_t)uvalue); break;
268305 case DW_FORM_data2: OS << format("0x%04x", (uint16_t)uvalue); break;
269306 case DW_FORM_data4: OS << format("0x%08x", (uint32_t)uvalue); break;
307 case DW_FORM_ref_sig8:
270308 case DW_FORM_data8: OS << format("0x%016" PRIx64, uvalue); break;
271309 case DW_FORM_string:
272310 OS << '"';
273311 OS.write_escaped(getAsCString(NULL));
274312 OS << '"';
275313 break;
314 case DW_FORM_exprloc:
276315 case DW_FORM_block:
277316 case DW_FORM_block1:
278317 case DW_FORM_block2:
279318 case DW_FORM_block4:
280319 if (uvalue > 0) {
281320 switch (Form) {
321 case DW_FORM_exprloc:
282322 case DW_FORM_block: OS << format("<0x%" PRIx64 "> ", uvalue); break;
283323 case DW_FORM_block1: OS << format("<0x%2.2x> ", (uint8_t)uvalue); break;
284324 case DW_FORM_block2: OS << format("<0x%4.4x> ", (uint16_t)uvalue); break;
341381 case DW_FORM_indirect:
342382 OS << "DW_FORM_indirect";
343383 break;
384
385 case DW_FORM_sec_offset:
386 if (cu->getAddressByteSize() == 4)
387 OS << format("0x%08x", (uint32_t)uvalue);
388 else
389 OS << format("0x%016" PRIx64, uvalue);
390 break;
391
344392 default:
345393 OS << format("DW_FORM(0x%4.4x)", Form);
346394 break;
403451
404452 bool DWARFFormValue::isBlockForm(uint16_t form) {
405453 switch (form) {
454 case DW_FORM_exprloc:
406455 case DW_FORM_block:
407456 case DW_FORM_block1:
408457 case DW_FORM_block2: