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:
81 offset_ptr,
m_unit->GetFormParams().getDwarfOffsetByteSize());
108 case DW_FORM_ref_sig8:
112 case DW_FORM_loclistx:
113 case DW_FORM_rnglistx:
116 case DW_FORM_ref_udata:
117 case DW_FORM_GNU_str_index:
118 case DW_FORM_GNU_addr_index:
121 case DW_FORM_ref_addr:
124 offset_ptr,
m_unit->GetFormParams().getRefAddrByteSize());
126 case DW_FORM_indirect:
130 case DW_FORM_flag_present:
190 if (form <= DW_FORM_ref_sig8 &&
g_form_sizes[form].valid)
192 if (form == DW_FORM_addr && u)
213 case DW_FORM_exprloc:
214 case DW_FORM_block: {
215 uint64_t size = debug_info_data.
GetULEB128(offset_ptr);
219 case DW_FORM_block1: {
220 uint8_t size = debug_info_data.
GetU8(offset_ptr);
224 case DW_FORM_block2: {
225 uint16_t size = debug_info_data.
GetU16(offset_ptr);
229 case DW_FORM_block4: {
230 uint32_t size = debug_info_data.
GetU32(offset_ptr);
237 debug_info_data.
GetCStr(offset_ptr);
245 case DW_FORM_ref_addr:
252 case DW_FORM_flag_present:
253 case DW_FORM_implicit_const:
280 case DW_FORM_sec_offset:
282 case DW_FORM_line_strp:
284 *offset_ptr += unit->
GetFormParams().getDwarfOffsetByteSize();
298 case DW_FORM_ref_sig8:
309 case DW_FORM_loclistx:
310 case DW_FORM_rnglistx:
313 case DW_FORM_ref_udata:
314 case DW_FORM_GNU_addr_index:
315 case DW_FORM_GNU_str_index:
320 case DW_FORM_indirect: {
335 bool unit_relative_offset =
false;
348 case DW_FORM_sec_offset:
352 case DW_FORM_ref_sig8:
359 case DW_FORM_exprloc:
366 case DW_FORM_exprloc:
368 s.
Printf(
"<0x%" PRIx64
"> ", uvalue);
371 s.
Printf(
"<0x%2.2x> ", (uint8_t)uvalue);
374 s.
Printf(
"<0x%4.4x> ", (uint16_t)uvalue);
377 s.
Printf(
"<0x%8.8x> ", (uint32_t)uvalue);
383 const uint8_t *data_ptr =
m_value.data;
385 const uint8_t *end_data_ptr =
387 while (data_ptr < end_data_ptr) {
388 s.
Printf(
"%2.2x ", *data_ptr);
403 case DW_FORM_line_strp: {
412 case DW_FORM_ref_addr: {
416 m_unit->GetFormParams().getRefAddrByteSize());
420 unit_relative_offset =
true;
423 unit_relative_offset =
true;
426 unit_relative_offset =
true;
429 unit_relative_offset =
true;
431 case DW_FORM_ref_udata:
432 unit_relative_offset =
true;
437 case DW_FORM_indirect:
440 case DW_FORM_flag_present:
447 if (unit_relative_offset) {
450 s.
Printf(
"{0x%8.8" PRIx64
"}", uvalue +
m_unit->GetOffset());
457 if (
m_form == DW_FORM_string)
459 if (
m_form == DW_FORM_strp)
462 if (
m_form == DW_FORM_GNU_str_index ||
m_form == DW_FORM_strx ||
466 std::optional<uint64_t> offset =
473 if (
m_form == DW_FORM_line_strp)
482 if (
m_form == DW_FORM_addr)
486 assert(
m_form == DW_FORM_GNU_addr_index ||
m_form == DW_FORM_addrx ||
490 uint32_t index_size =
m_unit->GetAddressByteSize();
494 &offset, index_size);
497std::pair<DWARFUnit *, uint64_t>
505 case DW_FORM_ref_udata:
508 value +=
m_unit->GetOffset();
509 if (!
m_unit->ContainsDIEOffset(value)) {
510 m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
511 "DW_FORM_ref* DIE reference {0:x16} is outside of its CU", value);
516 case DW_FORM_ref_addr: {
518 m_unit->GetSymbolFileDWARF().DebugInfo().GetUnitContainingDIEOffset(
521 m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
522 "DW_FORM_ref_addr DIE reference {0:x16} has no matching CU", value);
525 return {ref_cu, value};
528 case DW_FORM_ref_sig8: {
530 m_unit->GetSymbolFileDWARF().DebugInfo().GetTypeUnitForHash(value);
543 return unit ? unit->GetDIE(offset) :
DWARFDIE();
553 case DW_FORM_ref_udata:
554 return value + base_offset;
556 case DW_FORM_ref_addr:
557 case DW_FORM_ref_sig8:
558 case DW_FORM_GNU_ref_alt:
574 (
m_form == llvm::dwarf::DW_FORM_udata &&
575 uint64_t(std::numeric_limits<int64_t>::max()) <
m_value.uval))
578 case llvm::dwarf::DW_FORM_data4:
580 case llvm::dwarf::DW_FORM_data2:
582 case llvm::dwarf::DW_FORM_data1:
584 case llvm::dwarf::DW_FORM_sdata:
585 case llvm::dwarf::DW_FORM_data8:
595 case DW_FORM_exprloc:
605 llvm_unreachable(
"All cases handled above!");
620 llvm_unreachable(
"All cases handled above!");
627 case DW_FORM_loclistx:
628 case DW_FORM_rnglistx:
642 case DW_FORM_line_strp:
649 case DW_FORM_ref_addr:
654 case DW_FORM_ref_udata:
655 case DW_FORM_indirect:
656 case DW_FORM_sec_offset:
657 case DW_FORM_exprloc:
658 case DW_FORM_flag_present:
659 case DW_FORM_ref_sig8:
660 case DW_FORM_GNU_str_index:
661 case DW_FORM_GNU_addr_index:
662 case DW_FORM_implicit_const:
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.