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 (
m_form == DW_FORM_string)
471 if (
m_form == DW_FORM_strp)
474 if (
m_form == DW_FORM_GNU_str_index ||
m_form == DW_FORM_strx ||
478 std::optional<uint64_t> offset =
485 if (
m_form == DW_FORM_line_strp)
494 if (
m_form == DW_FORM_addr)
498 assert(
m_form == DW_FORM_GNU_addr_index ||
m_form == DW_FORM_addrx ||
502 uint32_t index_size =
m_unit->GetAddressByteSize();
506 &offset, index_size);
509std::pair<DWARFUnit *, uint64_t>
517 case DW_FORM_ref_udata:
520 value +=
m_unit->GetOffset();
521 if (!
m_unit->ContainsDIEOffset(value)) {
522 m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
523 "DW_FORM_ref* DIE reference {0:x16} is outside of its CU", value);
528 case DW_FORM_ref_addr: {
530 m_unit->GetSymbolFileDWARF().DebugInfo().GetUnitContainingDIEOffset(
533 m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
534 "DW_FORM_ref_addr DIE reference {0:x16} has no matching CU", value);
537 return {ref_cu, value};
540 case DW_FORM_ref_sig8: {
542 m_unit->GetSymbolFileDWARF().DebugInfo().GetTypeUnitForHash(value);
555 return unit ? unit->GetDIE(offset) :
DWARFDIE();
565 case DW_FORM_ref_udata:
566 return value + base_offset;
568 case DW_FORM_ref_addr:
569 case DW_FORM_ref_sig8:
570 case DW_FORM_GNU_ref_alt:
586 (
m_form == llvm::dwarf::DW_FORM_udata &&
587 uint64_t(std::numeric_limits<int64_t>::max()) <
m_value.uval))
590 case llvm::dwarf::DW_FORM_data4:
592 case llvm::dwarf::DW_FORM_data2:
594 case llvm::dwarf::DW_FORM_data1:
596 case llvm::dwarf::DW_FORM_sdata:
597 case llvm::dwarf::DW_FORM_data8:
607 case DW_FORM_exprloc:
617 llvm_unreachable(
"All cases handled above!");
632 llvm_unreachable(
"All cases handled above!");
639 case DW_FORM_loclistx:
640 case DW_FORM_rnglistx:
654 case DW_FORM_line_strp:
661 case DW_FORM_ref_addr:
666 case DW_FORM_ref_udata:
667 case DW_FORM_indirect:
668 case DW_FORM_sec_offset:
669 case DW_FORM_exprloc:
670 case DW_FORM_flag_present:
671 case DW_FORM_ref_sig8:
672 case DW_FORM_GNU_str_index:
673 case DW_FORM_GNU_addr_index:
674 case DW_FORM_implicit_const:
675 case DW_FORM_GNU_ref_alt:
676 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.