105 FormValue.
extractValue(U->getDebugInfoExtractor(), OffsetPtr,
106 U->getFormParams(), U);
113 bool Indirect =
false;
118 case DW_FORM_exprloc:
119 case DW_FORM_block: {
124 case DW_FORM_block1: {
125 uint8_t
size = DebugInfoData.
getU8(OffsetPtr);
129 case DW_FORM_block2: {
134 case DW_FORM_block4: {
142 DebugInfoData.
getCStr(OffsetPtr);
146 case DW_FORM_ref_addr:
147 case DW_FORM_flag_present:
158 case DW_FORM_ref_sig8:
159 case DW_FORM_ref_sup4:
160 case DW_FORM_ref_sup8:
169 case DW_FORM_sec_offset:
171 case DW_FORM_strp_sup:
172 case DW_FORM_line_strp:
173 case DW_FORM_GNU_ref_alt:
174 case DW_FORM_GNU_strp_alt:
175 case DW_FORM_implicit_const:
176 if (std::optional<uint8_t> FixedSize =
178 *OffsetPtr += *FixedSize;
189 case DW_FORM_ref_udata:
192 case DW_FORM_loclistx:
193 case DW_FORM_rnglistx:
194 case DW_FORM_GNU_addr_index:
195 case DW_FORM_GNU_str_index:
199 case DW_FORM_LLVM_addrx_offset:
204 case DW_FORM_indirect:
225 Ctx = &
CU->getContext();
229 bool Indirect =
false;
230 bool IsBlock =
false;
231 Value.data =
nullptr;
239 case DW_FORM_ref_addr: {
241 (
Form == DW_FORM_addr) ?
FP.AddrSize :
FP.getRefAddrByteSize();
243 Data.getRelocatedValue(
Size, OffsetPtr, &
Value.SectionIndex, &Err);
246 case DW_FORM_exprloc:
248 Value.uval =
Data.getULEB128(OffsetPtr, &Err);
252 Value.uval =
Data.getU8(OffsetPtr, &Err);
256 Value.uval =
Data.getU16(OffsetPtr, &Err);
260 Value.uval =
Data.getU32(OffsetPtr, &Err);
268 Value.uval =
Data.getU8(OffsetPtr, &Err);
274 Value.uval =
Data.getU16(OffsetPtr, &Err);
278 Value.uval =
Data.getU24(OffsetPtr, &Err);
282 case DW_FORM_ref_sup4:
285 Value.uval =
Data.getRelocatedValue(4, OffsetPtr,
nullptr, &Err);
289 case DW_FORM_ref_sup8:
290 Value.uval =
Data.getRelocatedValue(8, OffsetPtr,
nullptr, &Err);
298 Value.sval =
Data.getSLEB128(OffsetPtr, &Err);
301 case DW_FORM_ref_udata:
302 case DW_FORM_rnglistx:
303 case DW_FORM_loclistx:
304 case DW_FORM_GNU_addr_index:
305 case DW_FORM_GNU_str_index:
308 Value.uval =
Data.getULEB128(OffsetPtr, &Err);
310 case DW_FORM_LLVM_addrx_offset:
311 Value.uval =
Data.getULEB128(OffsetPtr, &Err) << 32;
312 Value.uval |=
Data.getU32(OffsetPtr, &Err);
315 Value.cstr =
Data.getCStr(OffsetPtr, &Err);
317 case DW_FORM_indirect:
322 case DW_FORM_sec_offset:
323 case DW_FORM_GNU_ref_alt:
324 case DW_FORM_GNU_strp_alt:
325 case DW_FORM_line_strp:
326 case DW_FORM_strp_sup: {
327 Value.uval =
Data.getRelocatedValue(
FP.getDwarfOffsetByteSize(),
328 OffsetPtr,
nullptr, &Err);
331 case DW_FORM_flag_present:
334 case DW_FORM_ref_sig8:
335 Value.uval =
Data.getU64(OffsetPtr, &Err);
337 case DW_FORM_implicit_const:
345 }
while (Indirect && !Err);
348 Value.data =
Data.getBytes(OffsetPtr,
Value.uval, &Err).bytes_begin();
355 uint8_t HexDigits = AddressSize * 2;
370 if (!DumpOpts.
Verbose || SectionIndex == -1ULL)
375 OS <<
" \"" << SecRef.Name <<
'\"';
378 if (!SecRef.IsNameUnique)
379 OS <<
format(
" [%" PRIu64
"]", SectionIndex);
384 bool CURelativeOffset =
false;
398 case DW_FORM_GNU_addr_index:
399 case DW_FORM_LLVM_addrx_offset: {
401 OS <<
"<invalid dwarf unit>";
406 if (
Form == DW_FORM_LLVM_addrx_offset) {
416 OS <<
"<unresolved>";
419 case DW_FORM_flag_present:
424 OS <<
format(
"0x%02x", (uint8_t)UValue);
432 case DW_FORM_ref_sig8:
433 AddrOS <<
format(
"0x%016" PRIx64, UValue);
436 OS <<
format(
"0x%016" PRIx64, UValue);
439 OS << format_bytes(ArrayRef<uint8_t>(
Value.data, 16), std::nullopt, 16, 16);
446 case DW_FORM_exprloc:
453 case DW_FORM_exprloc:
455 AddrOS <<
format(
"<0x%" PRIx64
"> ", UValue);
458 AddrOS <<
format(
"<0x%2.2x> ", (uint8_t)UValue);
470 const uint8_t *DataPtr =
Value.data;
473 const uint8_t *EndDataPtr = DataPtr + UValue;
474 while (DataPtr < EndDataPtr) {
475 AddrOS <<
format(
"%2.2x ", *DataPtr);
484 case DW_FORM_implicit_const:
492 OS <<
format(
" .debug_str[0x%0*" PRIx64
"] = ", OffsetDumpWidth, UValue);
495 case DW_FORM_line_strp:
497 OS <<
format(
" .debug_line_str[0x%0*" PRIx64
"] = ", OffsetDumpWidth,
506 case DW_FORM_GNU_str_index:
511 case DW_FORM_GNU_strp_alt:
513 OS <<
format(
"alt indirect string, offset: 0x%" PRIx64
"", UValue);
516 case DW_FORM_ref_addr:
517 AddrOS <<
format(
"0x%016" PRIx64, UValue);
520 CURelativeOffset =
true;
522 AddrOS <<
format(
"cu + 0x%2.2x", (uint8_t)UValue);
525 CURelativeOffset =
true;
530 CURelativeOffset =
true;
535 CURelativeOffset =
true;
537 AddrOS <<
format(
"cu + 0x%8.8" PRIx64, UValue);
539 case DW_FORM_ref_udata:
540 CURelativeOffset =
true;
542 AddrOS <<
format(
"cu + 0x%" PRIx64, UValue);
544 case DW_FORM_GNU_ref_alt:
545 AddrOS <<
format(
"<alt 0x%" PRIx64
">", UValue);
550 case DW_FORM_indirect:
551 OS <<
"DW_FORM_indirect";
554 case DW_FORM_rnglistx:
558 case DW_FORM_loclistx:
562 case DW_FORM_sec_offset:
563 AddrOS <<
format(
"0x%0*" PRIx64, OffsetDumpWidth, UValue);
571 if (CURelativeOffset) {
586 COS.get().write_escaped(*DbgStr);
593 return make_error<StringError>(
"Invalid form for string attribute",
595 if (
Form == DW_FORM_string)
598 if (
Form == DW_FORM_GNU_strp_alt || C ==
nullptr)
599 return make_error<StringError>(
"Unsupported form for string attribute",
602 std::optional<uint32_t>
Index;
603 if (
Form == DW_FORM_GNU_str_index ||
Form == DW_FORM_strx ||
604 Form == DW_FORM_strx1 ||
Form == DW_FORM_strx2 ||
Form == DW_FORM_strx3 ||
605 Form == DW_FORM_strx4) {
607 return make_error<StringError>(
"API limitation - string extraction not "
608 "available without a DWARFUnit",
618 bool IsDebugLineString =
Form == DW_FORM_line_strp;
626 Msg += (
" uses index " +
Twine(*
Index) +
", but the referenced string").str();
627 Msg += (
" offset " +
Twine(
Offset) +
" is beyond " +
628 (IsDebugLineString ?
".debug_line_str" :
".debug_str") +
" bounds")
630 return make_error<StringError>(Msg,
644 bool AddrOffset =
Form == dwarf::DW_FORM_LLVM_addrx_offset;
645 if (
Form == DW_FORM_GNU_addr_index ||
Form == DW_FORM_addrx ||
646 Form == DW_FORM_addrx1 ||
Form == DW_FORM_addrx2 ||
647 Form == DW_FORM_addrx3 ||
Form == DW_FORM_addrx4 || AddrOffset) {
652 std::optional<object::SectionedAddress> SA =
653 U->getAddrOffsetSectionItem(
Index);
657 SA->Address += (
Value.uval & 0xffffffff);
663std::optional<object::SectionedAddress>
674 case DW_FORM_ref_udata:
684 if (
Form == DW_FORM_ref_addr)
690 if (
Form == DW_FORM_ref_sig8)
697 case DW_FORM_GNU_ref_alt:
698 case DW_FORM_ref_sup4:
699 case DW_FORM_ref_sup8:
714 Form == DW_FORM_sdata)
721 (
Form == DW_FORM_udata &&
726 return int32_t(
Value.uval);
728 return int16_t(
Value.uval);
730 return int8_t(
Value.uval);
740 Form != DW_FORM_data16)
757std::optional<std::string>
763 std::string FileName;
778 case DW_FORM_GNU_ref_alt:
780 case DW_FORM_GNU_addr_index:
782 case DW_FORM_GNU_str_index:
783 case DW_FORM_GNU_strp_alt:
785 case DW_FORM_LLVM_addrx_offset:
788 case DW_FORM_line_strp:
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This file contains constants used for implementing Dwarf debug support.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
DataExtractor getStringExtractor() const
const DWARFDebugLine::LineTable * getLineTableForUnit(DWARFUnit *U)
Get a pointer to a parsed line table corresponding to a compile unit.
DataExtractor getLineStringExtractor() const
const DWARFObject & getDWARFObj() const
virtual ArrayRef< SectionName > getSectionNames() const
DataExtractor getStringExtractor() const
DWARFContext & getContext() const
uint8_t getAddressByteSize() const
const char * getCompilationDir()
uint16_t getVersion() const
Expected< uint64_t > getStringOffsetSectionItem(uint32_t Index) const
uint64_t getOffset() const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
std::string str() const
str - Get the contents as an std::string.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
An RAII object that temporarily switches an output stream to a specific color.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '\t', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an esca...
StringRef FormEncodingString(unsigned Encoding)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static constexpr StringLiteral SectionNames[SectionKindsNum]
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
bool doesFormBelongToClass(dwarf::Form Form, DWARFFormValue::FormClass FC, uint16_t DwarfVersion)
Check whether specified Form belongs to the FC class.
std::optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
This is an optimization pass for GlobalISel generic memory operations.
bool errorToBool(Error Err)
Helper for converting an Error to a bool.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Container for dump options that control which debug information will be dumped.