Go to the documentation of this file.
30 using namespace dwarf;
114 bool Indirect =
false;
119 case DW_FORM_exprloc:
120 case DW_FORM_block: {
125 case DW_FORM_block1: {
126 uint8_t
size = DebugInfoData.
getU8(OffsetPtr);
130 case DW_FORM_block2: {
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:
168 case DW_FORM_sec_offset:
170 case DW_FORM_strp_sup:
171 case DW_FORM_line_strp:
172 case DW_FORM_GNU_ref_alt:
173 case DW_FORM_GNU_strp_alt:
174 case DW_FORM_implicit_const:
177 *OffsetPtr += *FixedSize;
188 case DW_FORM_ref_udata:
191 case DW_FORM_loclistx:
192 case DW_FORM_rnglistx:
193 case DW_FORM_GNU_addr_index:
194 case DW_FORM_GNU_str_index:
198 case DW_FORM_LLVM_addrx_offset:
203 case DW_FORM_indirect:
222 case DW_FORM_GNU_ref_alt:
223 return (
FC == FC_Reference);
224 case DW_FORM_GNU_addr_index:
225 return (
FC == FC_Address);
226 case DW_FORM_GNU_str_index:
227 case DW_FORM_GNU_strp_alt:
228 return (
FC == FC_String);
229 case DW_FORM_LLVM_addrx_offset:
230 return (
FC == FC_Address);
235 if (
FC == FC_SectionOffset) {
236 if (
Form == DW_FORM_strp ||
Form == DW_FORM_line_strp)
240 if (
Form == DW_FORM_data4 ||
Form == DW_FORM_data8)
241 return !U || U->getVersion() <= 3;
252 Ctx = &
CU->getContext();
256 bool Indirect =
false;
257 bool IsBlock =
false;
258 Value.data =
nullptr;
266 case DW_FORM_ref_addr: {
268 (
Form == DW_FORM_addr) ?
FP.AddrSize :
FP.getRefAddrByteSize();
270 Data.getRelocatedValue(Size, OffsetPtr, &
Value.SectionIndex, &Err);
273 case DW_FORM_exprloc:
275 Value.uval =
Data.getULEB128(OffsetPtr, &Err);
279 Value.uval =
Data.getU8(OffsetPtr, &Err);
283 Value.uval =
Data.getU16(OffsetPtr, &Err);
287 Value.uval =
Data.getU32(OffsetPtr, &Err);
295 Value.uval =
Data.getU8(OffsetPtr, &Err);
301 Value.uval =
Data.getU16(OffsetPtr, &Err);
304 Value.uval =
Data.getU24(OffsetPtr, &Err);
308 case DW_FORM_ref_sup4:
311 Value.uval =
Data.getRelocatedValue(4, OffsetPtr,
nullptr, &Err);
315 case DW_FORM_ref_sup8:
316 Value.uval =
Data.getRelocatedValue(8, OffsetPtr,
nullptr, &Err);
324 Value.sval =
Data.getSLEB128(OffsetPtr, &Err);
327 case DW_FORM_ref_udata:
328 case DW_FORM_rnglistx:
329 case DW_FORM_loclistx:
330 case DW_FORM_GNU_addr_index:
331 case DW_FORM_GNU_str_index:
334 Value.uval =
Data.getULEB128(OffsetPtr, &Err);
336 case DW_FORM_LLVM_addrx_offset:
337 Value.uval =
Data.getULEB128(OffsetPtr, &Err) << 32;
338 Value.uval |=
Data.getU32(OffsetPtr, &Err);
341 Value.cstr =
Data.getCStr(OffsetPtr, &Err);
343 case DW_FORM_indirect:
348 case DW_FORM_sec_offset:
349 case DW_FORM_GNU_ref_alt:
350 case DW_FORM_GNU_strp_alt:
351 case DW_FORM_line_strp:
352 case DW_FORM_strp_sup: {
353 Value.uval =
Data.getRelocatedValue(
FP.getDwarfOffsetByteSize(),
354 OffsetPtr,
nullptr, &Err);
357 case DW_FORM_flag_present:
360 case DW_FORM_ref_sig8:
361 Value.uval =
Data.getU64(OffsetPtr, &Err);
363 case DW_FORM_implicit_const:
371 }
while (Indirect && !Err);
374 Value.data =
Data.getBytes(OffsetPtr,
Value.uval, &Err).bytes_begin();
381 uint8_t HexDigits = AddressSize * 2;
382 OS <<
format(
"0x%*.*" PRIx64, HexDigits, HexDigits, Address);
388 dumpAddress(OS, U->getAddressByteSize(), SA.
Address);
389 dumpAddressSection(U->getContext().getDWARFObj(), OS, DumpOpts,
396 if (!DumpOpts.
Verbose || SectionIndex == -1ULL)
399 const auto &SecRef = SectionNames[SectionIndex];
401 OS <<
" \"" << SecRef.Name <<
'\"';
404 if (!SecRef.IsNameUnique)
405 OS <<
format(
" [%" PRIu64
"]", SectionIndex);
410 bool CURelativeOffset =
false;
417 dumpSectionedAddress(AddrOS, DumpOpts, {
Value.uval,
Value.SectionIndex});
424 case DW_FORM_GNU_addr_index: {
426 OS <<
"<invalid dwarf unit>";
433 dumpSectionedAddress(AddrOS, DumpOpts, *A);
435 OS <<
"<unresolved>";
438 case DW_FORM_LLVM_addrx_offset: {
440 OS <<
"<invalid dwarf unit>";
444 uint32_t Offset = UValue & 0xffffffff;
447 AddrOS <<
format(
"indexed (%8.8x) + 0x%x address = ",
Index, Offset);
449 A->Address += Offset;
450 dumpSectionedAddress(AddrOS, DumpOpts, *A);
452 OS <<
"<unresolved>";
455 case DW_FORM_flag_present:
460 OS <<
format(
"0x%02x", (uint8_t)UValue);
468 case DW_FORM_ref_sig8:
469 AddrOS <<
format(
"0x%016" PRIx64, UValue);
472 OS <<
format(
"0x%016" PRIx64, UValue);
475 OS << format_bytes(ArrayRef<uint8_t>(
Value.data, 16),
None, 16, 16);
482 case DW_FORM_exprloc:
489 case DW_FORM_exprloc:
491 AddrOS <<
format(
"<0x%" PRIx64
"> ", UValue);
494 AddrOS <<
format(
"<0x%2.2x> ", (uint8_t)UValue);
506 const uint8_t *DataPtr =
Value.data;
509 const uint8_t *EndDataPtr = DataPtr + UValue;
510 while (DataPtr < EndDataPtr) {
511 AddrOS <<
format(
"%2.2x ", *DataPtr);
520 case DW_FORM_implicit_const:
528 OS <<
format(
" .debug_str[0x%0*" PRIx64
"] = ", OffsetDumpWidth, UValue);
531 case DW_FORM_line_strp:
533 OS <<
format(
" .debug_line_str[0x%0*" PRIx64
"] = ", OffsetDumpWidth,
542 case DW_FORM_GNU_str_index:
547 case DW_FORM_GNU_strp_alt:
549 OS <<
format(
"alt indirect string, offset: 0x%" PRIx64
"", UValue);
552 case DW_FORM_ref_addr:
553 AddrOS <<
format(
"0x%016" PRIx64, UValue);
556 CURelativeOffset =
true;
558 AddrOS <<
format(
"cu + 0x%2.2x", (uint8_t)UValue);
561 CURelativeOffset =
true;
566 CURelativeOffset =
true;
571 CURelativeOffset =
true;
573 AddrOS <<
format(
"cu + 0x%8.8" PRIx64, UValue);
575 case DW_FORM_ref_udata:
576 CURelativeOffset =
true;
578 AddrOS <<
format(
"cu + 0x%" PRIx64, UValue);
580 case DW_FORM_GNU_ref_alt:
581 AddrOS <<
format(
"<alt 0x%" PRIx64
">", UValue);
586 case DW_FORM_indirect:
587 OS <<
"DW_FORM_indirect";
590 case DW_FORM_rnglistx:
594 case DW_FORM_loclistx:
598 case DW_FORM_sec_offset:
599 AddrOS <<
format(
"0x%0*" PRIx64, OffsetDumpWidth, UValue);
607 if (CURelativeOffset) {
612 <<
format(
"0x%8.8" PRIx64, UValue + (U ? U->getOffset() : 0));
618 void DWARFFormValue::dumpString(
raw_ostream &OS)
const {
622 COS.get().write_escaped(*DbgStr);
628 if (!isFormClass(FC_String))
629 return make_error<StringError>(
"Invalid form for string attribute",
631 if (
Form == DW_FORM_string)
634 if (
Form == DW_FORM_GNU_strp_alt ||
C ==
nullptr)
635 return make_error<StringError>(
"Unsupported form for string attribute",
639 if (
Form == DW_FORM_GNU_str_index ||
Form == DW_FORM_strx ||
640 Form == DW_FORM_strx1 ||
Form == DW_FORM_strx2 ||
Form == DW_FORM_strx3 ||
641 Form == DW_FORM_strx4) {
643 return make_error<StringError>(
"API limitation - string extraction not "
644 "available without a DWARFUnit",
655 ?
C->getLineStringExtractor()
656 : U ? U->getStringExtractor()
657 :
C->getStringExtractor();
658 if (
const char *Str = StrData.
getCStr(&Offset))
662 Msg += (
" uses index " +
Twine(*
Index) +
", but the referenced string").str();
663 Msg += (
" offset " +
Twine(Offset) +
" is beyond .debug_str bounds").str();
664 return make_error<StringError>(
Msg,
669 if (
auto SA = getAsSectionedAddress())
676 if (!isFormClass(FC_Address))
678 bool AddrOffset =
Form == dwarf::DW_FORM_LLVM_addrx_offset;
679 if (
Form == DW_FORM_GNU_addr_index ||
Form == DW_FORM_addrx || AddrOffset) {
695 if (
auto R = getAsRelativeReference())
696 return R->Unit ? R->Unit->getOffset() + R->Offset : R->Offset;
701 if (!isFormClass(FC_Reference))
708 case DW_FORM_ref_udata:
712 case DW_FORM_ref_addr:
713 case DW_FORM_ref_sig8:
714 case DW_FORM_GNU_ref_alt:
722 if (!isFormClass(FC_SectionOffset))
728 if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) ||
729 Form == DW_FORM_sdata)
735 if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) ||
736 (
Form == DW_FORM_udata &&
741 return int32_t(
Value.uval);
743 return int16_t(
Value.uval);
745 return int8_t(
Value.uval);
754 if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc) &&
755 Form != DW_FORM_data16)
761 if (!isFormClass(FC_String) &&
Form == DW_FORM_string)
767 if (!isFormClass(FC_Reference))
774 if (U ==
nullptr || !isFormClass(FC_Constant))
778 std::string FileName;
const DWARFDebugLine::LineTable * getLineTableForUnit(DWARFUnit *U)
Get a pointer to a parsed line table corresponding to a compile unit.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '\t', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an esca...
static ErrorSuccess success()
Create a success value.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
An RAII object that temporarily switches an output stream to a specific color.
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Tagged union holding either a T or a Error.
const dwarf::FormParams & getFormParams() const
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
(vector float) vec_cmpeq(*A, *B) C
virtual ArrayRef< SectionName > getSectionNames() const
This class implements an extremely fast bulk output stream that can only output to a stream.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
StringRef FormEncodingString(unsigned Encoding)
DWARFDataExtractor getDebugInfoExtractor() const
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
bool errorToBool(Error Err)
Helper for converting an Error to a bool.
Optional< const char * > toString(const Optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
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.
const char * getCompilationDir()
DWARFContext & getContext() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
if(llvm_vc STREQUAL "") set(fake_version_inc "$
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
const CustomOperand< const MCSubtargetInfo & > Msg[]
Optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Lightweight error class with error context and mandatory checking.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Error takeError()
Take ownership of the stored error.
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
LLVM Value Representation.
Container for dump options that control which debug information will be dumped.