21 using namespace dwarf;
24 uint8_t getRefAddrSize(uint8_t AddrSize, uint16_t Version) {
26 return (Version == 2) ? AddrSize : 4;
29 template <u
int8_t AddrSize, u
int8_t RefAddrSize>
31 static const uint8_t sizes[] = {
65 uint8_t RefAddrSize = getRefAddrSize(AddrSize, Version);
66 if (AddrSize == 4 && RefAddrSize == 4)
67 return makeFixedFormSizesArrayRef<4, 4>();
68 if (AddrSize == 4 && RefAddrSize == 8)
69 return makeFixedFormSizesArrayRef<4, 8>();
70 if (AddrSize == 8 && RefAddrSize == 4)
71 return makeFixedFormSizesArrayRef<8, 4>();
72 if (AddrSize == 8 && RefAddrSize == 8)
73 return makeFixedFormSizesArrayRef<8, 8>();
114 if (Form == DW_FORM_ref_sig8)
115 return (FC == FC_Reference);
117 if (Form == DW_FORM_GNU_addr_index)
118 return (FC == FC_Address);
119 if (Form == DW_FORM_GNU_str_index)
120 return (FC == FC_String);
124 if ((Form == DW_FORM_data4 || Form == DW_FORM_data8) &&
125 FC == FC_SectionOffset)
132 bool indirect =
false;
133 bool is_block =
false;
141 case DW_FORM_ref_addr: {
143 (Form == DW_FORM_addr)
148 const std::pair<uint8_t, int64_t> &R = AI->second;
154 case DW_FORM_exprloc:
185 Value.uval += AI->second.second;
199 const std::pair<uint8_t, int64_t> &R = AI->second;
206 case DW_FORM_ref_udata:
212 case DW_FORM_indirect:
216 case DW_FORM_sec_offset: {
221 const std::pair<uint8_t, int64_t> &R = AI->second;
227 case DW_FORM_flag_present:
230 case DW_FORM_ref_sig8:
233 case DW_FORM_GNU_addr_index:
234 case DW_FORM_GNU_str_index:
246 Value.data =
reinterpret_cast<const uint8_t *
>(str.
data());
247 *offset_ptr +=
Value.uval;
262 uint32_t *offset_ptr,
const DWARFUnit *cu) {
263 bool indirect =
false;
268 case DW_FORM_exprloc:
269 case DW_FORM_block: {
270 uint64_t size = debug_info_data.
getULEB128(offset_ptr);
274 case DW_FORM_block1: {
275 uint8_t size = debug_info_data.
getU8(offset_ptr);
279 case DW_FORM_block2: {
280 uint16_t size = debug_info_data.
getU16(offset_ptr);
284 case DW_FORM_block4: {
285 uint32_t size = debug_info_data.
getU32(offset_ptr);
292 debug_info_data.
getCStr(offset_ptr);
299 case DW_FORM_ref_addr:
304 case DW_FORM_flag_present:
330 case DW_FORM_ref_sig8:
338 case DW_FORM_ref_udata:
339 case DW_FORM_GNU_str_index:
340 case DW_FORM_GNU_addr_index:
344 case DW_FORM_indirect:
346 form = debug_info_data.
getULEB128(offset_ptr);
350 case DW_FORM_sec_offset:
365 uint64_t uvalue =
Value.uval;
366 bool cu_relative_offset =
false;
369 case DW_FORM_addr: OS <<
format(
"0x%016" PRIx64, uvalue);
break;
370 case DW_FORM_GNU_addr_index: {
371 OS <<
format(
" indexed (%8.8x) address = ", (uint32_t)uvalue);
374 OS <<
format(
"0x%016" PRIx64, Address);
376 OS <<
"<no .debug_addr section>";
379 case DW_FORM_flag_present: OS <<
"true";
break;
381 case DW_FORM_data1: OS <<
format(
"0x%02x", (uint8_t)uvalue);
break;
382 case DW_FORM_data2: OS <<
format(
"0x%04x", (uint16_t)uvalue);
break;
383 case DW_FORM_data4: OS <<
format(
"0x%08x", (uint32_t)uvalue);
break;
384 case DW_FORM_ref_sig8:
385 case DW_FORM_data8: OS <<
format(
"0x%016" PRIx64, uvalue);
break;
391 case DW_FORM_exprloc:
398 case DW_FORM_exprloc:
399 case DW_FORM_block: OS <<
format(
"<0x%" PRIx64
"> ", uvalue);
break;
400 case DW_FORM_block1: OS <<
format(
"<0x%2.2x> ", (uint8_t)uvalue);
break;
401 case DW_FORM_block2: OS <<
format(
"<0x%4.4x> ", (uint16_t)uvalue);
break;
402 case DW_FORM_block4: OS <<
format(
"<0x%8.8x> ", (uint32_t)uvalue);
break;
406 const uint8_t* data_ptr =
Value.data;
409 const uint8_t* end_data_ptr = data_ptr + uvalue;
410 while (data_ptr < end_data_ptr) {
411 OS <<
format(
"%2.2x ", *data_ptr);
420 case DW_FORM_sdata: OS <<
Value.sval;
break;
421 case DW_FORM_udata: OS <<
Value.uval;
break;
423 OS <<
format(
" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
432 case DW_FORM_GNU_str_index: {
433 OS <<
format(
" indexed (%8.8x) string = ", (uint32_t)uvalue);
442 case DW_FORM_ref_addr:
443 OS <<
format(
"0x%016" PRIx64, uvalue);
446 cu_relative_offset =
true;
447 OS <<
format(
"cu + 0x%2.2x", (uint8_t)uvalue);
450 cu_relative_offset =
true;
451 OS <<
format(
"cu + 0x%4.4x", (uint16_t)uvalue);
454 cu_relative_offset =
true;
455 OS <<
format(
"cu + 0x%4.4x", (uint32_t)uvalue);
458 cu_relative_offset =
true;
459 OS <<
format(
"cu + 0x%8.8" PRIx64, uvalue);
461 case DW_FORM_ref_udata:
462 cu_relative_offset =
true;
463 OS <<
format(
"cu + 0x%" PRIx64, uvalue);
468 case DW_FORM_indirect:
469 OS <<
"DW_FORM_indirect";
473 case DW_FORM_sec_offset:
474 OS <<
format(
"0x%08x", (uint32_t)uvalue);
478 OS <<
format(
"DW_FORM(0x%4.4x)", Form);
482 if (cu_relative_offset)
483 OS <<
format(
" => {0x%8.8" PRIx64
"}", uvalue + (cu ? cu->
getOffset() : 0));
487 if (!isFormClass(FC_String))
489 if (Form == DW_FORM_string)
493 uint32_t Offset =
Value.uval;
494 if (Form == DW_FORM_GNU_str_index) {
507 if (!isFormClass(FC_Address))
509 if (Form == DW_FORM_GNU_addr_index) {
510 uint32_t Index =
Value.uval;
520 if (!isFormClass(FC_Reference))
527 case DW_FORM_ref_udata:
531 case DW_FORM_ref_addr:
540 if (!isFormClass(FC_SectionOffset))
546 if (!isFormClass(FC_Constant) || Form == DW_FORM_sdata)
StringRef getStringOffsetSection() const
StringRef substr(size_t Start, size_t N=npos) const
bool getStringOffsetSectionItem(uint32_t Index, uint32_t &Result) const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
format_object1< T > format(const char *Fmt, const T &Val)
const char * data() const
const T & getValue() const LLVM_LVALUE_FUNCTION
uint16_t getVersion() const
StringRef getStringSection() const
const RelocAddrMap * getRelocMap() const
DataExtractor getStringExtractor() const
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
bool getAddrOffsetSectionItem(uint32_t Index, uint64_t &Result) const
uint32_t getOffset() const
uint8_t getAddressByteSize() const
LLVM Value Representation.
iterator find(const KeyT &Val)
bool empty() const
empty - Check if the string is empty.