101 return DWARFFormValue(
F, V);
106 DWARFFormValue FormValue(
F);
107 FormValue.
extractValue(U->getDebugInfoExtractor(), OffsetPtr,
108 U->getFormParams(), U);
115 bool Indirect =
false;
120 case DW_FORM_exprloc:
121 case DW_FORM_block: {
126 case DW_FORM_block1: {
131 case DW_FORM_block2: {
136 case DW_FORM_block4: {
144 DebugInfoData.
getCStr(OffsetPtr);
148 case DW_FORM_ref_addr:
149 case DW_FORM_flag_present:
160 case DW_FORM_ref_sig8:
161 case DW_FORM_ref_sup4:
162 case DW_FORM_ref_sup8:
171 case DW_FORM_sec_offset:
173 case DW_FORM_strp_sup:
174 case DW_FORM_line_strp:
175 case DW_FORM_GNU_ref_alt:
176 case DW_FORM_GNU_strp_alt:
177 case DW_FORM_implicit_const:
178 if (std::optional<uint8_t> FixedSize =
180 *OffsetPtr += *FixedSize;
191 case DW_FORM_ref_udata:
194 case DW_FORM_loclistx:
195 case DW_FORM_rnglistx:
196 case DW_FORM_GNU_addr_index:
197 case DW_FORM_GNU_str_index:
201 case DW_FORM_LLVM_addrx_offset:
206 case DW_FORM_indirect:
227 Ctx = &
CU->getContext();
231 bool Indirect =
false;
232 bool IsBlock =
false;
233 Value.data =
nullptr;
241 case DW_FORM_ref_addr: {
243 (Form == DW_FORM_addr) ?
FP.AddrSize :
FP.getRefAddrByteSize();
245 Data.getRelocatedValue(
Size, OffsetPtr, &Value.SectionIndex, &Err);
248 case DW_FORM_exprloc:
250 Value.uval =
Data.getULEB128(OffsetPtr, &Err);
254 Value.uval =
Data.getU8(OffsetPtr, &Err);
258 Value.uval =
Data.getU16(OffsetPtr, &Err);
262 Value.uval =
Data.getU32(OffsetPtr, &Err);
270 Value.uval =
Data.getU8(OffsetPtr, &Err);
276 Value.uval =
Data.getU16(OffsetPtr, &Err);
280 Value.uval =
Data.getU24(OffsetPtr, &Err);
284 case DW_FORM_ref_sup4:
287 Value.uval =
Data.getRelocatedValue(4, OffsetPtr,
nullptr, &Err);
291 case DW_FORM_ref_sup8:
292 Value.uval =
Data.getRelocatedValue(8, OffsetPtr,
nullptr, &Err);
300 Value.sval =
Data.getSLEB128(OffsetPtr, &Err);
303 case DW_FORM_ref_udata:
304 case DW_FORM_rnglistx:
305 case DW_FORM_loclistx:
306 case DW_FORM_GNU_addr_index:
307 case DW_FORM_GNU_str_index:
310 Value.uval =
Data.getULEB128(OffsetPtr, &Err);
312 case DW_FORM_LLVM_addrx_offset:
313 Value.uval =
Data.getULEB128(OffsetPtr, &Err) << 32;
314 Value.uval |=
Data.getU32(OffsetPtr, &Err);
317 Value.cstr =
Data.getCStr(OffsetPtr, &Err);
319 case DW_FORM_indirect:
324 case DW_FORM_sec_offset:
325 case DW_FORM_GNU_ref_alt:
326 case DW_FORM_GNU_strp_alt:
327 case DW_FORM_line_strp:
328 case DW_FORM_strp_sup: {
329 Value.uval =
Data.getRelocatedValue(
FP.getDwarfOffsetByteSize(),
330 OffsetPtr,
nullptr, &Err);
333 case DW_FORM_flag_present:
336 case DW_FORM_ref_sig8:
337 Value.uval =
Data.getU64(OffsetPtr, &Err);
339 case DW_FORM_implicit_const:
347 }
while (Indirect && !Err);
350 Value.data =
Data.getBytes(OffsetPtr, Value.uval, &Err).bytes_begin();
357 uint8_t HexDigits = AddressSize * 2;
373 if (!DumpOpts.
Verbose || SectionIndex == -1ULL)
378 OS <<
" \"" << SecRef.Name <<
'\"';
381 if (!SecRef.IsNameUnique)
382 OS <<
formatv(
" [{0}]", SectionIndex);
387 bool CURelativeOffset =
false;
401 case DW_FORM_GNU_addr_index:
402 case DW_FORM_LLVM_addrx_offset: {
404 OS <<
"<invalid dwarf unit>";
409 if (Form == DW_FORM_LLVM_addrx_offset) {
412 AddrOS <<
formatv(
"indexed ({0:x-8}) + {1:x+} address = ",
Index,
420 OS <<
"<unresolved>";
423 case DW_FORM_flag_present:
436 case DW_FORM_ref_sig8:
437 AddrOS <<
formatv(
"{0:x+16}", UValue);
440 OS <<
formatv(
"{0:x+16}", UValue);
443 OS << format_bytes(ArrayRef<uint8_t>(Value.data, 16), std::nullopt, 16, 16);
450 case DW_FORM_exprloc:
457 case DW_FORM_exprloc:
459 AddrOS <<
formatv(
"<{0:x+}> ", UValue);
474 const uint8_t *DataPtr = Value.data;
477 const uint8_t *EndDataPtr = DataPtr + UValue;
478 while (DataPtr < EndDataPtr) {
479 AddrOS <<
formatv(
"{0:x-2} ", *DataPtr);
488 case DW_FORM_implicit_const:
496 OS <<
formatv(
" .debug_str[0x{0:x-}] = ",
500 case DW_FORM_line_strp:
502 OS <<
formatv(
" .debug_line_str[0x{0:x-}] = ",
511 case DW_FORM_GNU_str_index:
516 case DW_FORM_GNU_strp_alt:
518 OS <<
formatv(
"alt indirect string, offset: {0:x+}", UValue);
521 case DW_FORM_ref_addr:
522 AddrOS <<
formatv(
"{0:x+16}", UValue);
525 CURelativeOffset =
true;
530 CURelativeOffset =
true;
535 CURelativeOffset =
true;
540 CURelativeOffset =
true;
542 AddrOS <<
formatv(
"cu + {0:x+8}", UValue);
544 case DW_FORM_ref_udata:
545 CURelativeOffset =
true;
547 AddrOS <<
formatv(
"cu + {0:x+}", UValue);
549 case DW_FORM_GNU_ref_alt:
550 AddrOS <<
formatv(
"<alt {0:x+}>", UValue);
555 case DW_FORM_indirect:
556 OS <<
"DW_FORM_indirect";
559 case DW_FORM_rnglistx:
563 case DW_FORM_loclistx:
567 case DW_FORM_sec_offset:
573 OS <<
formatv(
"DW_FORM(0x{0:x-4})", Form);
577 if (CURelativeOffset) {
582 <<
formatv(
"{0:x+8}", UValue + (U ? U->getOffset() : 0));
588void DWARFFormValue::dumpString(
raw_ostream &OS)
const {
592 COS.get().write_escaped(*DbgStr);
601 if (Form == DW_FORM_string)
604 if (Form == DW_FORM_GNU_strp_alt || C ==
nullptr)
608 std::optional<uint32_t>
Index;
609 if (Form == DW_FORM_GNU_str_index || Form == DW_FORM_strx ||
610 Form == DW_FORM_strx1 || Form == DW_FORM_strx2 || Form == DW_FORM_strx3 ||
611 Form == DW_FORM_strx4) {
614 "available without a DWARFUnit",
624 bool IsDebugLineString = Form == DW_FORM_line_strp;
626 IsDebugLineString ? C->getLineStringExtractor()
627 : U ? U->getStringExtractor() : C->getStringExtractor();
632 Msg +=
formatv(
" uses index {0}, but the referenced string", *
Index).str();
635 (IsDebugLineString ?
".debug_line_str" :
".debug_str"))
652 bool AddrOffset = Form == dwarf::DW_FORM_LLVM_addrx_offset;
653 if (Form == DW_FORM_GNU_addr_index || Form == DW_FORM_addrx ||
654 Form == DW_FORM_addrx1 || Form == DW_FORM_addrx2 ||
655 Form == DW_FORM_addrx3 || Form == DW_FORM_addrx4 || AddrOffset) {
657 uint32_t Index = AddrOffset ? (Value.uval >> 32) : Value.uval;
660 std::optional<object::SectionedAddress> SA =
661 U->getAddrOffsetSectionItem(
Index);
665 SA->Address += (Value.uval & 0xffffffff);
668 return {{Value.uval, Value.SectionIndex}};
671std::optional<object::SectionedAddress>
682 case DW_FORM_ref_udata:
692 if (Form == DW_FORM_ref_addr)
698 if (Form == DW_FORM_ref_sig8)
705 case DW_FORM_GNU_ref_alt:
706 case DW_FORM_ref_sup4:
707 case DW_FORM_ref_sup8:
722 Form == DW_FORM_sdata)
729 (Form == DW_FORM_udata &&
730 uint64_t(std::numeric_limits<int64_t>::max()) < Value.uval))
734 return int32_t(Value.uval);
736 return int16_t(Value.uval);
738 return int8_t(Value.uval);
748 Form != DW_FORM_data16)
750 return ArrayRef(Value.data, Value.uval);
765std::optional<std::string>
771 std::string FileName;
786 case DW_FORM_GNU_ref_alt:
788 case DW_FORM_GNU_addr_index:
790 case DW_FORM_GNU_str_index:
791 case DW_FORM_GNU_strp_alt:
793 case DW_FORM_LLVM_addrx_offset:
796 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...
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
str - 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.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
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.