Lines Matching refs:dwarf

9 // This file contains support for constructing a dwarf compile unit.
60 static dwarf::Tag GetCompileUnitType(UnitKind Kind, DwarfDebug *DW) {
68 return dwarf::DW_TAG_skeleton_unit;
70 return dwarf::DW_TAG_compile_unit;
81 /// addLabelAddress - Add a dwarf label attribute data and value using
83 void DwarfCompileUnit::addLabelAddress(DIE &Die, dwarf::Attribute Attribute,
102 DD->getDwarfVersion() >= 5 ? dwarf::DW_FORM_addrx
103 : dwarf::DW_FORM_GNU_addr_index,
116 addBlock(Die, Attribute, dwarf::DW_FORM_exprloc, Loc);
118 addAttribute(Die, Attribute, dwarf::DW_FORM_LLVM_addrx_offset,
124 dwarf::Attribute Attribute,
127 addAttribute(Die, Attribute, dwarf::DW_FORM_addr, DIELabel(Label));
129 addAttribute(Die, Attribute, dwarf::DW_FORM_addr, DIEInteger(0));
176 addDIEEntry(*VariableDIE, dwarf::DW_AT_specification, *VariableSpecDIE);
186 addString(*VariableDIE, dwarf::DW_AT_name, GV->getDisplayName());
192 addFlag(*VariableDIE, dwarf::DW_AT_external);
199 addFlag(*VariableDIE, dwarf::DW_AT_declaration);
206 addUInt(*VariableDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
263 // https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
289 dwarf::Form Form;
290 dwarf::LocationAtom Op;
293 ? FormAndOp{dwarf::DW_FORM_data4, dwarf::DW_OP_const4u}
294 : FormAndOp{dwarf::DW_FORM_data8, dwarf::DW_OP_const8u};
305 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
309 // FIXME: Make this work with -gsplit-dwarf.
314 addUInt(*Loc, dwarf::DW_FORM_data1, FormAndOp.Op);
320 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_const_index);
321 addUInt(*Loc, dwarf::DW_FORM_udata,
325 addUInt(*Loc, dwarf::DW_FORM_data1,
326 DD->useGNUTLSOpcode() ? dwarf::DW_OP_GNU_push_tls_address
327 : dwarf::DW_OP_form_tls_address);
336 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
344 addUInt(*Loc, dwarf::DW_FORM_data1, FormAndOp.Op);
351 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + BaseReg);
353 addSInt(*Loc, dwarf::DW_FORM_sdata, 0);
355 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
371 // https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
375 addUInt(*VariableDIE, dwarf::DW_AT_address_class, dwarf::DW_FORM_data1,
379 addBlock(*VariableDIE, dwarf::DW_AT_location, DwarfExpr->finalize());
403 DIE &NDie = createAndAddDIE(dwarf::DW_TAG_common_block, *ContextDIE, CB);
405 addString(NDie, dwarf::DW_AT_name, Name);
450 // compile unit in debug_line section. For split dwarf this is
454 addSectionLabel(getUnitDie(), dwarf::DW_AT_stmt_list, LineTableStartSym,
460 addSectionLabel(D, dwarf::DW_AT_stmt_list, LineTableStartSym,
471 addLabelAddress(D, dwarf::DW_AT_low_pc, Begin);
473 addLabelAddress(D, dwarf::DW_AT_high_pc, End);
475 addLabelDelta(D, dwarf::DW_AT_high_pc, End, Begin);
479 // 'GlobalIndex' is used for split dwarf, which currently relies on a few
496 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_WASM_location);
497 addSInt(*Loc, dwarf::DW_FORM_sdata, TI_GLOBAL_RELOC);
499 addLabel(*Loc, dwarf::DW_FORM_data4, Sym);
507 addUInt(*Loc, dwarf::DW_FORM_data4, GlobalIndex);
527 addFlag(*SPDie, dwarf::DW_AT_APPLE_omit_frame_ptr);
538 addAddress(*SPDie, dwarf::DW_AT_frame_base, Location);
544 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_call_frame_cfa);
546 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_consts);
547 addSInt(*Loc, dwarf::DW_FORM_sdata, FrameBase.Location.Offset);
548 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
550 addBlock(*SPDie, dwarf::DW_AT_frame_base, Loc);
563 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
564 addBlock(*SPDie, dwarf::DW_AT_frame_base, Loc);
572 addBlock(*SPDie, dwarf::DW_AT_frame_base, DwarfExpr.finalize());
638 addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_rnglistx, Index);
644 addSectionDelta(ScopeDIE, dwarf::DW_AT_ranges, List.Label,
647 addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges, List.Label,
711 auto ScopeDIE = DIE::get(DIEValueAllocator, dwarf::DW_TAG_inlined_subroutine);
713 addDIEEntry(*ScopeDIE, dwarf::DW_AT_abstract_origin, *OriginDIE);
719 addUInt(*ScopeDIE, dwarf::DW_AT_call_file, std::nullopt,
721 addUInt(*ScopeDIE, dwarf::DW_AT_call_line, std::nullopt, IA->getLine());
723 addUInt(*ScopeDIE, dwarf::DW_AT_call_column, std::nullopt, IA->getColumn());
725 addUInt(*ScopeDIE, dwarf::DW_AT_GNU_discriminator, std::nullopt,
743 auto ScopeDIE = DIE::get(DIEValueAllocator, dwarf::DW_TAG_lexical_block);
794 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
796 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset,
797 dwarf::DW_FORM_data1, *DwarfExpr.TagOffset);
810 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
871 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
873 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
879 addLocationList(VariableDie, dwarf::DW_AT_location,
883 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
906 // https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
933 // https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
938 addUInt(VariableDie, dwarf::DW_AT_address_class, dwarf::DW_FORM_data1,
941 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
943 addUInt(VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
961 addBlock(VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
992 if (!Array || Array->getTag() != dwarf::DW_TAG_array_type)
1102 addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
1114 DIE::get(DIEValueAllocator, dwarf::DW_TAG_unspecified_parameters));
1195 DIE &AbsDef = ContextCU->createAndAddDIE(dwarf::DW_TAG_subprogram,
1202 ContextCU->addSInt(AbsDef, dwarf::DW_AT_inline,
1203 DD->getDwarfVersion() <= 4 ? std::optional<dwarf::Form>()
1204 : dwarf::DW_FORM_implicit_const,
1205 dwarf::DW_INL_inlined);
1207 ContextCU->addDIEEntry(AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);
1214 dwarf::Tag DwarfCompileUnit::getDwarf5OrGNUTag(dwarf::Tag Tag) const {
1218 case dwarf::DW_TAG_call_site:
1219 return dwarf::DW_TAG_GNU_call_site;
1220 case dwarf::DW_TAG_call_site_parameter:
1221 return dwarf::DW_TAG_GNU_call_site_parameter;
1227 dwarf::Attribute
1228 DwarfCompileUnit::getDwarf5OrGNUAttr(dwarf::Attribute Attr) const {
1232 case dwarf::DW_AT_call_all_calls:
1233 return dwarf::DW_AT_GNU_all_call_sites;
1234 case dwarf::DW_AT_call_target:
1235 return dwarf::DW_AT_GNU_call_site_target;
1236 case dwarf::DW_AT_call_origin:
1237 return dwarf::DW_AT_abstract_origin;
1238 case dwarf::DW_AT_call_return_pc:
1239 return dwarf::DW_AT_low_pc;
1240 case dwarf::DW_AT_call_value:
1241 return dwarf::DW_AT_GNU_call_site_value;
1242 case dwarf::DW_AT_call_tail_call:
1243 return dwarf::DW_AT_GNU_tail_call;
1249 dwarf::LocationAtom
1250 DwarfCompileUnit::getDwarf5OrGNULocationAtom(dwarf::LocationAtom Loc) const {
1254 case dwarf::DW_OP_entry_value:
1255 return dwarf::DW_OP_GNU_entry_value;
1268 DIE &CallSiteDIE = createAndAddDIE(getDwarf5OrGNUTag(dwarf::DW_TAG_call_site),
1273 addAddress(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_target),
1280 !CalleeDIE->findAttribute(dwarf::DW_AT_linkage_name)) {
1284 addDIEEntry(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_origin),
1290 addFlag(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_tail_call));
1305 addLabelAddress(CallSiteDIE, dwarf::DW_AT_call_pc, CallAddr);
1317 getDwarf5OrGNUAttr(dwarf::DW_AT_call_return_pc), PCAddr);
1329 getDwarf5OrGNUTag(dwarf::DW_TAG_call_site_parameter));
1331 addAddress(*CallSiteDieParam, dwarf::DW_AT_location,
1340 addBlock(*CallSiteDieParam, getDwarf5OrGNUAttr(dwarf::DW_AT_call_value),
1349 DIE *IMDie = DIE::get(DIEValueAllocator, (dwarf::Tag)Module->getTag());
1375 addDIEEntry(*IMDie, dwarf::DW_AT_import, *EntityDie);
1378 addString(*IMDie, dwarf::DW_AT_name, Name);
1421 addDIEEntry(*D, dwarf::DW_AT_abstract_origin, *AbsSPDIE);
1438 addDIEEntry(*Die, dwarf::DW_AT_abstract_origin, *AbsEntity->getDIE());
1456 addLabelAddress(*Die, dwarf::DW_AT_low_pc, Sym);
1493 dwarf::UnitType UT = Skeleton ? dwarf::DW_UT_split_compile
1494 : DD->useSplitDwarf() ? dwarf::DW_UT_skeleton
1495 : dwarf::DW_UT_compile;
1497 if (DD->getDwarfVersion() >= 5 && UT != dwarf::DW_UT_compile)
1566 addComplexAddress(Single->getExpr(), Die, dwarf::DW_AT_location, Location);
1568 addAddress(Die, dwarf::DW_AT_location, Location);
1572 void DwarfCompileUnit::addAddress(DIE &Die, dwarf::Attribute Attribute,
1589 addUInt(Die, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
1598 dwarf::Attribute Attribute,
1619 addUInt(Die, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
1624 void DwarfCompileUnit::addLocationList(DIE &Die, dwarf::Attribute Attribute,
1626 dwarf::Form Form = (DD->getDwarfVersion() >= 5)
1627 ? dwarf::DW_FORM_loclistx
1636 addString(VariableDie, dwarf::DW_AT_name, Name);
1640 addUInt(VariableDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1648 addFlag(VariableDie, dwarf::DW_AT_artificial);
1655 addString(LabelDie, dwarf::DW_AT_name, Name);
1661 void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form,
1663 addAttribute(Die, (dwarf::Attribute)0, Form, DIEExpr(Expr));
1691 DD->getDwarfVersion() >= 5 ? dwarf::DW_AT_addr_base
1692 : dwarf::DW_AT_GNU_addr_base,
1697 addAttribute(Die, (dwarf::Attribute)0, dwarf::DW_FORM_udata,
1708 DIE::get(DIEValueAllocator, dwarf::DW_TAG_base_type));
1710 addString(Die, dwarf::DW_AT_name,
1711 Twine(dwarf::AttributeEncodingString(Btr.Encoding) +
1713 addUInt(Die, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Btr.Encoding);
1715 addUInt(Die, dwarf::DW_AT_byte_size, std::nullopt,