Lines Matching +full:form +full:- +full:data
1 //===- DWARFFormValue.cpp -------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
38 // --- These can be FC_SectionOffset in DWARF3 and below:
41 // ---
82 DWARFFormValue DWARFFormValue::createFromSValue(dwarf::Form F, int64_t V) {
86 DWARFFormValue DWARFFormValue::createFromUValue(dwarf::Form F, uint64_t V) {
90 DWARFFormValue DWARFFormValue::createFromPValue(dwarf::Form F, const char *V) {
94 DWARFFormValue DWARFFormValue::createFromBlockValue(dwarf::Form F,
98 V.data = D.data();
102 DWARFFormValue DWARFFormValue::createFromUnit(dwarf::Form F, const DWARFUnit *U,
105 FormValue.extractValue(U->getDebugInfoExtractor(), OffsetPtr,
106 U->getFormParams(), U);
110 bool DWARFFormValue::skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
115 switch (Form) {
116 // Blocks of inlined data that have a length field and the data bytes
140 // Inlined NULL terminated C-strings.
177 dwarf::getFixedFormByteSize(Form, Params)) {
206 Form = static_cast<dwarf::Form>(DebugInfoData.getULEB128(OffsetPtr));
217 return doesFormBelongToClass(Form, FC, U ? U->getVersion() : 3);
220 bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data,
225 Ctx = &CU->getContext();
231 Value.data = nullptr;
232 // Read the value for the form into value and follow and DW_FORM_indirect
237 switch (Form) {
241 (Form == DW_FORM_addr) ? FP.AddrSize : FP.getRefAddrByteSize();
243 Data.getRelocatedValue(Size, OffsetPtr, &Value.SectionIndex, &Err);
248 Value.uval = Data.getULEB128(OffsetPtr, &Err);
252 Value.uval = Data.getU8(OffsetPtr, &Err);
256 Value.uval = Data.getU16(OffsetPtr, &Err);
260 Value.uval = Data.getU32(OffsetPtr, &Err);
268 Value.uval = Data.getU8(OffsetPtr, &Err);
274 Value.uval = Data.getU16(OffsetPtr, &Err);
278 Value.uval = Data.getU24(OffsetPtr, &Err);
285 Value.uval = Data.getRelocatedValue(4, OffsetPtr, nullptr, &Err);
290 Value.uval = Data.getRelocatedValue(8, OffsetPtr, nullptr, &Err);
293 // Treat this like a 16-byte block.
298 Value.sval = Data.getSLEB128(OffsetPtr, &Err);
308 Value.uval = Data.getULEB128(OffsetPtr, &Err);
311 Value.uval = Data.getULEB128(OffsetPtr, &Err) << 32;
312 Value.uval |= Data.getU32(OffsetPtr, &Err);
315 Value.cstr = Data.getCStr(OffsetPtr, &Err);
318 Form = static_cast<dwarf::Form>(Data.getULEB128(OffsetPtr, &Err));
327 Value.uval = Data.getRelocatedValue(FP.getDwarfOffsetByteSize(),
335 Value.uval = Data.getU64(OffsetPtr, &Err);
343 llvm_unreachable("unsupported form");
348 Value.data = Data.getBytes(OffsetPtr, Value.uval, &Err).bytes_begin();
362 dumpAddress(OS, U->getAddressByteSize(), SA.Address);
363 dumpAddressSection(U->getContext().getDWARFObj(), OS, DumpOpts,
370 if (!DumpOpts.Verbose || SectionIndex == -1ULL)
389 switch (Form) {
406 if (Form == DW_FORM_LLVM_addrx_offset) {
439 OS << format_bytes(ArrayRef<uint8_t>(Value.data, 16), std::nullopt, 16, 16);
452 switch (Form) {
470 const uint8_t *DataPtr = Value.data;
567 OS << format("DW_FORM(0x%4.4x)", Form);
576 << format("0x%8.8" PRIx64, UValue + (U ? U->getOffset() : 0));
593 return make_error<StringError>("Invalid form for string attribute",
595 if (Form == DW_FORM_string)
598 if (Form == DW_FORM_GNU_strp_alt || C == nullptr)
599 return make_error<StringError>("Unsupported form for string attribute",
603 if (Form == DW_FORM_GNU_str_index || Form == DW_FORM_strx ||
604 Form == DW_FORM_strx1 || Form == DW_FORM_strx2 || Form == DW_FORM_strx3 ||
605 Form == DW_FORM_strx4) {
607 return make_error<StringError>("API limitation - string extraction not "
610 Expected<uint64_t> StrOffset = U->getStringOffsetSectionItem(Offset);
618 bool IsDebugLineString = Form == DW_FORM_line_strp;
620 IsDebugLineString ? C->getLineStringExtractor()
621 : U ? U->getStringExtractor() : C->getStringExtractor();
624 std::string Msg = FormEncodingString(Form).str();
636 return SA->Address;
641 const ValueType &Value, const dwarf::Form Form, const DWARFUnit *U) {
642 if (!doesFormBelongToClass(Form, FC_Address, U ? U->getVersion() : 3))
644 bool AddrOffset = Form == dwarf::DW_FORM_LLVM_addrx_offset;
645 if (Form == DW_FORM_GNU_addr_index || Form == DW_FORM_addrx ||
646 Form == DW_FORM_addrx1 || Form == DW_FORM_addrx2 ||
647 Form == DW_FORM_addrx3 || Form == DW_FORM_addrx4 || AddrOffset) {
653 U->getAddrOffsetSectionItem(Index);
657 SA->Address += (Value.uval & 0xffffffff);
665 return getAsSectionedAddress(Value, Form, U);
669 switch (Form) {
684 if (Form == DW_FORM_ref_addr)
690 if (Form == DW_FORM_ref_sig8)
696 switch (Form) {
714 Form == DW_FORM_sdata)
721 (Form == DW_FORM_udata &&
724 switch (Form) {
740 Form != DW_FORM_data16)
742 return ArrayRef(Value.data, Value.uval);
746 if (!isFormClass(FC_String) && Form == DW_FORM_string)
761 DWARFUnit *DLU = const_cast<DWARFUnit *>(U)->getLinkedUnit();
762 if (auto *LT = DLU->getContext().getLineTableForUnit(DLU)) {
764 if (LT->getFileNameByIndex(Value.uval, DLU->getCompilationDir(), Kind,
771 bool llvm::dwarf::doesFormBelongToClass(dwarf::Form Form, DWARFFormValue::FormClass FC,
773 // First, check DWARF5 form classes.
774 if (Form < std::size(DWARF5FormClasses) && DWARF5FormClasses[Form] == FC)
777 switch (Form) {