23using namespace llvm::dwarf;
33 if (
m_form == DW_FORM_implicit_const)
36 bool indirect =
false;
37 bool is_block =
false;
77 case DW_FORM_line_strp:
78 case DW_FORM_sec_offset:
79 case DW_FORM_GNU_ref_alt:
80 case DW_FORM_GNU_strp_alt:
83 offset_ptr,
m_unit->GetFormParams().getDwarfOffsetByteSize());
110 case DW_FORM_ref_sig8:
114 case DW_FORM_loclistx:
115 case DW_FORM_rnglistx:
118 case DW_FORM_ref_udata:
119 case DW_FORM_GNU_str_index:
120 case DW_FORM_GNU_addr_index:
123 case DW_FORM_ref_addr:
126 offset_ptr,
m_unit->GetFormParams().getRefAddrByteSize());
128 case DW_FORM_indirect:
132 case DW_FORM_flag_present:
192 if (form <= DW_FORM_ref_sig8 &&
g_form_sizes[form].valid)
194 if (form == DW_FORM_addr && u)
215 case DW_FORM_exprloc:
216 case DW_FORM_block: {
217 uint64_t size = debug_info_data.
GetULEB128(offset_ptr);
221 case DW_FORM_block1: {
222 uint8_t size = debug_info_data.
GetU8(offset_ptr);
226 case DW_FORM_block2: {
227 uint16_t size = debug_info_data.
GetU16(offset_ptr);
231 case DW_FORM_block4: {
232 uint32_t size = debug_info_data.
GetU32(offset_ptr);
239 debug_info_data.
GetCStr(offset_ptr);
247 case DW_FORM_ref_addr:
254 case DW_FORM_flag_present:
255 case DW_FORM_implicit_const:
282 case DW_FORM_sec_offset:
284 case DW_FORM_line_strp:
285 case DW_FORM_GNU_ref_alt:
286 case DW_FORM_GNU_strp_alt:
288 *offset_ptr += unit->
GetFormParams().getDwarfOffsetByteSize();
302 case DW_FORM_ref_sig8:
313 case DW_FORM_loclistx:
314 case DW_FORM_rnglistx:
317 case DW_FORM_ref_udata:
318 case DW_FORM_GNU_addr_index:
319 case DW_FORM_GNU_str_index:
324 case DW_FORM_indirect: {
339 bool unit_relative_offset =
false;
352 case DW_FORM_sec_offset:
356 case DW_FORM_ref_sig8:
363 case DW_FORM_exprloc:
370 case DW_FORM_exprloc:
372 s.
Printf(
"<0x%" PRIx64
"> ", uvalue);
375 s.
Printf(
"<0x%2.2x> ", (uint8_t)uvalue);
378 s.
Printf(
"<0x%4.4x> ", (uint16_t)uvalue);
381 s.
Printf(
"<0x%8.8x> ", (uint32_t)uvalue);
387 const uint8_t *data_ptr =
m_value.data;
389 const uint8_t *end_data_ptr =
391 while (data_ptr < end_data_ptr) {
392 s.
Printf(
"%2.2x ", *data_ptr);
407 case DW_FORM_line_strp: {
416 case DW_FORM_ref_addr: {
420 m_unit->GetFormParams().getRefAddrByteSize());
423 case DW_FORM_GNU_ref_alt:
424 case DW_FORM_GNU_strp_alt: {
427 m_unit->GetFormParams().getDwarfOffsetByteSize());
431 unit_relative_offset =
true;
434 unit_relative_offset =
true;
437 unit_relative_offset =
true;
440 unit_relative_offset =
true;
442 case DW_FORM_ref_udata:
443 unit_relative_offset =
true;
448 case DW_FORM_indirect:
451 case DW_FORM_flag_present:
459 if (unit_relative_offset) {
462 s.
Printf(
"{0x%8.8" PRIx64
"}", uvalue +
m_unit->GetOffset());
469 if (std::optional<llvm::StringRef> str = data.
PeekCStr(offset))
477 if (
m_form == DW_FORM_string)
479 if (
m_form == DW_FORM_strp)
482 if (
m_form == DW_FORM_GNU_str_index ||
m_form == DW_FORM_strx ||
486 std::optional<uint64_t> offset =
493 if (
m_form == DW_FORM_line_strp)
502 if (
m_form == DW_FORM_addr)
506 assert(
m_form == DW_FORM_GNU_addr_index ||
m_form == DW_FORM_addrx ||
510 uint32_t index_size =
m_unit->GetAddressByteSize();
514 &offset, index_size);
517std::pair<DWARFUnit *, uint64_t>
525 case DW_FORM_ref_udata:
528 value +=
m_unit->GetOffset();
529 if (!
m_unit->ContainsDIEOffset(value)) {
530 m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
531 "DW_FORM_ref* DIE reference {0:x16} is outside of its CU", value);
536 case DW_FORM_ref_addr: {
538 m_unit->GetSymbolFileDWARF().DebugInfo().GetUnitContainingDIEOffset(
541 m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
542 "DW_FORM_ref_addr DIE reference {0:x16} has no matching CU", value);
545 return {ref_cu, value};
548 case DW_FORM_ref_sig8: {
550 m_unit->GetSymbolFileDWARF().DebugInfo().GetTypeUnitForHash(value);
563 return unit ? unit->GetDIE(offset) :
DWARFDIE();
573 case DW_FORM_ref_udata:
574 return value + base_offset;
576 case DW_FORM_ref_addr:
577 case DW_FORM_ref_sig8:
578 case DW_FORM_GNU_ref_alt:
594 (
m_form == llvm::dwarf::DW_FORM_udata &&
595 uint64_t(std::numeric_limits<int64_t>::max()) <
m_value.uval))
598 case llvm::dwarf::DW_FORM_data4:
600 case llvm::dwarf::DW_FORM_data2:
602 case llvm::dwarf::DW_FORM_data1:
604 case llvm::dwarf::DW_FORM_sdata:
605 case llvm::dwarf::DW_FORM_data8:
615 case DW_FORM_exprloc:
625 llvm_unreachable(
"All cases handled above!");
640 llvm_unreachable(
"All cases handled above!");
647 case DW_FORM_loclistx:
648 case DW_FORM_rnglistx:
662 case DW_FORM_line_strp:
669 case DW_FORM_ref_addr:
674 case DW_FORM_ref_udata:
675 case DW_FORM_indirect:
676 case DW_FORM_sec_offset:
677 case DW_FORM_exprloc:
678 case DW_FORM_flag_present:
679 case DW_FORM_ref_sig8:
680 case DW_FORM_GNU_str_index:
681 case DW_FORM_GNU_addr_index:
682 case DW_FORM_implicit_const:
683 case DW_FORM_GNU_ref_alt:
684 case DW_FORM_GNU_strp_alt:
A stream class that can stream formatted output to a file.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t size_t PutHex8(uint8_t uvalue)
Append an uint8_t value in the hexadecimal format to the stream.
size_t PutHex64(uint64_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t PutHex16(uint16_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
void QuotedCString(const char *cstr, const char *format="\"%s\"")
Output a quoted C string value to the stream.
size_t PutHex32(uint32_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
size_t PutULEB128(uint64_t uval)
Output a ULEB128 number to the stream.
size_t PutSLEB128(int64_t uval)
Output a SLEB128 number to the stream.
const DWARFDataExtractor & getOrLoadStrData()
const DWARFDataExtractor & getOrLoadLineStrData()
const DWARFDataExtractor & getOrLoadAddrData()
dw_offset_t GetTypeOffset()
uint8_t GetAddressByteSize() const override
const llvm::dwarf::FormParams & GetFormParams() const
DWARFContext & GetDWARFContext()
#define DW_INVALID_OFFSET
llvm::dwarf::Form dw_form_t
A class that represents a running process on the host machine.
void DumpAddress(llvm::raw_ostream &s, uint64_t addr, uint32_t addr_size, const char *prefix=nullptr, const char *suffix=nullptr)
Output an address value to this stream.