27 using namespace dwarf;
101 uint64_t *OffsetPtr) {
111 bool Indirect =
false;
116 case DW_FORM_exprloc:
117 case DW_FORM_block: {
122 case DW_FORM_block1: {
123 uint8_t
size = DebugInfoData.
getU8(OffsetPtr);
127 case DW_FORM_block2: {
132 case DW_FORM_block4: {
140 DebugInfoData.
getCStr(OffsetPtr);
144 case DW_FORM_ref_addr:
145 case DW_FORM_flag_present:
156 case DW_FORM_ref_sig8:
157 case DW_FORM_ref_sup4:
158 case DW_FORM_ref_sup8:
165 case DW_FORM_sec_offset:
167 case DW_FORM_strp_sup:
168 case DW_FORM_line_strp:
169 case DW_FORM_GNU_ref_alt:
170 case DW_FORM_GNU_strp_alt:
173 *OffsetPtr += *FixedSize;
184 case DW_FORM_ref_udata:
187 case DW_FORM_loclistx:
188 case DW_FORM_rnglistx:
189 case DW_FORM_GNU_addr_index:
190 case DW_FORM_GNU_str_index:
194 case DW_FORM_indirect:
213 case DW_FORM_GNU_ref_alt:
214 return (FC == FC_Reference);
215 case DW_FORM_GNU_addr_index:
216 return (FC == FC_Address);
217 case DW_FORM_GNU_str_index:
218 case DW_FORM_GNU_strp_alt:
219 return (FC == FC_String);
224 if (FC == FC_SectionOffset) {
225 if (
Form == DW_FORM_strp ||
Form == DW_FORM_line_strp)
229 if (
Form == DW_FORM_data4 ||
Form == DW_FORM_data8)
230 return !U || U->getVersion() <= 3;
244 bool Indirect =
false;
245 bool IsBlock =
false;
246 Value.data =
nullptr;
253 case DW_FORM_ref_addr: {
259 case DW_FORM_exprloc:
294 case DW_FORM_ref_sup4:
301 case DW_FORM_ref_sup8:
313 case DW_FORM_ref_udata:
314 case DW_FORM_rnglistx:
315 case DW_FORM_loclistx:
321 case DW_FORM_indirect:
326 case DW_FORM_sec_offset:
327 case DW_FORM_GNU_ref_alt:
328 case DW_FORM_GNU_strp_alt:
329 case DW_FORM_line_strp:
330 case DW_FORM_strp_sup: {
335 case DW_FORM_flag_present:
338 case DW_FORM_ref_sig8:
341 case DW_FORM_GNU_addr_index:
342 case DW_FORM_GNU_str_index:
356 Value.data =
nullptr;
359 *OffsetPtr +=
Value.uval;
370 dumpAddressSection(U->getContext().getDWARFObj(), OS, DumpOpts,
376 uint64_t SectionIndex) {
377 if (!DumpOpts.
Verbose || SectionIndex == -1ULL)
380 const auto &SecRef = SectionNames[SectionIndex];
382 OS <<
" \"" << SecRef.Name <<
'\"';
385 if (!SecRef.IsNameUnique)
386 OS <<
format(
" [%" PRIu64
"]", SectionIndex);
390 uint64_t UValue =
Value.uval;
391 bool CURelativeOffset =
false;
397 dumpSectionedAddress(AddrOS, DumpOpts, {
Value.uval,
Value.SectionIndex});
404 case DW_FORM_GNU_addr_index: {
406 OS <<
"<invalid dwarf unit>";
413 dumpSectionedAddress(AddrOS, DumpOpts, *A);
415 OS <<
"<unresolved>";
418 case DW_FORM_flag_present:
423 OS <<
format(
"0x%02x", (uint8_t)UValue);
431 case DW_FORM_ref_sig8:
432 AddrOS <<
format(
"0x%016" PRIx64, UValue);
435 OS <<
format(
"0x%016" PRIx64, UValue);
438 OS << format_bytes(ArrayRef<uint8_t>(
Value.data, 16),
None, 16, 16);
445 case DW_FORM_exprloc:
452 case DW_FORM_exprloc:
454 AddrOS <<
format(
"<0x%" PRIx64
"> ", UValue);
457 AddrOS <<
format(
"<0x%2.2x> ", (uint8_t)UValue);
469 const uint8_t *DataPtr =
Value.data;
472 const uint8_t *EndDataPtr = DataPtr + UValue;
473 while (DataPtr < EndDataPtr) {
474 AddrOS <<
format(
"%2.2x ", *DataPtr);
493 case DW_FORM_line_strp:
503 case DW_FORM_GNU_str_index:
508 case DW_FORM_GNU_strp_alt:
510 OS <<
format(
"alt indirect string, offset: 0x%" PRIx64
"", UValue);
513 case DW_FORM_ref_addr:
514 AddrOS <<
format(
"0x%016" PRIx64, UValue);
517 CURelativeOffset =
true;
519 AddrOS <<
format(
"cu + 0x%2.2x", (uint8_t)UValue);
522 CURelativeOffset =
true;
527 CURelativeOffset =
true;
532 CURelativeOffset =
true;
534 AddrOS <<
format(
"cu + 0x%8.8" PRIx64, UValue);
536 case DW_FORM_ref_udata:
537 CURelativeOffset =
true;
539 AddrOS <<
format(
"cu + 0x%" PRIx64, UValue);
541 case DW_FORM_GNU_ref_alt:
542 AddrOS <<
format(
"<alt 0x%" PRIx64
">", UValue);
547 case DW_FORM_indirect:
548 OS <<
"DW_FORM_indirect";
551 case DW_FORM_rnglistx:
555 case DW_FORM_loclistx:
560 case DW_FORM_sec_offset:
569 if (CURelativeOffset) {
574 <<
format(
"0x%8.8" PRIx64, UValue + (U ? U->getOffset() : 0));
580 void DWARFFormValue::dumpString(
raw_ostream &OS)
const {
585 COS.get().write_escaped(DbgStr.
getValue());
591 if (!isFormClass(FC_String))
593 if (
Form == DW_FORM_string)
596 if (
Form == DW_FORM_GNU_strp_alt ||
C ==
nullptr)
599 if (
Form == DW_FORM_line_strp) {
601 if (
const char *Str =
C->getLineStringExtractor().getCStr(&Offset))
605 if (
Form == DW_FORM_GNU_str_index ||
Form == DW_FORM_strx ||
606 Form == DW_FORM_strx1 ||
Form == DW_FORM_strx2 ||
Form == DW_FORM_strx3 ||
607 Form == DW_FORM_strx4) {
618 if (
const char *Str = U->getStringExtractor().getCStr(&Offset))
622 if (
const char *Str =
C->getStringExtractor().getCStr(&Offset))
628 if (
auto SA = getAsSectionedAddress())
635 if (!isFormClass(FC_Address))
637 if (
Form == DW_FORM_GNU_addr_index ||
Form == DW_FORM_addrx) {
650 if (
auto R = getAsRelativeReference())
651 return R->Unit ? R->Unit->getOffset() + R->Offset : R->Offset;
656 if (!isFormClass(FC_Reference))
663 case DW_FORM_ref_udata:
667 case DW_FORM_ref_addr:
668 case DW_FORM_ref_sig8:
669 case DW_FORM_GNU_ref_alt:
677 if (!isFormClass(FC_SectionOffset))
683 if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) ||
684 Form == DW_FORM_sdata)
690 if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) ||
691 (
Form == DW_FORM_udata &&
696 return int32_t(
Value.uval);
698 return int16_t(
Value.uval);
700 return int8_t(
Value.uval);
709 if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc) &&
710 Form != DW_FORM_data16)
716 if (!isFormClass(FC_String) &&
Form == DW_FORM_string)
722 if (!isFormClass(FC_Reference))
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
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.
const dwarf::FormParams & getFormParams() const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
const T & getValue() const LLVM_LVALUE_FUNCTION
Container for dump options that control which debug information will be dumped.
size_t size() const
size - Get the array size.
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.
Align max(MaybeAlign Lhs, Align Rhs)
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This file contains constants used for implementing Dwarf debug support.
DWARFDataExtractor getDebugInfoExtractor() const
Optional< uint8_t > getFixedFormByteSize(dwarf::Form Form, FormParams Params)
Get the fixed byte size for a given form.
const unsigned char * bytes_begin() const
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.