100 return DWARFFormValue(
F, V);
104 uint64_t *OffsetPtr) {
105 DWARFFormValue FormValue(
F);
106 FormValue.
extractValue(U->getDebugInfoExtractor(), OffsetPtr,
107 U->getFormParams(), U);
114 bool Indirect =
false;
119 case DW_FORM_exprloc:
120 case DW_FORM_block: {
125 case DW_FORM_block1: {
130 case DW_FORM_block2: {
131 uint16_t
size = DebugInfoData.
getU16(OffsetPtr);
135 case DW_FORM_block4: {
143 DebugInfoData.
getCStr(OffsetPtr);
147 case DW_FORM_ref_addr:
148 case DW_FORM_flag_present:
159 case DW_FORM_ref_sig8:
160 case DW_FORM_ref_sup4:
161 case DW_FORM_ref_sup8:
170 case DW_FORM_sec_offset:
172 case DW_FORM_strp_sup:
173 case DW_FORM_line_strp:
174 case DW_FORM_GNU_ref_alt:
175 case DW_FORM_GNU_strp_alt:
176 case DW_FORM_implicit_const:
177 if (std::optional<uint8_t> FixedSize =
179 *OffsetPtr += *FixedSize;
190 case DW_FORM_ref_udata:
193 case DW_FORM_loclistx:
194 case DW_FORM_rnglistx:
195 case DW_FORM_GNU_addr_index:
196 case DW_FORM_GNU_str_index:
200 case DW_FORM_LLVM_addrx_offset:
205 case DW_FORM_indirect:
226 Ctx = &
CU->getContext();
230 bool Indirect =
false;
231 bool IsBlock =
false;
232 Value.data =
nullptr;
240 case DW_FORM_ref_addr: {
242 (Form == DW_FORM_addr) ?
FP.AddrSize :
FP.getRefAddrByteSize();
244 Data.getRelocatedValue(
Size, OffsetPtr, &Value.SectionIndex, &Err);
247 case DW_FORM_exprloc:
249 Value.uval =
Data.getULEB128(OffsetPtr, &Err);
253 Value.uval =
Data.getU8(OffsetPtr, &Err);
257 Value.uval =
Data.getU16(OffsetPtr, &Err);
261 Value.uval =
Data.getU32(OffsetPtr, &Err);
269 Value.uval =
Data.getU8(OffsetPtr, &Err);
275 Value.uval =
Data.getU16(OffsetPtr, &Err);
279 Value.uval =
Data.getU24(OffsetPtr, &Err);
283 case DW_FORM_ref_sup4:
286 Value.uval =
Data.getRelocatedValue(4, OffsetPtr,
nullptr, &Err);
290 case DW_FORM_ref_sup8:
291 Value.uval =
Data.getRelocatedValue(8, OffsetPtr,
nullptr, &Err);
299 Value.sval =
Data.getSLEB128(OffsetPtr, &Err);
302 case DW_FORM_ref_udata:
303 case DW_FORM_rnglistx:
304 case DW_FORM_loclistx:
305 case DW_FORM_GNU_addr_index:
306 case DW_FORM_GNU_str_index:
309 Value.uval =
Data.getULEB128(OffsetPtr, &Err);
311 case DW_FORM_LLVM_addrx_offset:
312 Value.uval =
Data.getULEB128(OffsetPtr, &Err) << 32;
313 Value.uval |=
Data.getU32(OffsetPtr, &Err);
316 Value.cstr =
Data.getCStr(OffsetPtr, &Err);
318 case DW_FORM_indirect:
323 case DW_FORM_sec_offset:
324 case DW_FORM_GNU_ref_alt:
325 case DW_FORM_GNU_strp_alt:
326 case DW_FORM_line_strp:
327 case DW_FORM_strp_sup: {
328 Value.uval =
Data.getRelocatedValue(
FP.getDwarfOffsetByteSize(),
329 OffsetPtr,
nullptr, &Err);
332 case DW_FORM_flag_present:
335 case DW_FORM_ref_sig8:
336 Value.uval =
Data.getU64(OffsetPtr, &Err);
338 case DW_FORM_implicit_const:
346 }
while (Indirect && !Err);
349 Value.data =
Data.getBytes(OffsetPtr, Value.uval, &Err).bytes_begin();
356 uint8_t HexDigits = AddressSize * 2;
371 uint64_t SectionIndex) {
372 if (!DumpOpts.
Verbose || SectionIndex == -1ULL)
377 OS <<
" \"" << SecRef.Name <<
'\"';
380 if (!SecRef.IsNameUnique)
381 OS <<
formatv(
" [{0}]", SectionIndex);
385 uint64_t UValue = Value.uval;
386 bool CURelativeOffset =
false;
400 case DW_FORM_GNU_addr_index:
401 case DW_FORM_LLVM_addrx_offset: {
403 OS <<
"<invalid dwarf unit>";
408 if (Form == DW_FORM_LLVM_addrx_offset) {
411 AddrOS <<
formatv(
"indexed ({0:x-8}) + {1:x+} address = ",
Index,
419 OS <<
"<unresolved>";
422 case DW_FORM_flag_present:
430 OS <<
formatv(
"{0:x+4}", (uint16_t)UValue);
435 case DW_FORM_ref_sig8:
436 AddrOS <<
formatv(
"{0:x+16}", UValue);
439 OS <<
formatv(
"{0:x+16}", UValue);
442 OS << format_bytes(ArrayRef<uint8_t>(Value.data, 16), std::nullopt, 16, 16);
449 case DW_FORM_exprloc:
456 case DW_FORM_exprloc:
458 AddrOS <<
formatv(
"<{0:x+}> ", UValue);
464 AddrOS <<
formatv(
"<{0:x+4}> ", (uint16_t)UValue);
473 const uint8_t *DataPtr = Value.data;
476 const uint8_t *EndDataPtr = DataPtr + UValue;
477 while (DataPtr < EndDataPtr) {
478 AddrOS <<
formatv(
"{0:x-2} ", *DataPtr);
487 case DW_FORM_implicit_const:
495 OS <<
formatv(
" .debug_str[0x{0:x-}] = ",
499 case DW_FORM_line_strp:
501 OS <<
formatv(
" .debug_line_str[0x{0:x-}] = ",
510 case DW_FORM_GNU_str_index:
515 case DW_FORM_GNU_strp_alt:
517 OS <<
formatv(
"alt indirect string, offset: {0:x+}", UValue);
520 case DW_FORM_ref_addr:
521 AddrOS <<
formatv(
"{0:x+16}", UValue);
524 CURelativeOffset =
true;
529 CURelativeOffset =
true;
531 AddrOS <<
formatv(
"cu + {0:x+4}", (uint16_t)UValue);
534 CURelativeOffset =
true;
539 CURelativeOffset =
true;
541 AddrOS <<
formatv(
"cu + {0:x+8}", UValue);
543 case DW_FORM_ref_udata:
544 CURelativeOffset =
true;
546 AddrOS <<
formatv(
"cu + {0:x+}", UValue);
548 case DW_FORM_GNU_ref_alt:
549 AddrOS <<
formatv(
"<alt {0:x+}>", UValue);
554 case DW_FORM_indirect:
555 OS <<
"DW_FORM_indirect";
558 case DW_FORM_rnglistx:
562 case DW_FORM_loclistx:
566 case DW_FORM_sec_offset:
572 OS <<
formatv(
"DW_FORM(0x{0:x-4})", Form);
576 if (CURelativeOffset) {
581 <<
formatv(
"{0:x+8}", UValue + (U ? U->getOffset() : 0));
587void DWARFFormValue::dumpString(
raw_ostream &OS)
const {
591 COS.get().write_escaped(*DbgStr);
600 if (Form == DW_FORM_string)
603 if (Form == DW_FORM_GNU_strp_alt || C ==
nullptr)
606 uint64_t
Offset = Value.uval;
607 std::optional<uint32_t>
Index;
608 if (Form == DW_FORM_GNU_str_index || Form == DW_FORM_strx ||
609 Form == DW_FORM_strx1 || Form == DW_FORM_strx2 || Form == DW_FORM_strx3 ||
610 Form == DW_FORM_strx4) {
613 "available without a DWARFUnit",
623 bool IsDebugLineString = Form == DW_FORM_line_strp;
625 IsDebugLineString ? C->getLineStringExtractor()
626 : U ? U->getStringExtractor() : C->getStringExtractor();
631 Msg +=
formatv(
" uses index {0}, but the referenced string", *
Index).str();
634 (IsDebugLineString ?
".debug_line_str" :
".debug_str"))
651 bool AddrOffset = Form == dwarf::DW_FORM_LLVM_addrx_offset;
652 if (Form == DW_FORM_GNU_addr_index || Form == DW_FORM_addrx ||
653 Form == DW_FORM_addrx1 || Form == DW_FORM_addrx2 ||
654 Form == DW_FORM_addrx3 || Form == DW_FORM_addrx4 || AddrOffset) {
656 uint32_t Index = AddrOffset ? (Value.uval >> 32) : Value.uval;
659 std::optional<object::SectionedAddress> SA =
660 U->getAddrOffsetSectionItem(
Index);
664 SA->Address += (Value.uval & 0xffffffff);
667 return {{Value.uval, Value.SectionIndex}};
670std::optional<object::SectionedAddress>
681 case DW_FORM_ref_udata:
691 if (Form == DW_FORM_ref_addr)
697 if (Form == DW_FORM_ref_sig8)
704 case DW_FORM_GNU_ref_alt:
705 case DW_FORM_ref_sup4:
706 case DW_FORM_ref_sup8:
721 Form == DW_FORM_sdata)
728 (Form == DW_FORM_udata &&
729 uint64_t(std::numeric_limits<int64_t>::max()) < Value.uval))
733 return int32_t(Value.uval);
735 return int16_t(Value.uval);
737 return int8_t(Value.uval);
747 Form != DW_FORM_data16)
749 return ArrayRef(Value.data, Value.uval);
764std::optional<std::string>
770 std::string FileName;
779 uint16_t DwarfVersion) {
785 case DW_FORM_GNU_ref_alt:
787 case DW_FORM_GNU_addr_index:
789 case DW_FORM_GNU_str_index:
790 case DW_FORM_GNU_strp_alt:
792 case DW_FORM_LLVM_addrx_offset:
795 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.
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...
const DWARFDebugLine::LineTable * getLineTableForUnit(DWARFUnit *U)
Get a pointer to a parsed line table corresponding to a compile unit.
DWARFContext & getContext() const
const char * getCompilationDir()
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
Get the contents as an std::string.
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...
LLVM_ABI StringRef FormEncodingString(unsigned Encoding)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static constexpr StringLiteral SectionNames[SectionKindsNum]
Calculates the starting offsets for various sections within the .debug_names section.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
LLVM_ABI bool doesFormBelongToClass(dwarf::Form Form, DWARFFormValue::FormClass FC, uint16_t DwarfVersion)
Check whether specified Form belongs to the FC class.
LLVM_ABI 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.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
ArrayRef(const T &OneElt) -> ArrayRef< T >
support::detail::AlignAdapter< T > fmt_align(T &&Item, AlignStyle Where, size_t Amount, char Fill=' ')
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
Container for dump options that control which debug information will be dumped.