28 using namespace dwarf;
84 bool Indirect =
false;
95 case DW_FORM_block1: {
96 uint8_t
size = DebugInfoData.
getU8(OffsetPtr);
100 case DW_FORM_block2: {
101 uint16_t
size = DebugInfoData.
getU16(OffsetPtr);
105 case DW_FORM_block4: {
113 DebugInfoData.
getCStr(OffsetPtr);
117 case DW_FORM_ref_addr:
118 case DW_FORM_flag_present:
129 case DW_FORM_ref_sig8:
130 case DW_FORM_ref_sup4:
131 case DW_FORM_ref_sup8:
138 case DW_FORM_sec_offset:
140 case DW_FORM_strp_sup:
141 case DW_FORM_line_strp:
142 case DW_FORM_GNU_ref_alt:
143 case DW_FORM_GNU_strp_alt:
146 *OffsetPtr += *FixedSize;
157 case DW_FORM_ref_udata:
160 case DW_FORM_loclistx:
161 case DW_FORM_rnglistx:
162 case DW_FORM_GNU_addr_index:
163 case DW_FORM_GNU_str_index:
167 case DW_FORM_indirect:
186 case DW_FORM_GNU_ref_alt:
187 return (FC == FC_Reference);
188 case DW_FORM_GNU_addr_index:
189 return (FC == FC_Address);
190 case DW_FORM_GNU_str_index:
191 case DW_FORM_GNU_strp_alt:
192 return (FC == FC_String);
200 return (
Form == DW_FORM_data4 ||
Form == DW_FORM_data8 ||
201 Form == DW_FORM_strp ||
Form == DW_FORM_line_strp) &&
202 FC == FC_SectionOffset;
213 bool Indirect =
false;
214 bool IsBlock =
false;
215 Value.data =
nullptr;
222 case DW_FORM_ref_addr: {
228 case DW_FORM_exprloc:
263 case DW_FORM_ref_sup4:
270 case DW_FORM_ref_sup8:
282 case DW_FORM_ref_udata:
283 case DW_FORM_rnglistx:
289 case DW_FORM_indirect:
294 case DW_FORM_sec_offset:
295 case DW_FORM_GNU_ref_alt:
296 case DW_FORM_GNU_strp_alt:
297 case DW_FORM_line_strp:
298 case DW_FORM_strp_sup: {
303 case DW_FORM_flag_present:
306 case DW_FORM_ref_sig8:
309 case DW_FORM_GNU_addr_index:
310 case DW_FORM_GNU_str_index:
324 Value.data =
nullptr;
326 Value.data =
reinterpret_cast<const uint8_t *
>(Str.
data());
327 *OffsetPtr +=
Value.uval;
338 dumpAddressSection(U->getContext().getDWARFObj(), OS, DumpOpts,
344 uint64_t SectionIndex) {
345 if (!DumpOpts.
Verbose || SectionIndex == -1ULL)
348 const auto &SecRef = SectionNames[SectionIndex];
350 OS <<
" \"" << SecRef.Name <<
'\"';
353 if (!SecRef.IsNameUnique)
354 OS <<
format(
" [%" PRIu64
"]", SectionIndex);
358 uint64_t UValue =
Value.uval;
359 bool CURelativeOffset =
false;
365 dumpSectionedAddress(AddrOS, DumpOpts, {
Value.uval,
Value.SectionIndex});
372 case DW_FORM_GNU_addr_index: {
377 OS <<
"<invalid dwarf unit>";
379 dumpSectionedAddress(AddrOS, DumpOpts, *A);
381 OS <<
"<no .debug_addr section>";
384 case DW_FORM_flag_present:
389 OS <<
format(
"0x%02x", (uint8_t)UValue);
392 OS <<
format(
"0x%04x", (uint16_t)UValue);
397 case DW_FORM_ref_sig8:
398 AddrOS <<
format(
"0x%016" PRIx64, UValue);
401 OS <<
format(
"0x%016" PRIx64, UValue);
404 OS << format_bytes(ArrayRef<uint8_t>(
Value.data, 16),
None, 16, 16);
411 case DW_FORM_exprloc:
418 case DW_FORM_exprloc:
420 AddrOS <<
format(
"<0x%" PRIx64
"> ", UValue);
423 AddrOS <<
format(
"<0x%2.2x> ", (uint8_t)UValue);
426 AddrOS <<
format(
"<0x%4.4x> ", (uint16_t)UValue);
435 const uint8_t *DataPtr =
Value.data;
438 const uint8_t *EndDataPtr = DataPtr + UValue;
439 while (DataPtr < EndDataPtr) {
440 AddrOS <<
format(
"%2.2x ", *DataPtr);
459 case DW_FORM_line_strp:
469 case DW_FORM_GNU_str_index:
474 case DW_FORM_GNU_strp_alt:
476 OS <<
format(
"alt indirect string, offset: 0x%" PRIx64
"", UValue);
479 case DW_FORM_ref_addr:
480 AddrOS <<
format(
"0x%016" PRIx64, UValue);
483 CURelativeOffset =
true;
485 AddrOS <<
format(
"cu + 0x%2.2x", (uint8_t)UValue);
488 CURelativeOffset =
true;
490 AddrOS <<
format(
"cu + 0x%4.4x", (uint16_t)UValue);
493 CURelativeOffset =
true;
498 CURelativeOffset =
true;
500 AddrOS <<
format(
"cu + 0x%8.8" PRIx64, UValue);
502 case DW_FORM_ref_udata:
503 CURelativeOffset =
true;
505 AddrOS <<
format(
"cu + 0x%" PRIx64, UValue);
507 case DW_FORM_GNU_ref_alt:
508 AddrOS <<
format(
"<alt 0x%" PRIx64
">", UValue);
513 case DW_FORM_indirect:
514 OS <<
"DW_FORM_indirect";
517 case DW_FORM_rnglistx:
522 case DW_FORM_sec_offset:
531 if (CURelativeOffset) {
536 <<
format(
"0x%8.8" PRIx64, UValue + (U ? U->getOffset() : 0));
542 void DWARFFormValue::dumpString(
raw_ostream &OS)
const {
547 COS.get().write_escaped(DbgStr.
getValue());
553 if (!isFormClass(FC_String))
555 if (
Form == DW_FORM_string)
558 if (
Form == DW_FORM_GNU_strp_alt ||
C ==
nullptr)
561 if (
Form == DW_FORM_line_strp) {
563 if (
const char *Str =
C->getLineStringExtractor().getCStr(&Offset))
567 if (
Form == DW_FORM_GNU_str_index ||
Form == DW_FORM_strx ||
568 Form == DW_FORM_strx1 ||
Form == DW_FORM_strx2 ||
Form == DW_FORM_strx3 ||
569 Form == DW_FORM_strx4) {
580 if (
const char *Str = U->getStringExtractor().getCStr(&Offset))
584 if (
const char *Str =
C->getStringExtractor().getCStr(&Offset))
590 if (
auto SA = getAsSectionedAddress())
595 if (!isFormClass(FC_Address))
597 if (
Form == DW_FORM_GNU_addr_index ||
Form == DW_FORM_addrx) {
610 if (!isFormClass(FC_Reference))
617 case DW_FORM_ref_udata:
620 return Value.uval + U->getOffset();
621 case DW_FORM_ref_addr:
622 case DW_FORM_ref_sig8:
623 case DW_FORM_GNU_ref_alt:
631 if (!isFormClass(FC_SectionOffset))
637 if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) ||
638 Form == DW_FORM_sdata)
644 if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) ||
645 (
Form == DW_FORM_udata &&
650 return int32_t(
Value.uval);
652 return int16_t(
Value.uval);
654 return int8_t(
Value.uval);
663 if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc) &&
664 Form != DW_FORM_data16)
670 if (!isFormClass(FC_String) &&
Form == DW_FORM_string)
676 if (!isFormClass(FC_Reference))
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents lattice values for constants.
An RAII object that temporarily switches an output stream to a specific color.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
const T & getValue() const LLVM_LVALUE_FUNCTION
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Container for dump options that control which debug information will be dumped.
DWARFContext & getContext() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an escape...
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
This file contains constants used for implementing Dwarf debug support.
Optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
virtual ArrayRef< SectionName > getSectionNames() const
LLVM Value Representation.
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.