Lines Matching full:dwarf
1 //===-- llvm/CodeGen/DwarfDebug.cpp - Dwarf Debug Framework ---------------===//
10 // This file contains support for writing dwarf debug info into asm files.
38 #include "llvm/Support/Dwarf.h"
64 GenerateGnuPubSections("generate-gnu-dwarf-pub-sections", cl::Hidden,
70 cl::desc("Generate dwarf aranges"),
78 DwarfAccelTables("dwarf-accel-tables", cl::Hidden,
79 cl::desc("Output prototype dwarf accelerator tables."),
86 SplitDwarf("split-dwarf", cl::Hidden,
94 DwarfPubSections("generate-dwarf-pub-sections", cl::Hidden,
95 cl::desc("Generate DWARF pubnames and pubtypes sections"),
101 static const char *const DWARFGroupName = "DWARF Emission";
102 static const char *const DbgTimerName = "DWARF Debug Writer";
149 if (tag == dwarf::DW_TAG_pointer_type)
163 DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4),
164 DwarfAccelTable::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2),
165 DwarfAccelTable::Atom(dwarf::DW_ATOM_type_flags, dwarf::DW_FORM_data1)};
172 AccelNames(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
173 dwarf::DW_FORM_data4)),
174 AccelObjC(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
175 dwarf::DW_FORM_data4)),
176 AccelNamespace(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
177 dwarf::DW_FORM_data4)),
190 // default for non-Darwin, and handle split dwarf.
271 // Add the various names to the Dwarf accelerator table names.
322 SPCU.addAddress(*SPDie, dwarf::DW_AT_frame_base, Location);
353 dwarf::Attribute A, const MCSymbol *L,
370 TheCU.addSectionDelta(ScopeDIE, dwarf::DW_AT_ranges, RangeSym,
373 addSectionLabel(*Asm, TheCU, ScopeDIE, dwarf::DW_AT_ranges, RangeSym,
404 auto ScopeDIE = make_unique<DIE>(dwarf::DW_TAG_lexical_block);
426 auto ScopeDIE = make_unique<DIE>(dwarf::DW_TAG_inlined_subroutine);
427 TheCU.addDIEEntry(*ScopeDIE, dwarf::DW_AT_abstract_origin, *OriginDIE);
435 TheCU.addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None,
437 TheCU.addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, DL.getLineNumber());
474 make_unique<DIE>(dwarf::DW_TAG_unspecified_parameters));
493 TheCU.addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
531 AbsDef = &SPCU.createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE,
535 SPCU.addUInt(*AbsDef, dwarf::DW_AT_inline, None, dwarf::DW_INL_inlined);
618 U.addFlag(D, dwarf::DW_AT_GNU_pubnames);
641 NewCU.addString(Die, dwarf::DW_AT_producer, DIUnit.getProducer());
642 NewCU.addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
644 NewCU.addString(Die, dwarf::DW_AT_name, FN);
649 // If we're using split dwarf the compilation dir is going to be in the
652 NewCU.addString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
658 NewCU.addFlag(Die, dwarf::DW_AT_APPLE_optimized);
662 NewCU.addString(Die, dwarf::DW_AT_APPLE_flags, Flags);
665 NewCU.addUInt(Die, dwarf::DW_AT_APPLE_major_runtime_vers,
666 dwarf::DW_FORM_data1, RVer);
718 TheCU.addDIEEntry(IMDie, dwarf::DW_AT_import, *EntityDie);
721 TheCU.addString(IMDie, dwarf::DW_AT_name, Name);
724 // Emit all Dwarf sections that should come prior to the content. Create
800 Unit->addDIEEntry(*VariableDie, dwarf::DW_AT_abstract_origin,
827 SPCU->addDIEEntry(*D, dwarf::DW_AT_abstract_origin, *AbsSPDIE);
898 if (TheU->getUnitDie().getTag() == dwarf::DW_TAG_compile_unit) {
899 // If we're splitting the dwarf out now that we've got the entire
906 TheU->addUInt(TheU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
907 dwarf::DW_FORM_data8, ID);
908 SkCU->addUInt(SkCU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
909 dwarf::DW_FORM_data8, ID);
915 dwarf::DW_AT_GNU_addr_base, DwarfAddrSectionSym,
919 dwarf::DW_AT_GNU_ranges_base,
934 addSectionLabel(*Asm, U, U.getUnitDie(), dwarf::DW_AT_ranges,
942 U.addUInt(U.getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
946 U.addLocalLabelAddress(U.getUnitDie(), dwarf::DW_AT_low_pc,
948 U.addLabelDelta(U.getUnitDie(), dwarf::DW_AT_high_pc, Range.getEnd(),
1008 // Emit all Dwarf sections that should come after the content.
1050 // Emit info into the dwarf accelerator table sections.
1125 if (DV.getTag() != dwarf::DW_TAG_arg_variable)
1209 if (DV.getTag() == dwarf::DW_TAG_arg_variable &&
1472 if (DV.isVariable() && DV.getTag() == dwarf::DW_TAG_arg_variable &&
1588 TheCU.addFlag(CurFnDIE, dwarf::DW_AT_APPLE_omit_frame_ptr);
1636 // Emit initial Dwarf sections with a label at the start of each one.
1640 // Dwarf sections base addresses.
1692 dwarf::TagString(Abbrev.getTag()));
1700 dwarf::Attribute Attr = AbbrevData[i].getAttribute();
1701 dwarf::Form Form = AbbrevData[i].getForm();
1705 Asm->OutStreamer.AddComment(dwarf::AttributeString(Attr));
1706 if (Attr == dwarf::DW_AT_accessibility)
1707 Asm->OutStreamer.AddComment(dwarf::AccessibilityString(
1748 Asm->EmitInt8(dwarf::DW_LNE_set_address);
1816 // dwarf pubnames - offset/name pairs where the offset is the offset into the CU
1823 // For type units the offset is the offset of the skeleton DIE. For split dwarf
1828 static dwarf::PubIndexEntryDescriptor computeIndexValue(DwarfUnit *CU,
1830 dwarf::GDBIndexEntryLinkage Linkage = dwarf::GIEL_STATIC;
1834 DIEValue *SpecVal = Die->findAttribute(dwarf::DW_AT_specification);
1837 if (SpecDIE.findAttribute(dwarf::DW_AT_external))
1838 Linkage = dwarf::GIEL_EXTERNAL;
1839 } else if (Die->findAttribute(dwarf::DW_AT_external))
1840 Linkage = dwarf::GIEL_EXTERNAL;
1843 case dwarf::DW_TAG_class_type:
1844 case dwarf::DW_TAG_structure_type:
1845 case dwarf::DW_TAG_union_type:
1846 case dwarf::DW_TAG_enumeration_type:
1847 return dwarf::PubIndexEntryDescriptor(
1848 dwarf::GIEK_TYPE, CU->getLanguage() != dwarf::DW_LANG_C_plus_plus
1849 ? dwarf::GIEL_STATIC
1850 : dwarf::GIEL_EXTERNAL);
1851 case dwarf::DW_TAG_typedef:
1852 case dwarf::DW_TAG_base_type:
1853 case dwarf::DW_TAG_subrange_type:
1854 return dwarf::PubIndexEntryDescriptor(dwarf::GIEK_TYPE, dwarf::GIEL_STATIC);
1855 case dwarf::DW_TAG_namespace:
1856 return dwarf::GIEK_TYPE;
1857 case dwarf::DW_TAG_subprogram:
1858 return dwarf::PubIndexEntryDescriptor(dwarf::GIEK_FUNCTION, Linkage);
1859 case dwarf::DW_TAG_constant:
1860 case dwarf::DW_TAG_variable:
1861 return dwarf::PubIndexEntryDescriptor(dwarf::GIEK_VARIABLE, Linkage);
1862 case dwarf::DW_TAG_enumerator:
1863 return dwarf::PubIndexEntryDescriptor(dwarf::GIEK_VARIABLE,
1864 dwarf::GIEL_STATIC);
1866 return dwarf::GIEK_NONE;
1895 // Start the dwarf pubnames section.
1906 Asm->OutStreamer.AddComment("DWARF Version");
1907 Asm->EmitInt16(dwarf::DW_PUBNAMES_VERSION);
1924 dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheU, Entity);
1926 Twine("Kind: ") + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
1927 dwarf::GDBIndexEntryLinkageString(Desc.Linkage));
1963 if (BTy.Verify() && (BTy.getEncoding() == dwarf::DW_ATE_signed ||
1964 BTy.getEncoding() == dwarf::DW_ATE_signed_char)) {
1965 Streamer.EmitInt8(dwarf::DW_OP_consts, "DW_OP_consts");
1968 Streamer.EmitInt8(dwarf::DW_OP_constu, "DW_OP_constu");
1984 Streamer.EmitInt8(dwarf::DW_OP_deref, "DW_OP_deref");
1985 Streamer.EmitInt8(dwarf::DW_OP_plus_uconst, "DW_OP_plus_uconst");
2002 Streamer.EmitInt8(dwarf::DW_OP_plus_uconst, "DW_OP_plus_uconst");
2006 Streamer.EmitInt8(dwarf::DW_OP_deref, "DW_OP_deref");
2013 // to represent them here in dwarf.
2032 // Start the dwarf loc section.
2070 Asm->EmitInt8(dwarf::DW_LLE_start_length_entry);
2077 Asm->EmitInt8(dwarf::DW_LLE_end_of_list_entry);
2088 // Start the dwarf aranges section.
2177 sizeof(int16_t) + // DWARF ARange version number
2184 // 7.20 in the Dwarf specs requires the table to be aligned to a tuple.
2194 Asm->OutStreamer.AddComment("DWARF Arange version number");
2195 Asm->EmitInt16(dwarf::DW_ARANGES_VERSION);
2230 // Start the dwarf ranges section.
2286 // DWARF5 Experimental Separate Dwarf emitters.
2290 NewU->addLocalString(Die, dwarf::DW_AT_GNU_dwo_name,
2294 NewU->addLocalString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
2337 // Emit the .debug_info.dwo section for separated dwarf. This contains the
2340 assert(useSplitDwarf() && "No split dwarf debug info?");
2346 // Emit the .debug_abbrev.dwo section for separated dwarf. This contains the
2349 assert(useSplitDwarf() && "No split dwarf?");
2354 assert(useSplitDwarf() && "No split dwarf?");
2360 // Emit the .debug_str.dwo section for separated dwarf. This contains the
2364 assert(useSplitDwarf() && "No split dwarf?");
2418 NewTU.addUInt(UnitDie, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
2476 Unit.addLabelAddress(D, dwarf::DW_AT_low_pc, Begin);
2478 Unit.addLabelAddress(D, dwarf::DW_AT_high_pc, End);
2480 Unit.addLabelDelta(D, dwarf::DW_AT_high_pc, End, Begin);