14 #define DEBUG_TYPE "dwarfdebug"
54 cl::desc(
"Disable debug info printing"));
58 cl::desc(
"Make an absence of debug location information explicit."),
63 cl::desc(
"Add an ODR hash to external type DIEs."),
68 cl::desc(
"Add the CU hash as the dwo_id."),
73 cl::desc(
"Generate GNU-style pubnames and pubtypes"),
86 cl::desc(
"Output prototype dwarf accelerator tables."),
94 cl::desc(
"Output prototype dwarf split debug info."),
102 cl::desc(
"Generate DWARF pubnames and pubtypes sections"),
121 template <
typename T>
122 T DbgVariable::resolve(
DIRef<T> Ref)
const {
156 uint16_t tag = Ty.
getTag();
158 if (tag == dwarf::DW_TAG_pointer_type)
165 return (resolve(DT.getTypeDerivedFrom()));
177 return dwarf::DWARF_VERSION;
178 return cast<ConstantInt>(Val)->getZExtValue();
182 :
Asm(A), MMI(
Asm->MMI), FirstCU(0),
184 SourceIdMap(DIEValueAllocator),
185 PrevLabel(NULL), GlobalCUIndexCount(0),
186 InfoHolder(A, &AbbreviationsSet, Abbreviations,
"info_string",
189 SkeletonHolder(A, &SkeletonAbbrevSet, SkeletonAbbrevs,
"skel_string",
192 DwarfInfoSectionSym = DwarfAbbrevSectionSym = 0;
193 DwarfStrSectionSym = TextSectionSym = 0;
194 DwarfDebugRangeSectionSym = DwarfDebugLocSectionSym = DwarfLineSectionSym = 0;
195 DwarfAddrSectionSym = 0;
196 DwarfAbbrevDWOSectionSym = DwarfStrDWOSectionSym = 0;
197 FunctionBeginSym = FunctionEndSym = 0;
204 HasDwarfAccelTables = IsDarwin;
209 HasSplitDwarf =
false;
214 HasDwarfPubSections = !IsDarwin;
229 const char *SymbolStem = 0) {
231 if (!SymbolStem)
return 0;
243 std::pair<MCSymbol*, unsigned> &Entry =
245 if (Entry.first)
return Entry.first;
247 Entry.second = NextStringPoolNumber++;
248 return Entry.first = Asm->
GetTempSymbol(StringPref, Entry.second);
252 std::pair<MCSymbol*, unsigned> &Entry =
254 if (Entry.first)
return Entry.second;
256 Entry.second = NextStringPoolNumber++;
266 std::pair<DenseMap<const MCExpr *, unsigned>::iterator,
bool>
P =
267 AddressPool.
insert(std::make_pair(Sym, NextAddrPoolNumber));
269 ++NextAddrPoolNumber;
270 return P.first->second;
277 DIEAbbrev *InSet = AbbreviationsSet->GetOrInsertNode(&Abbrev);
280 if (InSet == &Abbrev) {
282 Abbreviations.push_back(&Abbrev);
372 assert(SPDie &&
"Unable to find subprogram DIE!");
377 if (
DIE *AbsSPDIE = AbstractSPDies.lookup(SP)) {
380 SPCU->
addDIEEntry(SPDie, dwarf::DW_AT_abstract_origin, AbsSPDIE);
393 SPCU->
addFlag(SPDie, dwarf::DW_AT_declaration);
398 uint16_t SPTag = SPTy.
getTag();
399 if (SPTag == dwarf::DW_TAG_subroutine_type)
405 if (ATy.isArtificial())
406 SPCU->
addFlag(Arg, dwarf::DW_AT_artificial);
407 if (ATy.isObjectPointer())
408 SPCU->
addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
410 DIE *SPDeclDie = SPDie;
413 SPCU->
addDIEEntry(SPDie, dwarf::DW_AT_specification, SPDeclDie);
426 SPCU->
addAddress(SPDie, dwarf::DW_AT_frame_base, Location);
437 bool DwarfDebug::isLexicalScopeDIENull(
LexicalScope *Scope) {
446 if (Ranges.
size() > 1)
452 MCSymbol *End = getLabelAfterInsn(RI->second);
460 if (isLexicalScopeDIENull(Scope))
463 DIE *ScopeDIE =
new DIE(dwarf::DW_TAG_lexical_block);
469 if (Ranges.
size() > 1) {
473 TheCU->
addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4,
474 DebugRangeSymbols.size()
477 RE = Ranges.
end(); RI != RE; ++RI) {
478 DebugRangeSymbols.push_back(getLabelBeforeInsn(RI->first));
479 DebugRangeSymbols.push_back(getLabelAfterInsn(RI->second));
483 DebugRangeSymbols.push_back(NULL);
484 DebugRangeSymbols.push_back(NULL);
490 MCSymbol *Start = getLabelBeforeInsn(RI->first);
491 MCSymbol *End = getLabelAfterInsn(RI->second);
492 assert(End &&
"End label should not be null!");
494 assert(Start->
isDefined() &&
"Invalid starting label for an inlined scope!");
495 assert(End->
isDefined() &&
"Invalid end label for an inlined scope!");
508 assert(Ranges.
empty() ==
false &&
509 "LexicalScope does not have instruction markers!");
515 DIE *OriginDIE = TheCU->
getDIE(InlinedSP);
517 DEBUG(
dbgs() <<
"Unable to find original DIE for an inlined subprogram.");
521 DIE *ScopeDIE =
new DIE(dwarf::DW_TAG_inlined_subroutine);
522 TheCU->
addDIEEntry(ScopeDIE, dwarf::DW_AT_abstract_origin, OriginDIE);
524 if (Ranges.
size() > 1) {
528 TheCU->
addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4,
529 DebugRangeSymbols.size()
532 RE = Ranges.
end(); RI != RE; ++RI) {
533 DebugRangeSymbols.push_back(getLabelBeforeInsn(RI->first));
534 DebugRangeSymbols.push_back(getLabelAfterInsn(RI->second));
536 DebugRangeSymbols.push_back(NULL);
537 DebugRangeSymbols.push_back(NULL);
540 MCSymbol *StartLabel = getLabelBeforeInsn(RI->first);
541 MCSymbol *EndLabel = getLabelAfterInsn(RI->second);
543 if (StartLabel == 0 || EndLabel == 0)
547 "Invalid starting label for an inlined scope!");
548 assert(EndLabel->
isDefined() &&
"Invalid end label for an inlined scope!");
554 InlinedSubprogramDIEs.insert(OriginDIE);
558 TheCU->
addUInt(ScopeDIE, dwarf::DW_AT_call_file,
None,
561 TheCU->
addUInt(ScopeDIE, dwarf::DW_AT_call_line,
None, DL.getLineNumber());
572 DIE *ObjectPointer = NULL;
576 for (
unsigned i = 0, N = CurrentFnArguments.size(); i <
N; ++i)
581 if (ArgDV->isObjectPointer()) ObjectPointer = Arg;
586 for (
unsigned i = 0, N = Variables.
size(); i <
N; ++i)
590 if (Variables[i]->isObjectPointer()) ObjectPointer = Variable;
593 for (
unsigned j = 0, M = Scopes.
size(); j < M; ++j)
594 if (
DIE *Nested = constructScopeDIE(TheCU, Scopes[j]))
596 return ObjectPointer;
607 DIE *ObjectPointer = NULL;
608 bool ChildrenCreated =
false;
613 DIE *ScopeDIE = NULL;
615 ScopeDIE = constructInlinedScopeDIE(TheCU, Scope);
616 else if (DS.isSubprogram()) {
617 ProcessedSPNodes.insert(DS);
619 ScopeDIE = TheCU->
getDIE(DS);
622 AbstractSPDies.insert(std::make_pair(DS, ScopeDIE));
624 ScopeDIE = updateSubprogramScopeDIE(TheCU,
DISubprogram(DS));
627 if (isLexicalScopeDIENull(Scope))
632 ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children);
633 ChildrenCreated =
true;
637 ImportedEntityMap::const_iterator> Range = std::equal_range(
638 ScopesWithImportedEntities.
begin(), ScopesWithImportedEntities.
end(),
639 std::pair<const MDNode *, const MDNode *>(DS, (
const MDNode*)0),
641 if (Children.empty() && Range.first == Range.second)
643 ScopeDIE = constructLexicalScopeDIE(TheCU, Scope);
644 assert(ScopeDIE &&
"Scope DIE should not be null.");
645 for (ImportedEntityMap::const_iterator i = Range.first; i != Range.second;
647 constructImportedEntityDIE(TheCU, i->second, ScopeDIE);
651 assert(Children.empty() &&
652 "We create children only when the scope DIE is not null.");
655 if (!ChildrenCreated)
657 ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children);
661 E = Children.end();
I != E; ++
I)
664 if (DS.isSubprogram() && ObjectPointer != NULL)
665 TheCU->
addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, ObjectPointer);
667 if (DS.isSubprogram())
688 if (FileName.
empty())
692 if (DirName == CompilationDir)
696 unsigned SrcId = FileIDCUMap[CUID] + 1;
704 NamePair += FileName;
710 FileIDCUMap[CUID] = SrcId;
723 DIE *Die =
new DIE(dwarf::DW_TAG_compile_unit);
733 NewCU->
addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
735 NewCU->
addString(Die, dwarf::DW_AT_name, FN);
761 NewCU->
addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset,
763 : LineTableStartSym);
764 else if (UseTheFirstCU)
765 NewCU->
addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0);
767 NewCU->
addDelta(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4,
768 LineTableStartSym, DwarfLineSectionSym);
772 if (!CompilationDir.
empty())
773 NewCU->
addString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
779 NewCU->
addLabel(Die, dwarf::DW_AT_GNU_pubnames,
780 dwarf::DW_FORM_sec_offset,
784 NewCU->
addDelta(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_data4,
787 DwarfGnuPubNamesSectionSym);
790 NewCU->
addLabel(Die, dwarf::DW_AT_GNU_pubtypes,
791 dwarf::DW_FORM_sec_offset,
795 NewCU->
addDelta(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_data4,
798 DwarfGnuPubTypesSectionSym);
803 NewCU->
addFlag(Die, dwarf::DW_AT_APPLE_optimized);
807 NewCU->
addString(Die, dwarf::DW_AT_APPLE_flags, Flags);
810 NewCU->
addUInt(Die, dwarf::DW_AT_APPLE_major_runtime_vers,
811 dwarf::DW_FORM_data1, RVer);
818 CUMap.insert(std::make_pair(DIUnit, NewCU));
819 CUDieMap.insert(std::make_pair(Die, NewCU));
846 void DwarfDebug::constructImportedEntityDIE(
CompileUnit *TheCU,
852 constructImportedEntityDIE(TheCU,
Module, D);
860 return constructImportedEntityDIE(TheCU,
Module, Context);
863 void DwarfDebug::constructImportedEntityDIE(
CompileUnit *TheCU,
867 "Use one of the MDNode * overloads to handle invalid metadata");
868 assert(Context &&
"Should always have a context for an imported_module");
880 EntityDie = TheCU->
getDIE(Entity);
884 TheCU->
addUInt(IMDie, dwarf::DW_AT_decl_file,
None, FileID);
886 TheCU->
addDIEEntry(IMDie, dwarf::DW_AT_import, EntityDie);
889 TheCU->
addString(IMDie, dwarf::DW_AT_name, Name);
912 for (
unsigned i = 0, e = CU_Nodes->
getNumOperands(); i != e; ++i) {
915 DIArray ImportedEntities = CUNode.getImportedEntities();
916 for (
unsigned i = 0, e = ImportedEntities.
getNumElements(); i != e; ++i)
917 ScopesWithImportedEntities.
push_back(std::make_pair(
920 std::sort(ScopesWithImportedEntities.
begin(),
922 DIArray GVs = CUNode.getGlobalVariables();
923 for (
unsigned i = 0, e = GVs.getNumElements(); i != e; ++i)
925 DIArray SPs = CUNode.getSubprograms();
927 constructSubprogramDIE(CU, SPs.
getElement(i));
928 DIArray EnumTypes = CUNode.getEnumTypes();
930 CU->getOrCreateTypeDIE(EnumTypes.
getElement(i));
931 DIArray RetainedTypes = CUNode.getRetainedTypes();
932 for (
unsigned i = 0, e = RetainedTypes.
getNumElements(); i != e; ++i)
933 CU->getOrCreateTypeDIE(RetainedTypes.
getElement(i));
936 for (
unsigned i = 0, e = ImportedEntities.
getNumElements(); i != e; ++i)
937 constructImportedEntityDIE(CU, ImportedEntities.
getElement(i));
948 void DwarfDebug::computeInlinedDIEs() {
951 AE = InlinedSubprogramDIEs.end(); AI != AE; ++AI) {
956 AE = AbstractSPDies.end(); AI != AE; ++AI) {
957 DIE *ISP = AI->second;
958 if (InlinedSubprogramDIEs.count(ISP))
965 void DwarfDebug::collectDeadVariables() {
969 for (
unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
971 DIArray Subprograms = TheCU.getSubprograms();
972 for (
unsigned i = 0, e = Subprograms.getNumElements(); i != e; ++i) {
974 if (ProcessedSPNodes.count(SP) != 0)
986 assert(SPCU &&
"Unable to find Compile Unit!");
989 constructSubprogramDIE(SPCU, SP);
991 for (
unsigned vi = 0, ve = Variables.
getNumElements(); vi != ve; ++vi) {
993 if (!DV.isVariable())
996 if (
DIE *VariableDIE =
1012 if (
DIEString *S = dyn_cast_or_null<DIEString>(V))
1013 return S->getString();
1023 if (Parent->
getTag() == dwarf::DW_TAG_namespace &&
1040 void DwarfDebug::finalizeModuleInfo() {
1042 collectDeadVariables();
1045 computeInlinedDIEs();
1050 for (
unsigned i = 0, e = TypeUnits.size(); i != e; ++i) {
1051 DIE *Die = TypeUnits[i];
1058 CUMap.begin()->second->addUInt(Die, dwarf::DW_AT_GNU_odr_signature,
1059 dwarf::DW_FORM_data8,
1066 CUI != CUE; ++CUI) {
1082 dwarf::DW_FORM_data8,
ID);
1087 dwarf::DW_FORM_data8,
ID);
1097 void DwarfDebug::endSections() {
1099 for (
size_t n = 0; n < ArangeLabels.size(); n++) {
1100 const SymbolCU &SCU = ArangeLabels[n];
1105 SectionMap[Section].push_back(SCU);
1110 SectionMap[NULL].push_back(SCU);
1115 std::vector<const MCSection *> Sections;
1119 Sections.push_back(Section);
1124 std::sort(Sections.begin(), Sections.end(),
SectionSort);
1127 for (
unsigned ID=0;ID<Sections.size();ID++) {
1149 if (!FirstCU)
return;
1156 finalizeModuleInfo();
1165 emitAbbreviations();
1191 emitAbbreviations();
1192 emitDebugAbbrevDWO();
1215 emitAccelNamespaces();
1220 if (HasDwarfPubSections) {
1228 E = CUMap.end();
I != E; ++
I)
1232 E = SkeletonCUs.end();
I != E; ++
I)
1245 DbgVariable *AbsDbgVariable = AbstractVariables.lookup(Var);
1247 return AbsDbgVariable;
1253 AbsDbgVariable =
new DbgVariable(Var, NULL,
this);
1254 addScopeVariable(Scope, AbsDbgVariable);
1255 AbstractVariables[Var] = AbsDbgVariable;
1256 return AbsDbgVariable;
1265 if (DV.
getTag() != dwarf::DW_TAG_arg_variable)
1271 size_t Size = CurrentFnArguments.size();
1277 CurrentFnArguments.resize(ArgNo * 2);
1278 CurrentFnArguments[ArgNo - 1] = Var;
1284 DwarfDebug::collectVariableInfoFromMMITable(
const MachineFunction *MF,
1288 VE = VMap.
end(); VI != VE; ++VI) {
1289 const MDNode *Var = VI->first;
1293 const std::pair<unsigned, DebugLoc> &VP = VI->second;
1301 DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.second);
1304 if (!addCurrentFnArgument(MF, RegVar, Scope))
1305 addScopeVariable(Scope, RegVar);
1314 assert(MI->
isDebugValue() &&
"Invalid DBG_VALUE machine instruction!");
1355 collectVariableInfoFromMMITable(MF, Processed);
1358 UVI = UserVariables.begin(), UVE = UserVariables.end(); UVI != UVE;
1360 const MDNode *Var = *UVI;
1361 if (Processed.
count(Var))
1367 if (History.
empty())
1373 if (DV.
getTag() == dwarf::DW_TAG_arg_variable &&
1385 assert(MInsn->
isDebugValue() &&
"History must begin with debug value");
1388 if (!addCurrentFnArgument(MF, RegVar, Scope))
1389 addScopeVariable(Scope, RegVar);
1391 AbsVar->setMInsn(MInsn);
1394 if (History.
size() <= 1 || (History.
size() == 2 &&
1396 RegVar->setMInsn(MInsn);
1401 RegVar->setDotDebugLocOffset(DotDebugLocEntries.size());
1406 assert(Begin->
isDebugValue() &&
"Invalid History entry");
1414 const MCSymbol *FLabel = getLabelBeforeInsn(Begin);
1420 SLabel = FunctionEndSym;
1424 <<
"\t" << *Begin <<
"\t" << *End <<
"\n");
1426 SLabel = getLabelBeforeInsn(End);
1429 SLabel = getLabelAfterInsn(End);
1430 assert(SLabel &&
"Forgot label after clobber instruction");
1445 for (
unsigned i = 0, e = Variables.
getNumElements(); i != e; ++i) {
1450 addScopeVariable(Scope,
new DbgVariable(DV, NULL,
this));
1456 MCSymbol *Label = LabelsBeforeInsn.lookup(MI);
1457 assert(Label &&
"Didn't insert label before instruction");
1463 return LabelsAfterInsn.lookup(MI);
1474 if (DL == PrologEndLoc) {
1485 recordSourceLine(0, 0, 0, 0);
1491 LabelsBeforeInsn.find(MI);
1494 if (I == LabelsBeforeInsn.end())
1505 I->second = PrevLabel;
1516 LabelsAfterInsn.find(MI);
1519 if (I == LabelsAfterInsn.end())
1531 I->second = PrevLabel;
1538 void DwarfDebug::identifyScopeMarkers() {
1541 while (!WorkList.
empty()) {
1545 if (!Children.
empty())
1547 SE = Children.
end(); SI != SE; ++SI)
1557 RE = Ranges.
end(); RI != RE; ++RI) {
1558 assert(RI->first &&
"InsnRange does not have first instruction!");
1559 assert(RI->second &&
"InsnRange does not have second instruction!");
1560 requestLabelBeforeInsn(RI->first);
1561 requestLabelAfterInsn(RI->second);
1581 if (SP->getNumOperands() > 19)
1601 if (LScopes.
empty())
1604 assert(UserVariables.empty() && DbgValues.
empty() &&
"Maps weren't cleaned");
1607 identifyScopeMarkers();
1614 assert(TheCU &&
"Unable to find compile unit!");
1628 std::vector<const MDNode *> LiveUserVar(TRI->
getNumRegs());
1632 bool AtBlockEntry =
true;
1638 assert(MI->
getNumOperands() > 1 &&
"Invalid machine instruction!");
1650 if (History.
empty()) {
1651 UserVariables.push_back(Var);
1657 LabelsBeforeInsn[
MI] = FunctionBeginSym;
1663 if (History.
size() >= 2 &&
1665 DEBUG(
dbgs() <<
"Coalescing identical DBG_VALUE entries:\n"
1666 <<
"\t" << *Prev <<
"\t"
1667 << *History[History.
size() - 2] <<
"\n");
1673 if (PrevMBB !=
I && (!AtBlockEntry ||
llvm::next(PrevMBB) !=
I) &&
1678 PrevMBB->getLastNonDebugInstr();
1679 if (LastMI == PrevMBB->end()) {
1681 DEBUG(
dbgs() <<
"Dropping DBG_VALUE for empty range:\n"
1682 <<
"\t" << *Prev <<
"\n");
1684 }
else if (
llvm::next(PrevMBB) != PrevMBB->getParent()->end())
1694 AtBlockEntry =
false;
1705 MOI != MOE; ++MOI) {
1706 if (!MOI->isReg() || !MOI->isDef() || !MOI->getReg())
1715 LiveUserVar[
Reg] = 0;
1719 if (HistI == DbgValues.
end())
1722 if (History.
empty())
1744 if (History.
empty())
1753 if (LastMI == PrevMBB->
end())
1762 for (
unsigned i = 0, e = History.
size(); i != e; ++i) {
1765 requestLabelBeforeInsn(MI);
1767 requestLabelAfterInsn(MI);
1772 PrevLabel = FunctionBeginSym;
1800 while (I != Vars.
end()) {
1801 unsigned CurNum = (*I)->getVariable().getArgNumber();
1807 if (CurNum > ArgNum)
1831 collectVariableInfo(MF, ProcessedVars);
1835 assert(TheCU &&
"Unable to find compile unit!");
1839 for (
unsigned i = 0, e = AList.
size(); i != e; ++i) {
1845 for (
unsigned i = 0, e = Variables.
getNumElements(); i != e; ++i) {
1853 if (AbstractVariables.lookup(CleanDV))
1856 addScopeVariable(Scope,
new DbgVariable(DV, NULL,
this));
1859 if (ProcessedSPNodes.count(AScope->
getScopeNode()) == 0)
1860 constructScopeDIE(TheCU, AScope);
1863 DIE *CurFnDIE = constructScopeDIE(TheCU, FnScope);
1866 TheCU->
addFlag(CurFnDIE, dwarf::DW_AT_APPLE_omit_frame_ptr);
1870 I = ScopeVariables.
begin(), E = ScopeVariables.
end(); I != E; ++
I)
1872 ScopeVariables.
clear();
1874 UserVariables.clear();
1876 AbstractVariables.clear();
1877 LabelsBeforeInsn.clear();
1878 LabelsAfterInsn.clear();
1884 void DwarfDebug::recordSourceLine(
unsigned Line,
unsigned Col,
const MDNode *S,
1892 if (Scope.isCompileUnit()) {
1894 Fn = CU.getFilename();
1895 Dir = CU.getDirectory();
1896 }
else if (Scope.isFile()) {
1898 Fn =
F.getFilename();
1899 Dir =
F.getDirectory();
1900 }
else if (Scope.isSubprogram()) {
1904 }
else if (Scope.isLexicalBlockFile()) {
1906 Fn = DBF.getFilename();
1907 Dir = DBF.getDirectory();
1908 }
else if (Scope.isLexicalBlock()) {
1910 Fn =
DB.getFilename();
1911 Dir =
DB.getDirectory();
1930 const std::vector<DIE *> &Children = Die->
getChildren();
1937 const DIEAbbrev *Abbrev = Abbreviations[AbbrevNumber - 1];
1949 for (
unsigned i = 0, N = Values.
size(); i <
N; ++i)
1951 Offset += Values[i]->SizeOf(Asm, AbbrevData[i].getForm());
1954 if (!Children.empty()) {
1956 "Children flag not set");
1958 for (
unsigned j = 0, M = Children.
size(); j < M; ++j)
1962 Offset +=
sizeof(int8_t);
1972 unsigned SecOffset = 0;
1977 E = CUs.end(); I != E; ++
I) {
1978 (*I)->setDebugInfoOffset(SecOffset);
1981 unsigned Offset =
sizeof(int32_t) +
1982 (*I)->getHeaderSize();
1987 SecOffset += EndOffset;
1992 void DwarfDebug::emitSectionLabels() {
1996 DwarfInfoSectionSym =
1998 DwarfAbbrevSectionSym =
2001 DwarfAbbrevDWOSectionSym =
2003 "section_abbrev_dwo");
2009 DwarfLineSectionSym =
2013 DwarfGnuPubNamesSectionSym =
2015 DwarfGnuPubTypesSectionSym =
2017 }
else if (HasDwarfPubSections) {
2022 DwarfStrSectionSym =
2025 DwarfStrDWOSectionSym =
2027 DwarfAddrSectionSym =
2034 "section_debug_loc");
2044 const DIEAbbrev *Abbrev = Abbrevs[AbbrevNumber - 1];
2058 for (
unsigned i = 0, N = Values.
size(); i <
N; ++i) {
2059 dwarf::Attribute Attr = AbbrevData[i].getAttribute();
2060 dwarf::Form Form = AbbrevData[i].getForm();
2061 assert(Form &&
"Too many attributes for DIE (check abbreviation)");
2067 case dwarf::DW_AT_abstract_origin:
2068 case dwarf::DW_AT_type:
2069 case dwarf::DW_AT_friend:
2070 case dwarf::DW_AT_specification:
2071 case dwarf::DW_AT_import:
2072 case dwarf::DW_AT_containing_type: {
2073 DIEEntry *E = cast<DIEEntry>(Values[i]);
2076 if (Form == dwarf::DW_FORM_ref_addr) {
2077 assert(!
useSplitDwarf() &&
"TODO: dwo files can't have relocations.");
2081 CompileUnit *CU = CUDieMap.lookup(Origin->getCompileUnit());
2082 assert(CU &&
"CUDie should belong to a CU.");
2089 DwarfInfoSectionSym,
2094 "The referenced DIE should belong to the same CU in ref4");
2099 case dwarf::DW_AT_ranges: {
2110 DwarfDebugRangeSectionSym,
2115 case dwarf::DW_AT_location: {
2116 if (
DIELabel *L = dyn_cast<DIELabel>(Values[i])) {
2122 Values[i]->EmitValue(Asm, Form);
2126 case dwarf::DW_AT_accessibility: {
2131 Values[i]->EmitValue(Asm, Form);
2136 Values[i]->EmitValue(Asm, Form);
2143 const std::vector<DIE *> &Children = Die->
getChildren();
2145 for (
unsigned j = 0, M = Children.
size(); j < M; ++j)
2146 emitDIE(Children[j], Abbrevs);
2162 E = CUs.end(); I != E; ++
I) {
2177 DD->
emitDIE(Die, Abbreviations);
2184 void DwarfDebug::emitDebugInfo() {
2189 DwarfAbbrevSectionSym);
2193 void DwarfDebug::emitAbbreviations() {
2201 void DwarfDebug::emitAbbrevs(
const MCSection *Section,
2202 std::vector<DIEAbbrev *> *Abbrevs) {
2204 if (!Abbrevs->empty()) {
2212 for (
unsigned i = 0, N = Abbrevs->size(); i <
N; ++i) {
2214 const DIEAbbrev *Abbrev = Abbrevs->at(i);
2232 void DwarfDebug::emitEndOfLineMatrix(
unsigned SectionEnd) {
2255 void DwarfDebug::emitAccelNames() {
2257 dwarf::DW_FORM_data4));
2259 E = CUMap.end(); I != E; ++
I) {
2262 for (
StringMap<std::vector<DIE*> >::const_iterator
2263 GI = Names.
begin(),
GE = Names.
end(); GI !=
GE; ++GI) {
2265 const std::vector<DIE *> &Entities = GI->second;
2266 for (std::vector<DIE *>::const_iterator DI = Entities.begin(),
2267 DE = Entities.end(); DI !=
DE; ++DI)
2268 AT.AddName(Name, (*DI));
2272 AT.FinalizeTable(Asm,
"Names");
2279 AT.Emit(Asm, SectionBegin, &InfoHolder);
2284 void DwarfDebug::emitAccelObjC() {
2286 dwarf::DW_FORM_data4));
2288 E = CUMap.end(); I != E; ++
I) {
2291 for (
StringMap<std::vector<DIE*> >::const_iterator
2292 GI = Names.
begin(),
GE = Names.
end(); GI !=
GE; ++GI) {
2294 const std::vector<DIE *> &Entities = GI->second;
2295 for (std::vector<DIE *>::const_iterator DI = Entities.begin(),
2296 DE = Entities.end(); DI !=
DE; ++DI)
2297 AT.AddName(Name, (*DI));
2301 AT.FinalizeTable(Asm,
"ObjC");
2308 AT.Emit(Asm, SectionBegin, &InfoHolder);
2312 void DwarfDebug::emitAccelNamespaces() {
2314 dwarf::DW_FORM_data4));
2316 E = CUMap.end(); I != E; ++
I) {
2319 for (
StringMap<std::vector<DIE*> >::const_iterator
2320 GI = Names.
begin(),
GE = Names.
end(); GI !=
GE; ++GI) {
2322 const std::vector<DIE *> &Entities = GI->second;
2323 for (std::vector<DIE *>::const_iterator DI = Entities.begin(),
2324 DE = Entities.end(); DI !=
DE; ++DI)
2325 AT.AddName(Name, (*DI));
2329 AT.FinalizeTable(Asm,
"namespac");
2336 AT.Emit(Asm, SectionBegin, &InfoHolder);
2340 void DwarfDebug::emitAccelTypes() {
2341 std::vector<DwarfAccelTable::Atom> Atoms;
2343 dwarf::DW_FORM_data4));
2345 dwarf::DW_FORM_data2));
2347 dwarf::DW_FORM_data1));
2350 E = CUMap.end(); I != E; ++
I) {
2354 for (
StringMap<std::vector<std::pair<DIE*, unsigned> > >::const_iterator
2355 GI = Names.
begin(),
GE = Names.
end(); GI !=
GE; ++GI) {
2357 const std::vector<std::pair<DIE *, unsigned> > &Entities = GI->second;
2358 for (std::vector<std::pair<DIE *, unsigned> >::const_iterator DI
2359 = Entities.begin(),
DE = Entities.end(); DI !=
DE; ++DI)
2360 AT.AddName(Name, (*DI).first, (*DI).second);
2364 AT.FinalizeTable(Asm,
"types");
2371 AT.Emit(Asm, SectionBegin, &InfoHolder);
2397 DIE *SpecDIE = cast<DIEEntry>(SpecVal)->getEntry();
2404 case dwarf::DW_TAG_class_type:
2405 case dwarf::DW_TAG_structure_type:
2406 case dwarf::DW_TAG_union_type:
2407 case dwarf::DW_TAG_enumeration_type:
2412 case dwarf::DW_TAG_typedef:
2413 case dwarf::DW_TAG_base_type:
2414 case dwarf::DW_TAG_subrange_type:
2416 case dwarf::DW_TAG_namespace:
2418 case dwarf::DW_TAG_subprogram:
2420 case dwarf::DW_TAG_constant:
2421 case dwarf::DW_TAG_variable:
2423 case dwarf::DW_TAG_enumerator:
2433 void DwarfDebug::emitDebugPubNames(
bool GnuStyle) {
2440 for (CUMapType::iterator I = CUMap.begin(), E = CUMap.end(); I != E; ++
I) {
2460 Asm->
EmitInt16(dwarf::DW_PUBNAMES_VERSION);
2464 DwarfInfoSectionSym);
2474 GI = Globals.
begin(),
GE = Globals.
end(); GI !=
GE; ++GI) {
2475 const char *Name = GI->getKeyData();
2476 DIE *Entity = GI->second;
2500 void DwarfDebug::emitDebugPubTypes(
bool GnuStyle) {
2529 Asm->
EmitInt16(dwarf::DW_PUBTYPES_VERSION);
2534 DwarfInfoSectionSym);
2546 const char *Name = GI->getKeyData();
2547 DIE *Entity = GI->second;
2578 const MCSymbol *StrSecSym = NULL) {
2590 for (
StringMap<std::pair<MCSymbol*, unsigned> >::iterator
2593 Entries.push_back(std::make_pair(I->second.second, &*I));
2597 for (
unsigned i = 0, e = Entries.size(); i != e; ++i) {
2603 Entries[i].second->getKeyLength()+1));
2607 if (OffsetSection) {
2609 unsigned offset = 0;
2611 for (
unsigned i = 0, e = Entries.size(); i != e; ++i) {
2613 offset += Entries[i].second->getKeyLength() + 1;
2621 if (AddressPool.
empty())
return;
2630 E = AddressPool.
end();
2632 Entries[I->second] = I->first;
2634 for (
unsigned i = 0, e = Entries.size(); i != e; ++i) {
2636 if (
const MCExpr *Expr = Entries[i])
2645 void DwarfDebug::emitDebugStr() {
2651 void DwarfDebug::emitDebugLoc() {
2652 if (DotDebugLocEntries.empty())
2656 I = DotDebugLocEntries.begin(), E = DotDebugLocEntries.end();
2659 if (I + 1 != DotDebugLocEntries.end())
2670 I = DotDebugLocEntries.begin(), E = DotDebugLocEntries.end();
2671 I != E; ++
I, ++index) {
2687 if (Entry.
isInt()) {
2730 for (; i <
N; ++i) {
2755 unsigned IA = A.
Sym ? Streamer.GetSymbolOrder(A.
Sym) : 0;
2756 unsigned IB = B.
Sym ? Streamer.GetSymbolOrder(B.
Sym) : 0;
2778 void DwarfDebug::emitDebugARanges() {
2788 std::vector<const MCSection *> Sections;
2792 Sections.push_back(Section);
2797 std::sort(Sections.begin(), Sections.end(),
SectionSort);
2800 for (
size_t SecIdx=0;SecIdx<Sections.size();SecIdx++) {
2801 const MCSection *Section = Sections[SecIdx];
2803 if (List.
size() < 2)
2808 std::sort(List.
begin(), List.
end(), sorter);
2812 if (Section == NULL) {
2813 for (
size_t n = 0; n < List.
size(); n++) {
2820 Spans[Cur.
CU].push_back(Span);
2824 const MCSymbol *StartSym = List[0].Sym;
2825 for (
size_t n = 1; n < List.
size(); n++) {
2826 const SymbolCU &Prev = List[n - 1];
2830 if (Cur.
CU != Prev.
CU) {
2832 Span.
Start = StartSym;
2834 Spans[Prev.
CU].push_back(Span);
2845 std::vector<CompileUnit *> CUs;
2846 for (SpansType::iterator it = Spans.begin(); it != Spans.end(); it++) {
2852 std::sort(CUs.begin(), CUs.end(),
CUSort);
2855 for (
size_t CUIdx=0;CUIdx<CUs.size();CUIdx++) {
2857 std::vector<ArangeSpan> &List = Spans[CU];
2860 unsigned ContentSize
2866 unsigned TupleSize = PtrSize * 2;
2869 unsigned Padding = 0;
2870 while (((
sizeof(int32_t) + ContentSize + Padding) % TupleSize) != 0)
2873 ContentSize += Padding;
2874 ContentSize += (List.size() + 1) * TupleSize;
2880 Asm->
EmitInt16(dwarf::DW_ARANGES_VERSION);
2884 DwarfInfoSectionSym);
2890 for (
unsigned n = 0; n < Padding; n++)
2893 for (
unsigned n = 0; n < List.size(); n++) {
2903 uint64_t Size = SymSize[Span.
Start];
2918 void DwarfDebug::emitDebugRanges() {
2924 I = DebugRangeSymbols.begin(), E = DebugRangeSymbols.end();
2934 void DwarfDebug::emitDebugMacInfo() {
2949 DIE *Die =
new DIE(dwarf::DW_TAG_compile_unit);
2951 Asm,
this, &SkeletonHolder);
2959 NewCU->
addLabel(Die, dwarf::DW_AT_GNU_addr_base, dwarf::DW_FORM_sec_offset,
2960 DwarfAddrSectionSym);
2962 NewCU->
addUInt(Die, dwarf::DW_AT_GNU_addr_base,
2963 dwarf::DW_FORM_sec_offset, 0);
2967 NewCU->
addUInt(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 0);
2973 NewCU->
addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset,
2974 DwarfLineSectionSym);
2976 NewCU->
addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset, 0);
2978 if (!CompilationDir.
empty())
2979 NewCU->
addLocalString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
2984 NewCU->
addLabel(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_sec_offset,
2987 NewCU->
addDelta(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_data4,
2989 DwarfGnuPubNamesSectionSym);
2992 NewCU->
addLabel(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_sec_offset,
2995 NewCU->
addDelta(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_data4,
2997 DwarfGnuPubTypesSectionSym);
3001 if (DebugRangeSymbols.size()) {
3003 NewCU->
addLabel(Die, dwarf::DW_AT_GNU_ranges_base,
3004 dwarf::DW_FORM_sec_offset, DwarfDebugRangeSectionSym);
3006 NewCU->
addUInt(Die, dwarf::DW_AT_GNU_ranges_base, dwarf::DW_FORM_data4,
3010 SkeletonHolder.
addUnit(NewCU);
3011 SkeletonCUs.push_back(NewCU);
3016 void DwarfDebug::emitSkeletonAbbrevs(
const MCSection *Section) {
3018 emitAbbrevs(Section, &SkeletonAbbrevs);
3023 void DwarfDebug::emitDebugInfoDWO() {
3027 DwarfAbbrevDWOSectionSym);
3032 void DwarfDebug::emitDebugAbbrevDWO() {
3041 void DwarfDebug::emitDebugStrDWO() {
3045 const MCSymbol *StrSym = DwarfStrSectionSym;
SuperClass::iterator iterator
bool isBlockByrefVariable() const
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName)
EmitDwarfLocDirective - This implements the DWARF2.
void DeleteContainerPointers(Container &C)
void push_back(const T &Elt)
const MachineFunction * getParent() const
An object containing the capability of hashing and adding hash attributes onto a DIE.
const MCSection * getDwarfAccelNamesSection() const
const_iterator end(StringRef path)
Get end iterator over path.
mop_iterator operands_end()
uint64_t computeCUSignature(const DIE &Die)
Computes the CU signature.
const ValueTy & getValue() const
virtual void AddComment(const Twine &T)
const MCSection * getDwarfAbbrevSection() const
const MCSection * getDwarfMacroInfoSection() const
LLVMContext & getContext() const
SymbolCUSorter(const MCStreamer &s)
static cl::opt< DefaultOnOff > SplitDwarf("split-dwarf", cl::Hidden, cl::desc("Output prototype dwarf split debug info."), cl::values(clEnumVal(Default,"Default for platform"), clEnumVal(Enable,"Enabled"), clEnumVal(Disable,"Disabled"), clEnumValEnd), cl::init(Default))
static cl::opt< bool > GenerateGnuPubSections("generate-gnu-dwarf-pub-sections", cl::Hidden, cl::desc("Generate GNU-style pubnames and pubtypes"), cl::init(false))
static cl::opt< bool > DisableDebugInfoPrinting("disable-debug-info-print", cl::Hidden, cl::desc("Disable debug info printing"))
#define DWARF2_FLAG_PROLOGUE_END
bool isVariable() const
isVariable - Return true if the specified tag is legal for DIVariable.
DIE * getOrCreateSubprogramDIE(DISubprogram SP)
getOrCreateSubprogramDIE - Create new DIE using SP.
bool isSubprogram() const
void emitHeader(const MCSection *ASection, const MCSymbol *ASectionSym)
Emit the header for this unit, not including the initial length field.
const ConstantFP * getFPImm() const
bool useDwarfAccelTables()
Returns whether or not to emit tables that dwarf consumers can use to accelerate lookup.
const MCSection * getDwarfLineSection() const
The main container class for the LLVM Intermediate Representation.
const DataLayout & getDataLayout() const
getDataLayout - Return information about data layout.
StringRef getFlags() const
void EmitInt8(int Value) const
const MDNode * getScopeNode() const
bool isCurrentFunctionScope(const LexicalScope *LS)
void endFunction(const MachineFunction *MF)
Gather and emit post-function debug information.
unsigned getPointerSize(unsigned AS=0) const
bool Verify() const
Verify that the imported module descriptor is well formed.
const MCSection * getDwarfRangesSection() const
static cl::opt< DefaultOnOff > DwarfAccelTables("dwarf-accel-tables", cl::Hidden, cl::desc("Output prototype dwarf accelerator tables."), cl::values(clEnumVal(Default,"Default for platform"), clEnumVal(Enable,"Enabled"), clEnumVal(Disable,"Disabled"), clEnumValEnd), cl::init(Default))
static DebugLoc getFnDebugLoc(DebugLoc DL, const LLVMContext &Ctx)
void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, unsigned Size, bool IsSectionRelative=false) const
size_t find(char C, size_t From=0) const
void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
Collects and handles dwarf debug information.
unsigned getDebugInfoOffset() const
void setFrameIndex(int FI)
const MachineFunction * MF
The current machine function.
Collects and handles information specific to a particular collection of units.
SmallVectorImpl< InsnRange > & getRanges()
ValuesClass< DataType > END_WITH_NULL values(const char *Arg, DataType Val, const char *Desc,...)
MDNode * getInlinedAt() const
getInlinedAt - If this variable is inlined then return inline location.
virtual std::string getLabelEndName() const =0
const MDNode * getVariable() const
iterator insert(iterator I, const T &Elt)
DIE * getOrCreateNameSpace(DINameSpace NS)
getOrCreateNameSpace - Create a DIE for DINameSpace.
virtual bool hasRawTextSupport() const
const_iterator begin(StringRef path)
Get begin iterator over path.
virtual void EmitDwarfRegOp(const MachineLocation &MLoc, bool Indirect) const
EmitDwarfRegOp - Emit dwarf register operation.
static const char *const DbgTimerName
virtual std::string getLabelBeginName() const =0
unsigned getFunctionNumber() const
MDNode - a tuple of other values.
DIEValue * findAttribute(uint16_t Attribute)
static StringRef getDIEStringAttr(DIE *Die, unsigned Attr)
Grabs the string in whichever attribute is passed in and returns a reference to it. Returns "" if the attribute doesn't exist.
void EmitInt32(int Value) const
const Function * getFunction() const
StringRef getName() const
void EmitLabelReference(const MCSymbol *Label, unsigned Size, bool IsSectionRelative=false) const
void endInstruction(const MachineInstr *MI)
Process end of an instruction.
static bool SectionSort(const MCSection *A, const MCSection *B)
DIScope getContext() const
void addPubTypes(DISubprogram SP)
addPubTypes - Add a set of types from the subprogram to the global types.
const MCSection * getDataSection() const
DICompositeType getType() const
MachineLocation getLoc() const
DIE * constructVariableDIE(DbgVariable &DV, bool isScopeAbstract)
constructVariableDIE - Construct a DIE for the given DbgVariable.
uint16_t getLanguage() const
DIArray - This descriptor holds an array of descriptors.
bool isUnknown() const
isUnknown - Return true if this is an unknown location.
void emitAddresses(const MCSection *AddrSection)
Emit all of the addresses to the section given.
DIScopeRef getContext() const
ArrayRef< LexicalScope * > getAbstractScopesList() const
getAbstractScopesList - Return a reference to list of abstract scopes.
#define DWARF2_FLAG_IS_STMT
uint64_t getAddrElement(unsigned Idx) const
const MCSection * getDwarfLocSection() const
MCSymbol * CreateTempSymbol()
const MCSection & getSection() const
SmallVectorImpl< LexicalScope * > & getChildren()
unsigned getNumAddrElements() const
void addLabel(DIE *Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Label)
T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val()
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
#define llvm_unreachable(msg)
bool DisableFramePointerElim(const MachineFunction &MF) const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
virtual void EmitBytes(StringRef Data)=0
const Module * getModule() const
bool isIndirect() const
Return true if this variable is represented as a pointer.
const MCSection * getDwarfStrDWOSection() const
bool hasDebugInfo() const
virtual unsigned getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
ID
LLVM Calling Convention Representation.
#define clEnumVal(ENUMVAL, DESC)
MCContext & getContext() const
const MCSection * getDwarfAccelObjCSection() const
LexicalScope * getCurrentFunctionScope() const
getCurrentFunctionScope - Return lexical scope for the current function.
unsigned getNumOperands() const
static MCSymbol * emitSectionSym(AsmPrinter *Asm, const MCSection *Section, const char *SymbolStem=0)
DIDescriptor getEntity() const
void SwitchSection(const MCSection *Section, const MCExpr *Subsection=0)
DISubprogram - This is a wrapper for a subprogram (e.g. a function).
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
const MCSection * getDwarfAccelNamespaceSection() const
void setDwarfCompileUnitID(unsigned CUIndex)
bool count(PtrType Ptr) const
count - Return true if the specified pointer is in the set.
StringRef getDirectory() const
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
void setNumber(unsigned N)
unsigned getDwarfCompileUnitID()
This class is used to track local variable information.
unsigned getOrCreateSourceID(StringRef DirName, StringRef FullName, unsigned CUID)
Look up the source id with the given directory and source file names. If none currently exists...
virtual void initialize(const MachineFunction &)
initialize - Scan machine function and constuct lexical scope nest.
const MDNode * getInlinedAt() const
static bool isDbgValueInDefinedReg(const MachineInstr *MI)
DIVariable getVariable() const
void EmitInt16(int Value) const
static cl::opt< bool > GenerateCUHash("generate-cu-hash", cl::Hidden, cl::desc("Add the CU hash as the dwo_id."), cl::init(false))
static std::string utostr(uint64_t X, bool isNeg=false)
unsigned getLineNumber() const
const MCSection * getDwarfPubNamesSection() const
iterator getLastNonDebugInstr()
const MCSection * getTextSection() const
bool hasComplexAddress() const
HasComplexAddr - Return true if the variable has a complex address.
virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, unsigned CUID=0)
StringRef getName() const
unsigned getLineNumber() const
DIFile - This is a wrapper for a file.
StringRef getTargetTriple() const
getTargetTriple - Return the target triple string.
dwarf::Tag getTag() const
DIE * getOrCreateTypeDIE(const MDNode *N)
void addUInt(DIE *Die, dwarf::Attribute Attribute, Optional< dwarf::Form > Form, uint64_t Integer)
virtual void EmitIntValue(uint64_t Value, unsigned Size)
size_t size() const
size - Get the array size.
void EmitValue(const MCExpr *Value, unsigned Size)
void addString(DIE *Die, dwarf::Attribute Attribute, const StringRef Str)
const char * GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage)
bool isType() const
isType - Return true if the specified tag is legal for DIType.
LexicalScope * findLexicalScope(DebugLoc DL)
const MachineBasicBlock * getParent() const
static const MCSymbolRefExpr * Create(const MCSymbol *Symbol, MCContext &Ctx)
void Merge(DotDebugLocEntry *Next)
DILexicalBlock - This is a wrapper for a lexical block.
DISubprogram getDISubprogram(const MDNode *Scope)
getDISubprogram - Find subprogram that is enclosing this scope.
bool isDebugValue() const
LexicalScope * findAbstractScope(const MDNode *N)
findAbstractScope - Find an abstract scope or return NULL.
const MCSection * getDwarfGnuPubNamesSection() const
void addUnit(CompileUnit *CU)
Add a unit to the list of CUs.
void addLocalString(DIE *Die, dwarf::Attribute Attribute, const StringRef Str)
unsigned isDefinition() const
initializer< Ty > init(const Ty &Val)
void array_pod_sort(IteratorTy Start, IteratorTy End)
const MCSection * getDwarfInfoSection() const
StringRef getFilename() const
This struct describes location entries emitted in the .debug_loc section.
void computeSizeAndOffsets()
Compute the size and offset of all the DIEs.
static void getObjCClassCategory(StringRef In, StringRef &Class, StringRef &Category)
DIE * getOrCreateContextDIE(DIScope Context)
getOrCreateContextDIE - Get context owner's DIE.
VariableDbgInfoMapTy & getVariableDbgInfo()
unsigned getAbbrevNumber() const
DIDescriptor getElement(unsigned Idx) const
void assignAbbrevNumber(DIEAbbrev &Abbrev)
Define a unique number for the abbreviation.
unsigned getUniqueID() const
const MachineOperand & getOperand(unsigned i) const
DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext)
cleanseInlinedVariable - Remove inlined scope from the variable.
void addDelta(DIE *Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Hi, const MCSymbol *Lo)
bool isCImm() const
isCImm - Test if t his is a MO_CImmediate operand.
const MCSymbol * getBeginSym() const
ItTy next(ItTy it, Dist n)
DIGlobalVariable - This is a wrapper for a global variable.
unsigned getHeaderSize() const
MDNode * getOperand(unsigned i) const
getOperand - Return specified operand.
void addAccelName(StringRef Name, DIE *Die)
addAccelName - Add a new name to the name accelerator table.
bool getFlag(MIFlag Flag) const
getFlag - Return whether an MI flag is set.
LexicalScope * findInlinedScope(DebugLoc DL)
for(unsigned i=0, e=MI->getNumOperands();i!=e;++i)
static bool CUSort(const CompileUnit *A, const CompileUnit *B)
MDNode * getInlinedAt(const LLVMContext &Ctx) const
StringRef getLinkageName() const
void EmitLabelOffsetDifference(const MCSymbol *Hi, uint64_t Offset, const MCSymbol *Lo, unsigned Size) const
bool isAbstractScope() const
unsigned getNumElements() const
const MCSymbol * getEndSym() const
GDBIndexEntryLinkage Linkage
Helper used to pair up a symbol and its DWARF compile unit.
void setMCLineTableSymbol(MCSymbol *Sym, unsigned ID)
void addChild(DIE *Child)
DIE * getDIE(DIDescriptor D) const
uint64_t computeDIEODRSignature(const DIE &Die)
Computes the ODR signature.
uint64_t getValue() const
An imported module (C++ using directive or similar).
const StringMap< DIE * > & getGlobalNames() const
DIScope - A base class for various scopes.
const std::vector< DIE * > & getChildren() const
void constructContainingTypeDIEs()
const StringMap< DIE * > & getGlobalTypes() const
void insertDIE(DIDescriptor Desc, DIE *D)
void EmitSLEB128(int64_t Value, const char *Desc=0) const
EmitSLEB128 - emit the specified signed leb128 value.
void addAddress(DIE *Die, dwarf::Attribute Attribute, const MachineLocation &Location, bool Indirect=false)
SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
DIE * createAndAddDIE(unsigned Tag, DIE &Parent, DIDescriptor N=DIDescriptor())
MDNode * getScope(const LLVMContext &Ctx) const
const MCSection * getDwarfPubTypesSection() const
const DIE * getCompileUnit() const
static bool hasObjCCategory(StringRef Name)
bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
const MCStreamer & Streamer
static bool shouldAddODRHash(CompileUnit *CU, DIE *Die)
void setDebugInfoAvailability(bool avail)
bool isIdenticalTo(const MachineInstr *Other, MICheckType Check=CheckDefs) const
SectionKind getKind() const
virtual void EmitLabel(MCSymbol *Symbol)
DINameSpace - A wrapper for a C++ style name space.
const char * TagString(unsigned Tag)
const MCContext & getContext() const
static DotDebugLocEntry getDebugLocEntry(AsmPrinter *Asm, const MCSymbol *FLabel, const MCSymbol *SLabel, const MachineInstr *MI)
unsigned getStringPoolIndex(StringRef Str)
Returns the index into the string pool with the given string text.
void beginModule()
Emit all Dwarf sections that should come prior to the content.
const StringMap< std::vector< std::pair< DIE *, unsigned > > > & getAccelTypes() const
bool isSubprogramContext(const MDNode *Context)
void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *SectionLabel) const
unsigned getOffset() const
T resolve(DIRef< T > Ref) const
Find the MDNode for the given reference.
static Twine utohexstr(const uint64_t &Val)
const MCSection * getDwarfGnuPubTypesSection() const
void addGlobalName(StringRef Name, DIE *Die, DIScope Context)
addGlobalName - Add a new global name to the compile unit.
DIArray getTypeArray() const
const SmallVectorImpl< DIEValue * > & getValues() const
const MCSection * getDwarfStrSection() const
const MCSection * getDwarfInfoDWOSection() const
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
void emitStrings(const MCSection *StrSection, const MCSection *OffsetSection, const MCSymbol *StrSecSym)
Emit all of the strings to the section given.
DISubprogram getFunctionDeclaration() const
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
const ConstantInt * getCImm() const
static void addSubprogramNames(CompileUnit *TheCU, DISubprogram SP, DIE *Die)
DIScope getContext() const
static cl::opt< bool > GenerateODRHash("generate-odr-hash", cl::Hidden, cl::desc("Add an ODR hash to external type DIEs."), cl::init(false))
static cl::opt< bool > UnknownLocations("use-unknown-locations", cl::Hidden, cl::desc("Make an absence of debug location information explicit."), cl::init(false))
const char * AttributeString(unsigned Attribute)
Value * getModuleFlag(StringRef Key) const
DICompileUnit getNode() const
const MCSection * getDwarfStrOffDWOSection() const
bool isNameSpace() const
isNameSpace - Return true if the specified tag is DW_TAG_namespace.
static DebugLoc get(unsigned Line, unsigned Col, MDNode *Scope, MDNode *InlinedAt=0)
DenseMapIterator< KeyT, ValueT, KeyInfoT > iterator
static dwarf::PubIndexEntryDescriptor computeIndexValue(CompileUnit *CU, DIE *Die)
computeIndexValue - Compute the gdb index value for the DIE and CU.
bundle_iterator< const MachineInstr, const_instr_iterator > const_iterator
MCSymbol * getStringPoolSym()
Returns the entry into the start of the pool.
static StringRef getObjCMethodName(StringRef In)
NamedMDNode * getNamedMetadata(const Twine &Name) const
const char * GDBIndexEntryKindString(GDBIndexEntryKind Kind)
const MCSection * getDwarfAddrSection() const
void EmitULEB128(uint64_t Value, const char *Desc=0, unsigned PadTo=0) const
EmitULEB128 - emit the specified unsigned leb128 value.
const StringMap< std::vector< DIE * > > & getAccelNames() const
unsigned getAddrPoolIndex(const MCExpr *Sym)
Returns the index into the address pool with the given label/symbol.
unsigned getArgNumber() const
MCSymbol * getStringPoolEntry(StringRef Str)
Returns an entry into the string pool with the given string text.
static MDNode * getScopeNode(DebugLoc DL, const LLVMContext &Ctx)
void setOffset(unsigned O)
static bool isContainedInAnonNamespace(DIE *Die)
Return true if the current DIE is contained within an anonymous namespace.
unsigned getRunTimeVersion() const
static cl::opt< DefaultOnOff > DwarfPubSections("generate-dwarf-pub-sections", cl::Hidden, cl::desc("Generate DWARF pubnames and pubtypes sections"), cl::values(clEnumVal(Default,"Default for platform"), clEnumVal(Enable,"Enabled"), clEnumVal(Disable,"Disabled"), clEnumValEnd), cl::init(Default))
static DebugLoc getFromDILocation(MDNode *N)
getFromDILocation - Translate the DILocation quad into a DebugLoc.
const TargetMachine & getTarget() const
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
const SmallVectorImpl< DIEAbbrevData > & getData() const
bool isEmpty()
Empty entries are also used as a trigger to emit temp label. Such labels are referenced is used to fi...
virtual const TargetRegisterInfo * getRegisterInfo() const
const char * AccessibilityString(unsigned Access)
bool useSplitDwarf()
Returns whether or not to change the current debug info for the split dwarf proposal support...
const MCSection * getDwarfARangesSection() const
void addFlag(DIE *Die, dwarf::Attribute Attribute)
addFlag - Add a flag that is true to the DIE.
void set(unsigned R)
Make this location a direct register location.
bool hasMCUseLoc() const
hasMCUseLoc - Check whether we should use dwarf's .loc directive.
unsigned getReg() const
getReg - Returns the register number.
const MCSection * getDwarfAccelTypesSection() const
const TargetLoweringObjectFile & getObjFileLowering() const
getObjFileLowering - Return information about object file lowering.
const StringMap< std::vector< DIE * > > & getAccelNamespace() const
static const char *const DWARFGroupName
void addType(DIE *Entity, DIType Ty, dwarf::Attribute Attribute=dwarf::DW_AT_type)
addType - Add a new type attribute to the specified entity.
dwarf::Tag getTag() const
unsigned computeSizeAndOffset(DIE *Die, unsigned Offset)
Compute the size and offset of a DIE given an incoming Offset.
static unsigned getULEB128Size(uint64_t Value)
StringRef getName() const
LLVM Value Representation.
mop_iterator operands_begin()
ValueT lookup(const KeyT &Val) const
unsigned getScopeLineNumber() const
const StringMap< std::vector< DIE * > > & getAccelObjC() const
void beginInstruction(const MachineInstr *MI)
Process beginning of an instruction.
void addDIEEntry(DIE *Die, dwarf::Attribute Attribute, DIE *Entry)
void addLabelAddress(DIE *Die, dwarf::Attribute Attribute, MCSymbol *Label)
DIArray getVariables() const
unsigned getNumOperands() const
getNumOperands - Return the number of NamedMDNode operands.
uint16_t getChildrenFlag() const
void Emit(AsmPrinter *AP) const
const MachineBasicBlock & back() const
void EmitSymbolValue(const MCSymbol *Sym, unsigned Size)
void emitUnits(DwarfDebug *DD, const MCSection *USection, const MCSection *ASection, const MCSymbol *ASectionSym)
Emit all of the units to the section listed with the given abbreviation section.
bool isCompileUnit() const
isCompileUnit - Return true if the specified tag is DW_TAG_compile_unit.
MCSymbol * GetTempSymbol(StringRef Name, unsigned ID) const
StringRef slice(size_t Start, size_t End) const
bool TimePassesIsEnabled
This is the storage for the -time-passes option.
static const unsigned InitAbbreviationsSetSize
DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes)
Construct DITypeIdentifierMap by going through retained types of each CU.
static bool isObjCClass(StringRef Name)
DICompileUnit - A wrapper for a compile unit.
iterator find(const KeyT &Val)
static unsigned getRefAddrSize(AsmPrinter *AP)
Returns size of a ref_addr entry.
StringRef getProducer() const
Function object to check whether the first component of a std::pair compares less than the first comp...
void emitDIE(DIE *Die, ArrayRef< DIEAbbrev * > Abbrevs)
Recursively Emits a debug information entry.
bool doesDwarfUseRelocationsAcrossSections() const
DebugLoc getDebugLoc() const
static unsigned getDwarfVersionFromModule(const Module *M)
Return Dwarf Version by checking module flags.
bool empty()
empty - Return true if there is any lexical scope information available.
void beginFunction(const MachineFunction *MF)
Gather pre-function debug information.
bool isFile() const
isFile - Return true if the specified tag is DW_TAG_file_type.
void addAccelObjC(StringRef Name, DIE *Die)
addAccelObjC - Add a new name to the ObjC accelerator table.
unsigned getLanguage() const
unsigned getNumber() const
LLVMContext & getContext() const
const MCSection * getDwarfAbbrevDWOSection() const
bool empty() const
empty - Check if the string is empty.
DIBasicType - A basic type, like 'int' or 'float'.
void endModule()
Emit all Dwarf sections that should come after the content.
StringRef getSplitDebugFilename() const