1 //===-- llvm/CodeGen/DwarfDebug.cpp - Dwarf Debug Framework ---------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains support for writing dwarf debug info into asm files.
12 //===----------------------------------------------------------------------===//
14 #include "DwarfDebug.h"
15 #include "llvm/Module.h"
16 #include "llvm/CodeGen/MachineModuleInfo.h"
17 #include "llvm/Support/Timer.h"
18 #include "llvm/System/Path.h"
19 #include "llvm/Target/TargetAsmInfo.h"
20 #include "llvm/Target/TargetRegisterInfo.h"
21 #include "llvm/Target/TargetData.h"
22 #include "llvm/Target/TargetFrameInfo.h"
25 static TimerGroup &getDwarfTimerGroup() {
26 static TimerGroup DwarfTimerGroup("Dwarf Debugging");
27 return DwarfTimerGroup;
30 //===----------------------------------------------------------------------===//
32 /// Configuration values for initial hash set sizes (log2).
34 static const unsigned InitDiesSetSize = 9; // log2(512)
35 static const unsigned InitAbbreviationsSetSize = 9; // log2(512)
36 static const unsigned InitValuesSetSize = 9; // log2(512)
40 //===----------------------------------------------------------------------===//
41 /// CompileUnit - This dwarf writer support class manages information associate
42 /// with a source file.
43 class VISIBILITY_HIDDEN CompileUnit {
44 /// ID - File identifier for source.
48 /// Die - Compile unit debug information entry.
52 /// GVToDieMap - Tracks the mapping of unit level debug informaton
53 /// variables to debug information entries.
54 std::map<GlobalVariable *, DIE *> GVToDieMap;
56 /// GVToDIEEntryMap - Tracks the mapping of unit level debug informaton
57 /// descriptors to debug information entries using a DIEEntry proxy.
58 std::map<GlobalVariable *, DIEEntry *> GVToDIEEntryMap;
60 /// Globals - A map of globally visible named entities for this unit.
62 StringMap<DIE*> Globals;
64 /// DiesSet - Used to uniquely define dies within the compile unit.
66 FoldingSet<DIE> DiesSet;
68 CompileUnit(unsigned I, DIE *D)
69 : ID(I), Die(D), DiesSet(InitDiesSetSize) {}
70 ~CompileUnit() { delete Die; }
73 unsigned getID() const { return ID; }
74 DIE* getDie() const { return Die; }
75 StringMap<DIE*> &getGlobals() { return Globals; }
77 /// hasContent - Return true if this compile unit has something to write out.
79 bool hasContent() const { return !Die->getChildren().empty(); }
81 /// AddGlobal - Add a new global entity to the compile unit.
83 void AddGlobal(const std::string &Name, DIE *Die) { Globals[Name] = Die; }
85 /// getDieMapSlotFor - Returns the debug information entry map slot for the
86 /// specified debug variable.
87 DIE *&getDieMapSlotFor(GlobalVariable *GV) { return GVToDieMap[GV]; }
89 /// getDIEEntrySlotFor - Returns the debug information entry proxy slot for the
90 /// specified debug variable.
91 DIEEntry *&getDIEEntrySlotFor(GlobalVariable *GV) {
92 return GVToDIEEntryMap[GV];
95 /// AddDie - Adds or interns the DIE to the compile unit.
97 DIE *AddDie(DIE &Buffer) {
101 DIE *Die = DiesSet.FindNodeOrInsertPos(ID, Where);
104 Die = new DIE(Buffer);
105 DiesSet.InsertNode(Die, Where);
106 this->Die->AddChild(Die);
114 //===----------------------------------------------------------------------===//
115 /// DbgVariable - This class is used to track local variable information.
117 class VISIBILITY_HIDDEN DbgVariable {
118 DIVariable Var; // Variable Descriptor.
119 unsigned FrameIndex; // Variable frame index.
120 bool InlinedFnVar; // Variable for an inlined function.
122 DbgVariable(DIVariable V, unsigned I, bool IFV)
123 : Var(V), FrameIndex(I), InlinedFnVar(IFV) {}
126 DIVariable getVariable() const { return Var; }
127 unsigned getFrameIndex() const { return FrameIndex; }
128 bool isInlinedFnVar() const { return InlinedFnVar; }
131 //===----------------------------------------------------------------------===//
132 /// DbgScope - This class is used to track scope information.
134 class DbgConcreteScope;
135 class VISIBILITY_HIDDEN DbgScope {
136 DbgScope *Parent; // Parent to this scope.
137 DIDescriptor Desc; // Debug info descriptor for scope.
138 // Either subprogram or block.
139 unsigned StartLabelID; // Label ID of the beginning of scope.
140 unsigned EndLabelID; // Label ID of the end of scope.
141 SmallVector<DbgScope *, 4> Scopes; // Scopes defined in scope.
142 SmallVector<DbgVariable *, 8> Variables;// Variables declared in scope.
143 SmallVector<DbgConcreteScope *, 8> ConcreteInsts;// Concrete insts of funcs.
145 // Private state for dump()
146 mutable unsigned IndentLevel;
148 DbgScope(DbgScope *P, DIDescriptor D)
149 : Parent(P), Desc(D), StartLabelID(0), EndLabelID(0), IndentLevel(0) {}
153 DbgScope *getParent() const { return Parent; }
154 DIDescriptor getDesc() const { return Desc; }
155 unsigned getStartLabelID() const { return StartLabelID; }
156 unsigned getEndLabelID() const { return EndLabelID; }
157 SmallVector<DbgScope *, 4> &getScopes() { return Scopes; }
158 SmallVector<DbgVariable *, 8> &getVariables() { return Variables; }
159 SmallVector<DbgConcreteScope*,8> &getConcreteInsts() { return ConcreteInsts; }
160 void setStartLabelID(unsigned S) { StartLabelID = S; }
161 void setEndLabelID(unsigned E) { EndLabelID = E; }
163 /// AddScope - Add a scope to the scope.
165 void AddScope(DbgScope *S) { Scopes.push_back(S); }
167 /// AddVariable - Add a variable to the scope.
169 void AddVariable(DbgVariable *V) { Variables.push_back(V); }
171 /// AddConcreteInst - Add a concrete instance to the scope.
173 void AddConcreteInst(DbgConcreteScope *C) { ConcreteInsts.push_back(C); }
181 void DbgScope::dump() const {
182 std::string Indent(IndentLevel, ' ');
184 cerr << Indent; Desc.dump();
185 cerr << " [" << StartLabelID << ", " << EndLabelID << "]\n";
189 for (unsigned i = 0, e = Scopes.size(); i != e; ++i)
190 if (Scopes[i] != this)
197 //===----------------------------------------------------------------------===//
198 /// DbgConcreteScope - This class is used to track a scope that holds concrete
199 /// instance information.
201 class VISIBILITY_HIDDEN DbgConcreteScope : public DbgScope {
203 DIE *Die; // Debug info for this concrete scope.
205 DbgConcreteScope(DIDescriptor D) : DbgScope(NULL, D) {}
208 DIE *getDie() const { return Die; }
209 void setDie(DIE *D) { Die = D; }
212 DbgScope::~DbgScope() {
213 for (unsigned i = 0, N = Scopes.size(); i < N; ++i)
215 for (unsigned j = 0, M = Variables.size(); j < M; ++j)
217 for (unsigned k = 0, O = ConcreteInsts.size(); k < O; ++k)
218 delete ConcreteInsts[k];
221 } // end llvm namespace
223 DwarfDebug::DwarfDebug(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
224 : Dwarf(OS, A, T, "dbg"), MainCU(0),
225 AbbreviationsSet(InitAbbreviationsSetSize), Abbreviations(),
226 ValuesSet(InitValuesSetSize), Values(), StringPool(), SectionMap(),
227 SectionSourceLines(), didInitial(false), shouldEmit(false),
228 FunctionDbgScope(0), DebugTimer(0) {
229 if (TimePassesIsEnabled)
230 DebugTimer = new Timer("Dwarf Debug Writer",
231 getDwarfTimerGroup());
233 DwarfDebug::~DwarfDebug() {
234 for (unsigned j = 0, M = Values.size(); j < M; ++j)
237 for (DenseMap<const GlobalVariable *, DbgScope *>::iterator
238 I = AbstractInstanceRootMap.begin(),
239 E = AbstractInstanceRootMap.end(); I != E;++I)
245 /// AssignAbbrevNumber - Define a unique number for the abbreviation.
247 void DwarfDebug::AssignAbbrevNumber(DIEAbbrev &Abbrev) {
248 // Profile the node so that we can make it unique.
252 // Check the set for priors.
253 DIEAbbrev *InSet = AbbreviationsSet.GetOrInsertNode(&Abbrev);
255 // If it's newly added.
256 if (InSet == &Abbrev) {
257 // Add to abbreviation list.
258 Abbreviations.push_back(&Abbrev);
260 // Assign the vector position + 1 as its number.
261 Abbrev.setNumber(Abbreviations.size());
263 // Assign existing abbreviation number.
264 Abbrev.setNumber(InSet->getNumber());
268 /// CreateDIEEntry - Creates a new DIEEntry to be a proxy for a debug
269 /// information entry.
270 DIEEntry *DwarfDebug::CreateDIEEntry(DIE *Entry) {
275 DIEEntry::Profile(ID, Entry);
277 Value = static_cast<DIEEntry *>(ValuesSet.FindNodeOrInsertPos(ID, Where));
279 if (Value) return Value;
281 Value = new DIEEntry(Entry);
282 ValuesSet.InsertNode(Value, Where);
284 Value = new DIEEntry(Entry);
287 Values.push_back(Value);
291 /// SetDIEEntry - Set a DIEEntry once the debug information entry is defined.
293 void DwarfDebug::SetDIEEntry(DIEEntry *Value, DIE *Entry) {
294 Value->setEntry(Entry);
296 // Add to values set if not already there. If it is, we merely have a
297 // duplicate in the values list (no harm.)
298 ValuesSet.GetOrInsertNode(Value);
301 /// AddUInt - Add an unsigned integer attribute data and value.
303 void DwarfDebug::AddUInt(DIE *Die, unsigned Attribute,
304 unsigned Form, uint64_t Integer) {
305 if (!Form) Form = DIEInteger::BestForm(false, Integer);
308 DIEInteger::Profile(ID, Integer);
310 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
313 Value = new DIEInteger(Integer);
314 ValuesSet.InsertNode(Value, Where);
315 Values.push_back(Value);
318 Die->AddValue(Attribute, Form, Value);
321 /// AddSInt - Add an signed integer attribute data and value.
323 void DwarfDebug::AddSInt(DIE *Die, unsigned Attribute,
324 unsigned Form, int64_t Integer) {
325 if (!Form) Form = DIEInteger::BestForm(true, Integer);
328 DIEInteger::Profile(ID, (uint64_t)Integer);
330 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
333 Value = new DIEInteger(Integer);
334 ValuesSet.InsertNode(Value, Where);
335 Values.push_back(Value);
338 Die->AddValue(Attribute, Form, Value);
341 /// AddString - Add a string attribute data and value.
343 void DwarfDebug::AddString(DIE *Die, unsigned Attribute, unsigned Form,
344 const std::string &String) {
346 DIEString::Profile(ID, String);
348 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
351 Value = new DIEString(String);
352 ValuesSet.InsertNode(Value, Where);
353 Values.push_back(Value);
356 Die->AddValue(Attribute, Form, Value);
359 /// AddLabel - Add a Dwarf label attribute data and value.
361 void DwarfDebug::AddLabel(DIE *Die, unsigned Attribute, unsigned Form,
362 const DWLabel &Label) {
364 DIEDwarfLabel::Profile(ID, Label);
366 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
369 Value = new DIEDwarfLabel(Label);
370 ValuesSet.InsertNode(Value, Where);
371 Values.push_back(Value);
374 Die->AddValue(Attribute, Form, Value);
377 /// AddObjectLabel - Add an non-Dwarf label attribute data and value.
379 void DwarfDebug::AddObjectLabel(DIE *Die, unsigned Attribute, unsigned Form,
380 const std::string &Label) {
382 DIEObjectLabel::Profile(ID, Label);
384 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
387 Value = new DIEObjectLabel(Label);
388 ValuesSet.InsertNode(Value, Where);
389 Values.push_back(Value);
392 Die->AddValue(Attribute, Form, Value);
395 /// AddSectionOffset - Add a section offset label attribute data and value.
397 void DwarfDebug::AddSectionOffset(DIE *Die, unsigned Attribute, unsigned Form,
398 const DWLabel &Label, const DWLabel &Section,
399 bool isEH, bool useSet) {
401 DIESectionOffset::Profile(ID, Label, Section);
403 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
406 Value = new DIESectionOffset(Label, Section, isEH, useSet);
407 ValuesSet.InsertNode(Value, Where);
408 Values.push_back(Value);
411 Die->AddValue(Attribute, Form, Value);
414 /// AddDelta - Add a label delta attribute data and value.
416 void DwarfDebug::AddDelta(DIE *Die, unsigned Attribute, unsigned Form,
417 const DWLabel &Hi, const DWLabel &Lo) {
419 DIEDelta::Profile(ID, Hi, Lo);
421 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
424 Value = new DIEDelta(Hi, Lo);
425 ValuesSet.InsertNode(Value, Where);
426 Values.push_back(Value);
429 Die->AddValue(Attribute, Form, Value);
432 /// AddBlock - Add block data.
434 void DwarfDebug::AddBlock(DIE *Die, unsigned Attribute, unsigned Form,
436 Block->ComputeSize(TD);
440 DIEValue *Value = ValuesSet.FindNodeOrInsertPos(ID, Where);
444 ValuesSet.InsertNode(Value, Where);
445 Values.push_back(Value);
447 // Already exists, reuse the previous one.
449 Block = cast<DIEBlock>(Value);
452 Die->AddValue(Attribute, Block->BestForm(), Value);
455 /// AddSourceLine - Add location information to specified debug information
457 void DwarfDebug::AddSourceLine(DIE *Die, const DIVariable *V) {
458 // If there is no compile unit specified, don't add a line #.
459 if (V->getCompileUnit().isNull())
462 unsigned Line = V->getLineNumber();
463 unsigned FileID = FindCompileUnit(V->getCompileUnit()).getID();
464 assert(FileID && "Invalid file id");
465 AddUInt(Die, dwarf::DW_AT_decl_file, 0, FileID);
466 AddUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
469 /// AddSourceLine - Add location information to specified debug information
471 void DwarfDebug::AddSourceLine(DIE *Die, const DIGlobal *G) {
472 // If there is no compile unit specified, don't add a line #.
473 if (G->getCompileUnit().isNull())
476 unsigned Line = G->getLineNumber();
477 unsigned FileID = FindCompileUnit(G->getCompileUnit()).getID();
478 assert(FileID && "Invalid file id");
479 AddUInt(Die, dwarf::DW_AT_decl_file, 0, FileID);
480 AddUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
482 void DwarfDebug::AddSourceLine(DIE *Die, const DIType *Ty) {
483 // If there is no compile unit specified, don't add a line #.
484 DICompileUnit CU = Ty->getCompileUnit();
488 unsigned Line = Ty->getLineNumber();
489 unsigned FileID = FindCompileUnit(CU).getID();
490 assert(FileID && "Invalid file id");
491 AddUInt(Die, dwarf::DW_AT_decl_file, 0, FileID);
492 AddUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
495 /// AddAddress - Add an address attribute to a die based on the location
497 void DwarfDebug::AddAddress(DIE *Die, unsigned Attribute,
498 const MachineLocation &Location) {
499 unsigned Reg = RI->getDwarfRegNum(Location.getReg(), false);
500 DIEBlock *Block = new DIEBlock();
502 if (Location.isReg()) {
504 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_reg0 + Reg);
506 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_regx);
507 AddUInt(Block, 0, dwarf::DW_FORM_udata, Reg);
511 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + Reg);
513 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_bregx);
514 AddUInt(Block, 0, dwarf::DW_FORM_udata, Reg);
517 AddUInt(Block, 0, dwarf::DW_FORM_sdata, Location.getOffset());
520 AddBlock(Die, Attribute, 0, Block);
523 /// AddType - Add a new type attribute to the specified entity.
524 void DwarfDebug::AddType(CompileUnit *DW_Unit, DIE *Entity, DIType Ty) {
528 // Check for pre-existence.
529 DIEEntry *&Slot = DW_Unit->getDIEEntrySlotFor(Ty.getGV());
531 // If it exists then use the existing value.
533 Entity->AddValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Slot);
538 Slot = CreateDIEEntry();
541 DIE Buffer(dwarf::DW_TAG_base_type);
542 if (Ty.isBasicType(Ty.getTag()))
543 ConstructTypeDIE(DW_Unit, Buffer, DIBasicType(Ty.getGV()));
544 else if (Ty.isDerivedType(Ty.getTag()))
545 ConstructTypeDIE(DW_Unit, Buffer, DIDerivedType(Ty.getGV()));
547 assert(Ty.isCompositeType(Ty.getTag()) && "Unknown kind of DIType");
548 ConstructTypeDIE(DW_Unit, Buffer, DICompositeType(Ty.getGV()));
551 // Add debug information entry to entity and appropriate context.
553 DIDescriptor Context = Ty.getContext();
554 if (!Context.isNull())
555 Die = DW_Unit->getDieMapSlotFor(Context.getGV());
558 DIE *Child = new DIE(Buffer);
559 Die->AddChild(Child);
561 SetDIEEntry(Slot, Child);
563 Die = DW_Unit->AddDie(Buffer);
564 SetDIEEntry(Slot, Die);
567 Entity->AddValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Slot);
570 /// ConstructTypeDIE - Construct basic type die from DIBasicType.
571 void DwarfDebug::ConstructTypeDIE(CompileUnit *DW_Unit, DIE &Buffer,
573 // Get core information.
576 Buffer.setTag(dwarf::DW_TAG_base_type);
577 AddUInt(&Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
580 // Add name if not anonymous or intermediate type.
582 AddString(&Buffer, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
583 uint64_t Size = BTy.getSizeInBits() >> 3;
584 AddUInt(&Buffer, dwarf::DW_AT_byte_size, 0, Size);
587 /// ConstructTypeDIE - Construct derived type die from DIDerivedType.
588 void DwarfDebug::ConstructTypeDIE(CompileUnit *DW_Unit, DIE &Buffer,
590 // Get core information.
593 uint64_t Size = DTy.getSizeInBits() >> 3;
594 unsigned Tag = DTy.getTag();
596 // FIXME - Workaround for templates.
597 if (Tag == dwarf::DW_TAG_inheritance) Tag = dwarf::DW_TAG_reference_type;
601 // Map to main type, void will not have a type.
602 DIType FromTy = DTy.getTypeDerivedFrom();
603 AddType(DW_Unit, &Buffer, FromTy);
605 // Add name if not anonymous or intermediate type.
607 AddString(&Buffer, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
609 // Add size if non-zero (derived types might be zero-sized.)
611 AddUInt(&Buffer, dwarf::DW_AT_byte_size, 0, Size);
613 // Add source line info if available and TyDesc is not a forward declaration.
614 if (!DTy.isForwardDecl())
615 AddSourceLine(&Buffer, &DTy);
618 /// ConstructTypeDIE - Construct type DIE from DICompositeType.
619 void DwarfDebug::ConstructTypeDIE(CompileUnit *DW_Unit, DIE &Buffer,
620 DICompositeType CTy) {
621 // Get core information.
625 uint64_t Size = CTy.getSizeInBits() >> 3;
626 unsigned Tag = CTy.getTag();
630 case dwarf::DW_TAG_vector_type:
631 case dwarf::DW_TAG_array_type:
632 ConstructArrayTypeDIE(DW_Unit, Buffer, &CTy);
634 case dwarf::DW_TAG_enumeration_type: {
635 DIArray Elements = CTy.getTypeArray();
637 // Add enumerators to enumeration type.
638 for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
640 DIEnumerator Enum(Elements.getElement(i).getGV());
641 ElemDie = ConstructEnumTypeDIE(DW_Unit, &Enum);
642 Buffer.AddChild(ElemDie);
646 case dwarf::DW_TAG_subroutine_type: {
648 DIArray Elements = CTy.getTypeArray();
649 DIDescriptor RTy = Elements.getElement(0);
650 AddType(DW_Unit, &Buffer, DIType(RTy.getGV()));
652 // Add prototype flag.
653 AddUInt(&Buffer, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1);
656 for (unsigned i = 1, N = Elements.getNumElements(); i < N; ++i) {
657 DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
658 DIDescriptor Ty = Elements.getElement(i);
659 AddType(DW_Unit, Arg, DIType(Ty.getGV()));
660 Buffer.AddChild(Arg);
664 case dwarf::DW_TAG_structure_type:
665 case dwarf::DW_TAG_union_type:
666 case dwarf::DW_TAG_class_type: {
667 // Add elements to structure type.
668 DIArray Elements = CTy.getTypeArray();
670 // A forward struct declared type may not have elements available.
671 if (Elements.isNull())
674 // Add elements to structure type.
675 for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
676 DIDescriptor Element = Elements.getElement(i);
678 if (Element.getTag() == dwarf::DW_TAG_subprogram)
679 ElemDie = CreateSubprogramDIE(DW_Unit,
680 DISubprogram(Element.getGV()));
681 else if (Element.getTag() == dwarf::DW_TAG_variable) // ??
682 ElemDie = CreateGlobalVariableDIE(DW_Unit,
683 DIGlobalVariable(Element.getGV()));
685 ElemDie = CreateMemberDIE(DW_Unit,
686 DIDerivedType(Element.getGV()));
687 Buffer.AddChild(ElemDie);
690 // FIXME: We'd like an API to register additional attributes for the
691 // frontend to use while synthesizing, and then we'd use that api in clang
693 if (Name == "__block_literal_generic")
694 AddUInt(&Buffer, dwarf::DW_AT_APPLE_block, dwarf::DW_FORM_flag, 1);
696 unsigned RLang = CTy.getRunTimeLang();
698 AddUInt(&Buffer, dwarf::DW_AT_APPLE_runtime_class,
699 dwarf::DW_FORM_data1, RLang);
706 // Add name if not anonymous or intermediate type.
708 AddString(&Buffer, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
710 if (Tag == dwarf::DW_TAG_enumeration_type ||
711 Tag == dwarf::DW_TAG_structure_type || Tag == dwarf::DW_TAG_union_type) {
712 // Add size if non-zero (derived types might be zero-sized.)
714 AddUInt(&Buffer, dwarf::DW_AT_byte_size, 0, Size);
716 // Add zero size if it is not a forward declaration.
717 if (CTy.isForwardDecl())
718 AddUInt(&Buffer, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
720 AddUInt(&Buffer, dwarf::DW_AT_byte_size, 0, 0);
723 // Add source line info if available.
724 if (!CTy.isForwardDecl())
725 AddSourceLine(&Buffer, &CTy);
729 /// ConstructSubrangeDIE - Construct subrange DIE from DISubrange.
730 void DwarfDebug::ConstructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy){
731 int64_t L = SR.getLo();
732 int64_t H = SR.getHi();
733 DIE *DW_Subrange = new DIE(dwarf::DW_TAG_subrange_type);
736 AddDIEEntry(DW_Subrange, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IndexTy);
738 AddSInt(DW_Subrange, dwarf::DW_AT_lower_bound, 0, L);
739 AddSInt(DW_Subrange, dwarf::DW_AT_upper_bound, 0, H);
742 Buffer.AddChild(DW_Subrange);
745 /// ConstructArrayTypeDIE - Construct array type DIE from DICompositeType.
746 void DwarfDebug::ConstructArrayTypeDIE(CompileUnit *DW_Unit, DIE &Buffer,
747 DICompositeType *CTy) {
748 Buffer.setTag(dwarf::DW_TAG_array_type);
749 if (CTy->getTag() == dwarf::DW_TAG_vector_type)
750 AddUInt(&Buffer, dwarf::DW_AT_GNU_vector, dwarf::DW_FORM_flag, 1);
752 // Emit derived type.
753 AddType(DW_Unit, &Buffer, CTy->getTypeDerivedFrom());
754 DIArray Elements = CTy->getTypeArray();
756 // Construct an anonymous type for index type.
757 DIE IdxBuffer(dwarf::DW_TAG_base_type);
758 AddUInt(&IdxBuffer, dwarf::DW_AT_byte_size, 0, sizeof(int32_t));
759 AddUInt(&IdxBuffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
760 dwarf::DW_ATE_signed);
761 DIE *IndexTy = DW_Unit->AddDie(IdxBuffer);
763 // Add subranges to array type.
764 for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
765 DIDescriptor Element = Elements.getElement(i);
766 if (Element.getTag() == dwarf::DW_TAG_subrange_type)
767 ConstructSubrangeDIE(Buffer, DISubrange(Element.getGV()), IndexTy);
771 /// ConstructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
772 DIE *DwarfDebug::ConstructEnumTypeDIE(CompileUnit *DW_Unit, DIEnumerator *ETy) {
773 DIE *Enumerator = new DIE(dwarf::DW_TAG_enumerator);
776 AddString(Enumerator, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
777 int64_t Value = ETy->getEnumValue();
778 AddSInt(Enumerator, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, Value);
782 /// CreateGlobalVariableDIE - Create new DIE using GV.
783 DIE *DwarfDebug::CreateGlobalVariableDIE(CompileUnit *DW_Unit,
784 const DIGlobalVariable &GV) {
785 DIE *GVDie = new DIE(dwarf::DW_TAG_variable);
787 GV.getDisplayName(Name);
788 AddString(GVDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
789 std::string LinkageName;
790 GV.getLinkageName(LinkageName);
791 if (!LinkageName.empty())
792 AddString(GVDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string,
794 AddType(DW_Unit, GVDie, GV.getType());
795 if (!GV.isLocalToUnit())
796 AddUInt(GVDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1);
797 AddSourceLine(GVDie, &GV);
801 /// CreateMemberDIE - Create new member DIE.
802 DIE *DwarfDebug::CreateMemberDIE(CompileUnit *DW_Unit, const DIDerivedType &DT){
803 DIE *MemberDie = new DIE(DT.getTag());
807 AddString(MemberDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
809 AddType(DW_Unit, MemberDie, DT.getTypeDerivedFrom());
811 AddSourceLine(MemberDie, &DT);
813 uint64_t Size = DT.getSizeInBits();
814 uint64_t FieldSize = DT.getOriginalTypeSize();
816 if (Size != FieldSize) {
818 AddUInt(MemberDie, dwarf::DW_AT_byte_size, 0, DT.getOriginalTypeSize()>>3);
819 AddUInt(MemberDie, dwarf::DW_AT_bit_size, 0, DT.getSizeInBits());
821 uint64_t Offset = DT.getOffsetInBits();
822 uint64_t FieldOffset = Offset;
823 uint64_t AlignMask = ~(DT.getAlignInBits() - 1);
824 uint64_t HiMark = (Offset + FieldSize) & AlignMask;
825 FieldOffset = (HiMark - FieldSize);
826 Offset -= FieldOffset;
828 // Maybe we need to work from the other end.
829 if (TD->isLittleEndian()) Offset = FieldSize - (Offset + Size);
830 AddUInt(MemberDie, dwarf::DW_AT_bit_offset, 0, Offset);
833 DIEBlock *Block = new DIEBlock();
834 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
835 AddUInt(Block, 0, dwarf::DW_FORM_udata, DT.getOffsetInBits() >> 3);
836 AddBlock(MemberDie, dwarf::DW_AT_data_member_location, 0, Block);
838 if (DT.isProtected())
839 AddUInt(MemberDie, dwarf::DW_AT_accessibility, 0,
840 dwarf::DW_ACCESS_protected);
841 else if (DT.isPrivate())
842 AddUInt(MemberDie, dwarf::DW_AT_accessibility, 0,
843 dwarf::DW_ACCESS_private);
848 /// CreateSubprogramDIE - Create new DIE using SP.
849 DIE *DwarfDebug::CreateSubprogramDIE(CompileUnit *DW_Unit,
850 const DISubprogram &SP,
853 DIE *SPDie = new DIE(dwarf::DW_TAG_subprogram);
857 AddString(SPDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
859 std::string LinkageName;
860 SP.getLinkageName(LinkageName);
862 if (!LinkageName.empty())
863 AddString(SPDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string,
866 AddSourceLine(SPDie, &SP);
868 DICompositeType SPTy = SP.getType();
869 DIArray Args = SPTy.getTypeArray();
871 // Add prototyped tag, if C or ObjC.
872 unsigned Lang = SP.getCompileUnit().getLanguage();
873 if (Lang == dwarf::DW_LANG_C99 || Lang == dwarf::DW_LANG_C89 ||
874 Lang == dwarf::DW_LANG_ObjC)
875 AddUInt(SPDie, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1);
878 unsigned SPTag = SPTy.getTag();
879 if (!IsConstructor) {
880 if (Args.isNull() || SPTag != dwarf::DW_TAG_subroutine_type)
881 AddType(DW_Unit, SPDie, SPTy);
883 AddType(DW_Unit, SPDie, DIType(Args.getElement(0).getGV()));
886 if (!SP.isDefinition()) {
887 AddUInt(SPDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
889 // Add arguments. Do not add arguments for subprogram definition. They will
890 // be handled through RecordVariable.
891 if (SPTag == dwarf::DW_TAG_subroutine_type)
892 for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
893 DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
894 AddType(DW_Unit, Arg, DIType(Args.getElement(i).getGV()));
895 AddUInt(Arg, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1); // ??
896 SPDie->AddChild(Arg);
900 if (!SP.isLocalToUnit() && !IsInlined)
901 AddUInt(SPDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1);
903 // DW_TAG_inlined_subroutine may refer to this DIE.
904 DIE *&Slot = DW_Unit->getDieMapSlotFor(SP.getGV());
909 /// FindCompileUnit - Get the compile unit for the given descriptor.
911 CompileUnit &DwarfDebug::FindCompileUnit(DICompileUnit Unit) const {
912 DenseMap<Value *, CompileUnit *>::const_iterator I =
913 CompileUnitMap.find(Unit.getGV());
914 assert(I != CompileUnitMap.end() && "Missing compile unit.");
918 /// CreateDbgScopeVariable - Create a new scope variable.
920 DIE *DwarfDebug::CreateDbgScopeVariable(DbgVariable *DV, CompileUnit *Unit) {
921 // Get the descriptor.
922 const DIVariable &VD = DV->getVariable();
924 // Translate tag to proper Dwarf tag. The result variable is dropped for
927 switch (VD.getTag()) {
928 case dwarf::DW_TAG_return_variable:
930 case dwarf::DW_TAG_arg_variable:
931 Tag = dwarf::DW_TAG_formal_parameter;
933 case dwarf::DW_TAG_auto_variable: // fall thru
935 Tag = dwarf::DW_TAG_variable;
939 // Define variable debug information entry.
940 DIE *VariableDie = new DIE(Tag);
943 AddString(VariableDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
945 // Add source line info if available.
946 AddSourceLine(VariableDie, &VD);
948 // Add variable type.
949 AddType(Unit, VariableDie, VD.getType());
951 // Add variable address.
952 if (!DV->isInlinedFnVar()) {
953 // Variables for abstract instances of inlined functions don't get a
955 MachineLocation Location;
956 Location.set(RI->getFrameRegister(*MF),
957 RI->getFrameIndexOffset(*MF, DV->getFrameIndex()));
958 AddAddress(VariableDie, dwarf::DW_AT_location, Location);
964 /// getOrCreateScope - Returns the scope associated with the given descriptor.
966 DbgScope *DwarfDebug::getOrCreateScope(GlobalVariable *V) {
967 DbgScope *&Slot = DbgScopeMap[V];
968 if (Slot) return Slot;
970 DbgScope *Parent = NULL;
973 // Don't create a new scope if we already created one for an inlined function.
974 DenseMap<const GlobalVariable *, DbgScope *>::iterator
975 II = AbstractInstanceRootMap.find(V);
976 if (II != AbstractInstanceRootMap.end())
977 return LexicalScopeStack.back();
979 if (!Block.isNull()) {
980 DIDescriptor ParentDesc = Block.getContext();
982 ParentDesc.isNull() ? NULL : getOrCreateScope(ParentDesc.getGV());
985 Slot = new DbgScope(Parent, DIDescriptor(V));
988 Parent->AddScope(Slot);
990 // First function is top level function.
991 FunctionDbgScope = Slot;
996 /// ConstructDbgScope - Construct the components of a scope.
998 void DwarfDebug::ConstructDbgScope(DbgScope *ParentScope,
999 unsigned ParentStartID,
1000 unsigned ParentEndID,
1001 DIE *ParentDie, CompileUnit *Unit) {
1002 // Add variables to scope.
1003 SmallVector<DbgVariable *, 8> &Variables = ParentScope->getVariables();
1004 for (unsigned i = 0, N = Variables.size(); i < N; ++i) {
1005 DIE *VariableDie = CreateDbgScopeVariable(Variables[i], Unit);
1006 if (VariableDie) ParentDie->AddChild(VariableDie);
1009 // Add concrete instances to scope.
1010 SmallVector<DbgConcreteScope *, 8> &ConcreteInsts =
1011 ParentScope->getConcreteInsts();
1012 for (unsigned i = 0, N = ConcreteInsts.size(); i < N; ++i) {
1013 DbgConcreteScope *ConcreteInst = ConcreteInsts[i];
1014 DIE *Die = ConcreteInst->getDie();
1016 unsigned StartID = ConcreteInst->getStartLabelID();
1017 unsigned EndID = ConcreteInst->getEndLabelID();
1019 // Add the scope bounds.
1021 AddLabel(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1022 DWLabel("label", StartID));
1024 AddLabel(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1025 DWLabel("func_begin", SubprogramCount));
1028 AddLabel(Die, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1029 DWLabel("label", EndID));
1031 AddLabel(Die, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1032 DWLabel("func_end", SubprogramCount));
1034 ParentDie->AddChild(Die);
1037 // Add nested scopes.
1038 SmallVector<DbgScope *, 4> &Scopes = ParentScope->getScopes();
1039 for (unsigned j = 0, M = Scopes.size(); j < M; ++j) {
1040 // Define the Scope debug information entry.
1041 DbgScope *Scope = Scopes[j];
1043 unsigned StartID = MMI->MappedLabel(Scope->getStartLabelID());
1044 unsigned EndID = MMI->MappedLabel(Scope->getEndLabelID());
1046 // Ignore empty scopes.
1047 if (StartID == EndID && StartID != 0) continue;
1049 // Do not ignore inlined scopes even if they don't have any variables or
1051 if (Scope->getScopes().empty() && Scope->getVariables().empty() &&
1052 Scope->getConcreteInsts().empty())
1055 if (StartID == ParentStartID && EndID == ParentEndID) {
1056 // Just add stuff to the parent scope.
1057 ConstructDbgScope(Scope, ParentStartID, ParentEndID, ParentDie, Unit);
1059 DIE *ScopeDie = new DIE(dwarf::DW_TAG_lexical_block);
1061 // Add the scope bounds.
1063 AddLabel(ScopeDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1064 DWLabel("label", StartID));
1066 AddLabel(ScopeDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1067 DWLabel("func_begin", SubprogramCount));
1070 AddLabel(ScopeDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1071 DWLabel("label", EndID));
1073 AddLabel(ScopeDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1074 DWLabel("func_end", SubprogramCount));
1076 // Add the scope's contents.
1077 ConstructDbgScope(Scope, StartID, EndID, ScopeDie, Unit);
1078 ParentDie->AddChild(ScopeDie);
1083 /// ConstructFunctionDbgScope - Construct the scope for the subprogram.
1085 void DwarfDebug::ConstructFunctionDbgScope(DbgScope *RootScope,
1086 bool AbstractScope) {
1087 // Exit if there is no root scope.
1088 if (!RootScope) return;
1089 DIDescriptor Desc = RootScope->getDesc();
1093 // Get the subprogram debug information entry.
1094 DISubprogram SPD(Desc.getGV());
1096 // Get the compile unit context.
1097 CompileUnit *Unit = MainCU;
1099 Unit = &FindCompileUnit(SPD.getCompileUnit());
1101 // Get the subprogram die.
1102 DIE *SPDie = Unit->getDieMapSlotFor(SPD.getGV());
1103 assert(SPDie && "Missing subprogram descriptor");
1105 if (!AbstractScope) {
1106 // Add the function bounds.
1107 AddLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1108 DWLabel("func_begin", SubprogramCount));
1109 AddLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1110 DWLabel("func_end", SubprogramCount));
1111 MachineLocation Location(RI->getFrameRegister(*MF));
1112 AddAddress(SPDie, dwarf::DW_AT_frame_base, Location);
1115 ConstructDbgScope(RootScope, 0, 0, SPDie, Unit);
1118 /// ConstructDefaultDbgScope - Construct a default scope for the subprogram.
1120 void DwarfDebug::ConstructDefaultDbgScope(MachineFunction *MF) {
1121 const char *FnName = MF->getFunction()->getNameStart();
1123 StringMap<DIE*> &Globals = MainCU->getGlobals();
1124 StringMap<DIE*>::iterator GI = Globals.find(FnName);
1125 if (GI != Globals.end()) {
1126 DIE *SPDie = GI->second;
1128 // Add the function bounds.
1129 AddLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1130 DWLabel("func_begin", SubprogramCount));
1131 AddLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1132 DWLabel("func_end", SubprogramCount));
1134 MachineLocation Location(RI->getFrameRegister(*MF));
1135 AddAddress(SPDie, dwarf::DW_AT_frame_base, Location);
1139 for (unsigned i = 0, e = CompileUnits.size(); i != e; ++i) {
1140 CompileUnit *Unit = CompileUnits[i];
1141 StringMap<DIE*> &Globals = Unit->getGlobals();
1142 StringMap<DIE*>::iterator GI = Globals.find(FnName);
1143 if (GI != Globals.end()) {
1144 DIE *SPDie = GI->second;
1146 // Add the function bounds.
1147 AddLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1148 DWLabel("func_begin", SubprogramCount));
1149 AddLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
1150 DWLabel("func_end", SubprogramCount));
1152 MachineLocation Location(RI->getFrameRegister(*MF));
1153 AddAddress(SPDie, dwarf::DW_AT_frame_base, Location);
1160 // FIXME: This is causing an abort because C++ mangled names are compared with
1161 // their unmangled counterparts. See PR2885. Don't do this assert.
1162 assert(0 && "Couldn't find DIE for machine function!");
1166 /// GetOrCreateSourceID - Look up the source id with the given directory and
1167 /// source file names. If none currently exists, create a new id and insert it
1168 /// in the SourceIds map. This can update DirectoryNames and SourceFileNames
1170 unsigned DwarfDebug::GetOrCreateSourceID(const std::string &DirName,
1171 const std::string &FileName) {
1173 StringMap<unsigned>::iterator DI = DirectoryIdMap.find(DirName);
1174 if (DI != DirectoryIdMap.end()) {
1175 DId = DI->getValue();
1177 DId = DirectoryNames.size() + 1;
1178 DirectoryIdMap[DirName] = DId;
1179 DirectoryNames.push_back(DirName);
1183 StringMap<unsigned>::iterator FI = SourceFileIdMap.find(FileName);
1184 if (FI != SourceFileIdMap.end()) {
1185 FId = FI->getValue();
1187 FId = SourceFileNames.size() + 1;
1188 SourceFileIdMap[FileName] = FId;
1189 SourceFileNames.push_back(FileName);
1192 DenseMap<std::pair<unsigned, unsigned>, unsigned>::iterator SI =
1193 SourceIdMap.find(std::make_pair(DId, FId));
1194 if (SI != SourceIdMap.end())
1197 unsigned SrcId = SourceIds.size() + 1; // DW_AT_decl_file cannot be 0.
1198 SourceIdMap[std::make_pair(DId, FId)] = SrcId;
1199 SourceIds.push_back(std::make_pair(DId, FId));
1204 void DwarfDebug::ConstructCompileUnit(GlobalVariable *GV) {
1205 DICompileUnit DIUnit(GV);
1206 std::string Dir, FN, Prod;
1207 unsigned ID = GetOrCreateSourceID(DIUnit.getDirectory(Dir),
1208 DIUnit.getFilename(FN));
1210 DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
1211 AddSectionOffset(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4,
1212 DWLabel("section_line", 0), DWLabel("section_line", 0),
1214 AddString(Die, dwarf::DW_AT_producer, dwarf::DW_FORM_string,
1215 DIUnit.getProducer(Prod));
1216 AddUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data1,
1217 DIUnit.getLanguage());
1218 AddString(Die, dwarf::DW_AT_name, dwarf::DW_FORM_string, FN);
1221 AddString(Die, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string, Dir);
1222 if (DIUnit.isOptimized())
1223 AddUInt(Die, dwarf::DW_AT_APPLE_optimized, dwarf::DW_FORM_flag, 1);
1226 DIUnit.getFlags(Flags);
1228 AddString(Die, dwarf::DW_AT_APPLE_flags, dwarf::DW_FORM_string, Flags);
1230 unsigned RVer = DIUnit.getRunTimeVersion();
1232 AddUInt(Die, dwarf::DW_AT_APPLE_major_runtime_vers,
1233 dwarf::DW_FORM_data1, RVer);
1235 CompileUnit *Unit = new CompileUnit(ID, Die);
1236 if (DIUnit.isMain()) {
1237 assert(!MainCU && "Multiple main compile units are found!");
1241 CompileUnitMap[DIUnit.getGV()] = Unit;
1242 CompileUnits.push_back(Unit);
1245 /// ConstructCompileUnits - Create a compile unit DIEs.
1246 void DwarfDebug::ConstructCompileUnits() {
1247 GlobalVariable *Root = M->getGlobalVariable("llvm.dbg.compile_units");
1250 assert(Root->hasLinkOnceLinkage() && Root->hasOneUse() &&
1251 "Malformed compile unit descriptor anchor type");
1252 Constant *RootC = cast<Constant>(*Root->use_begin());
1253 assert(RootC->hasNUsesOrMore(1) &&
1254 "Malformed compile unit descriptor anchor type");
1256 for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
1258 for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
1259 UUI != UUE; ++UUI) {
1260 GlobalVariable *GV = cast<GlobalVariable>(*UUI);
1261 ConstructCompileUnit(GV);
1265 bool DwarfDebug::ConstructGlobalVariableDIE(GlobalVariable *GV) {
1266 DIGlobalVariable DI_GV(GV);
1267 CompileUnit *DW_Unit = MainCU;
1269 DW_Unit = &FindCompileUnit(DI_GV.getCompileUnit());
1271 // Check for pre-existence.
1272 DIE *&Slot = DW_Unit->getDieMapSlotFor(DI_GV.getGV());
1276 DIE *VariableDie = CreateGlobalVariableDIE(DW_Unit, DI_GV);
1279 DIEBlock *Block = new DIEBlock();
1280 AddUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
1282 AddObjectLabel(Block, 0, dwarf::DW_FORM_udata,
1283 Asm->getGlobalLinkName(DI_GV.getGlobal(), GLN));
1284 AddBlock(VariableDie, dwarf::DW_AT_location, 0, Block);
1289 // Add to context owner.
1290 DW_Unit->getDie()->AddChild(VariableDie);
1292 // Expose as global. FIXME - need to check external flag.
1294 DW_Unit->AddGlobal(DI_GV.getName(Name), VariableDie);
1298 /// ConstructGlobalVariableDIEs - Create DIEs for each of the externally visible
1299 /// global variables. Return true if at least one global DIE is created.
1300 bool DwarfDebug::ConstructGlobalVariableDIEs() {
1301 GlobalVariable *Root = M->getGlobalVariable("llvm.dbg.global_variables");
1305 assert(Root->hasLinkOnceLinkage() && Root->hasOneUse() &&
1306 "Malformed global variable descriptor anchor type");
1307 Constant *RootC = cast<Constant>(*Root->use_begin());
1308 assert(RootC->hasNUsesOrMore(1) &&
1309 "Malformed global variable descriptor anchor type");
1311 bool Result = false;
1312 for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
1314 for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
1316 Result |= ConstructGlobalVariableDIE(cast<GlobalVariable>(*UUI));
1321 bool DwarfDebug::ConstructSubprogram(GlobalVariable *GV) {
1322 DISubprogram SP(GV);
1323 CompileUnit *Unit = MainCU;
1325 Unit = &FindCompileUnit(SP.getCompileUnit());
1327 // Check for pre-existence.
1328 DIE *&Slot = Unit->getDieMapSlotFor(GV);
1332 if (!SP.isDefinition())
1333 // This is a method declaration which will be handled while constructing
1337 DIE *SubprogramDie = CreateSubprogramDIE(Unit, SP);
1340 Slot = SubprogramDie;
1342 // Add to context owner.
1343 Unit->getDie()->AddChild(SubprogramDie);
1345 // Expose as global.
1347 Unit->AddGlobal(SP.getName(Name), SubprogramDie);
1351 /// ConstructSubprograms - Create DIEs for each of the externally visible
1352 /// subprograms. Return true if at least one subprogram DIE is created.
1353 bool DwarfDebug::ConstructSubprograms() {
1354 GlobalVariable *Root = M->getGlobalVariable("llvm.dbg.subprograms");
1358 assert(Root->hasLinkOnceLinkage() && Root->hasOneUse() &&
1359 "Malformed subprogram descriptor anchor type");
1360 Constant *RootC = cast<Constant>(*Root->use_begin());
1361 assert(RootC->hasNUsesOrMore(1) &&
1362 "Malformed subprogram descriptor anchor type");
1364 bool Result = false;
1365 for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
1367 for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
1369 Result |= ConstructSubprogram(cast<GlobalVariable>(*UUI));
1374 /// BeginModule - Emit all Dwarf sections that should come prior to the
1375 /// content. Create global DIEs and emit initial debug info sections.
1376 /// This is inovked by the target AsmPrinter.
1377 void DwarfDebug::BeginModule(Module *M, MachineModuleInfo *mmi) {
1380 if (TimePassesIsEnabled)
1381 DebugTimer->startTimer();
1383 // Create all the compile unit DIEs.
1384 ConstructCompileUnits();
1386 if (CompileUnits.empty()) {
1387 if (TimePassesIsEnabled)
1388 DebugTimer->stopTimer();
1393 // Create DIEs for each of the externally visible global variables.
1394 bool globalDIEs = ConstructGlobalVariableDIEs();
1396 // Create DIEs for each of the externally visible subprograms.
1397 bool subprogramDIEs = ConstructSubprograms();
1399 // If there is not any debug info available for any global variables and any
1400 // subprograms then there is not any debug info to emit.
1401 if (!globalDIEs && !subprogramDIEs) {
1402 if (TimePassesIsEnabled)
1403 DebugTimer->stopTimer();
1410 MMI->setDebugInfoAvailability(true);
1412 // Prime section data.
1413 SectionMap.insert(TAI->getTextSection());
1415 // Print out .file directives to specify files for .loc directives. These are
1416 // printed out early so that they precede any .loc directives.
1417 if (TAI->hasDotLocAndDotFile()) {
1418 for (unsigned i = 1, e = getNumSourceIds()+1; i != e; ++i) {
1419 // Remember source id starts at 1.
1420 std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(i);
1421 sys::Path FullPath(getSourceDirectoryName(Id.first));
1423 FullPath.appendComponent(getSourceFileName(Id.second));
1424 assert(AppendOk && "Could not append filename to directory!");
1426 Asm->EmitFile(i, FullPath.toString());
1431 // Emit initial sections
1434 if (TimePassesIsEnabled)
1435 DebugTimer->stopTimer();
1438 /// EndModule - Emit all Dwarf sections that should come after the content.
1440 void DwarfDebug::EndModule() {
1441 if (!ShouldEmitDwarfDebug())
1444 if (TimePassesIsEnabled)
1445 DebugTimer->startTimer();
1447 // Standard sections final addresses.
1448 Asm->SwitchToSection(TAI->getTextSection());
1449 EmitLabel("text_end", 0);
1450 Asm->SwitchToSection(TAI->getDataSection());
1451 EmitLabel("data_end", 0);
1453 // End text sections.
1454 for (unsigned i = 1, N = SectionMap.size(); i <= N; ++i) {
1455 Asm->SwitchToSection(SectionMap[i]);
1456 EmitLabel("section_end", i);
1459 // Emit common frame information.
1460 EmitCommonDebugFrame();
1462 // Emit function debug frame information
1463 for (std::vector<FunctionDebugFrameInfo>::iterator I = DebugFrames.begin(),
1464 E = DebugFrames.end(); I != E; ++I)
1465 EmitFunctionDebugFrame(*I);
1467 // Compute DIE offsets and sizes.
1470 // Emit all the DIEs into a debug info section
1473 // Corresponding abbreviations into a abbrev section.
1474 EmitAbbreviations();
1476 // Emit source line correspondence into a debug line section.
1479 // Emit info into a debug pubnames section.
1480 EmitDebugPubNames();
1482 // Emit info into a debug str section.
1485 // Emit info into a debug loc section.
1488 // Emit info into a debug aranges section.
1491 // Emit info into a debug ranges section.
1494 // Emit info into a debug macinfo section.
1497 // Emit inline info.
1498 EmitDebugInlineInfo();
1500 if (TimePassesIsEnabled)
1501 DebugTimer->stopTimer();
1504 /// BeginFunction - Gather pre-function debug information. Assumes being
1505 /// emitted immediately after the function entry point.
1506 void DwarfDebug::BeginFunction(MachineFunction *MF) {
1509 if (!ShouldEmitDwarfDebug()) return;
1511 if (TimePassesIsEnabled)
1512 DebugTimer->startTimer();
1514 // Begin accumulating function debug information.
1515 MMI->BeginFunction(MF);
1517 // Assumes in correct section after the entry point.
1518 EmitLabel("func_begin", ++SubprogramCount);
1520 // Emit label for the implicitly defined dbg.stoppoint at the start of the
1522 DebugLoc FDL = MF->getDefaultDebugLoc();
1523 if (!FDL.isUnknown()) {
1524 DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
1525 unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col,
1526 DICompileUnit(DLT.CompileUnit));
1527 Asm->printLabel(LabelID);
1530 if (TimePassesIsEnabled)
1531 DebugTimer->stopTimer();
1534 /// EndFunction - Gather and emit post-function debug information.
1536 void DwarfDebug::EndFunction(MachineFunction *MF) {
1537 if (!ShouldEmitDwarfDebug()) return;
1539 if (TimePassesIsEnabled)
1540 DebugTimer->startTimer();
1542 // Define end label for subprogram.
1543 EmitLabel("func_end", SubprogramCount);
1545 // Get function line info.
1546 if (!Lines.empty()) {
1547 // Get section line info.
1548 unsigned ID = SectionMap.insert(Asm->CurrentSection_);
1549 if (SectionSourceLines.size() < ID) SectionSourceLines.resize(ID);
1550 std::vector<SrcLineInfo> &SectionLineInfos = SectionSourceLines[ID-1];
1551 // Append the function info to section info.
1552 SectionLineInfos.insert(SectionLineInfos.end(),
1553 Lines.begin(), Lines.end());
1556 // Construct the DbgScope for abstract instances.
1557 for (SmallVector<DbgScope *, 32>::iterator
1558 I = AbstractInstanceRootList.begin(),
1559 E = AbstractInstanceRootList.end(); I != E; ++I)
1560 ConstructFunctionDbgScope(*I);
1562 // Construct scopes for subprogram.
1563 if (FunctionDbgScope)
1564 ConstructFunctionDbgScope(FunctionDbgScope);
1566 // FIXME: This is wrong. We are essentially getting past a problem with
1567 // debug information not being able to handle unreachable blocks that have
1568 // debug information in them. In particular, those unreachable blocks that
1569 // have "region end" info in them. That situation results in the "root
1570 // scope" not being created. If that's the case, then emit a "default"
1571 // scope, i.e., one that encompasses the whole function. This isn't
1572 // desirable. And a better way of handling this (and all of the debugging
1573 // information) needs to be explored.
1574 ConstructDefaultDbgScope(MF);
1576 DebugFrames.push_back(FunctionDebugFrameInfo(SubprogramCount,
1577 MMI->getFrameMoves()));
1580 if (FunctionDbgScope) {
1581 delete FunctionDbgScope;
1582 DbgScopeMap.clear();
1583 DbgAbstractScopeMap.clear();
1584 DbgConcreteScopeMap.clear();
1585 InlinedVariableScopes.clear();
1586 FunctionDbgScope = NULL;
1587 LexicalScopeStack.clear();
1588 AbstractInstanceRootList.clear();
1589 AbstractInstanceRootMap.clear();
1594 if (TimePassesIsEnabled)
1595 DebugTimer->stopTimer();
1598 /// RecordSourceLine - Records location information and associates it with a
1599 /// label. Returns a unique label ID used to generate a label and provide
1600 /// correspondence to the source line list.
1601 unsigned DwarfDebug::RecordSourceLine(Value *V, unsigned Line, unsigned Col) {
1602 if (TimePassesIsEnabled)
1603 DebugTimer->startTimer();
1605 CompileUnit *Unit = CompileUnitMap[V];
1606 assert(Unit && "Unable to find CompileUnit");
1607 unsigned ID = MMI->NextLabelID();
1608 Lines.push_back(SrcLineInfo(Line, Col, Unit->getID(), ID));
1610 if (TimePassesIsEnabled)
1611 DebugTimer->stopTimer();
1616 /// RecordSourceLine - Records location information and associates it with a
1617 /// label. Returns a unique label ID used to generate a label and provide
1618 /// correspondence to the source line list.
1619 unsigned DwarfDebug::RecordSourceLine(unsigned Line, unsigned Col,
1621 if (TimePassesIsEnabled)
1622 DebugTimer->startTimer();
1624 std::string Dir, Fn;
1625 unsigned Src = GetOrCreateSourceID(CU.getDirectory(Dir),
1626 CU.getFilename(Fn));
1627 unsigned ID = MMI->NextLabelID();
1628 Lines.push_back(SrcLineInfo(Line, Col, Src, ID));
1630 if (TimePassesIsEnabled)
1631 DebugTimer->stopTimer();
1636 /// getOrCreateSourceID - Public version of GetOrCreateSourceID. This can be
1637 /// timed. Look up the source id with the given directory and source file
1638 /// names. If none currently exists, create a new id and insert it in the
1639 /// SourceIds map. This can update DirectoryNames and SourceFileNames maps as
1641 unsigned DwarfDebug::getOrCreateSourceID(const std::string &DirName,
1642 const std::string &FileName) {
1643 if (TimePassesIsEnabled)
1644 DebugTimer->startTimer();
1646 unsigned SrcId = GetOrCreateSourceID(DirName, FileName);
1648 if (TimePassesIsEnabled)
1649 DebugTimer->stopTimer();
1654 /// RecordRegionStart - Indicate the start of a region.
1655 unsigned DwarfDebug::RecordRegionStart(GlobalVariable *V) {
1656 if (TimePassesIsEnabled)
1657 DebugTimer->startTimer();
1659 DbgScope *Scope = getOrCreateScope(V);
1660 unsigned ID = MMI->NextLabelID();
1661 if (!Scope->getStartLabelID()) Scope->setStartLabelID(ID);
1662 LexicalScopeStack.push_back(Scope);
1664 if (TimePassesIsEnabled)
1665 DebugTimer->stopTimer();
1670 /// RecordRegionEnd - Indicate the end of a region.
1671 unsigned DwarfDebug::RecordRegionEnd(GlobalVariable *V) {
1672 if (TimePassesIsEnabled)
1673 DebugTimer->startTimer();
1675 DbgScope *Scope = getOrCreateScope(V);
1676 unsigned ID = MMI->NextLabelID();
1677 Scope->setEndLabelID(ID);
1678 // FIXME : region.end() may not be in the last basic block.
1679 // For now, do not pop last lexical scope because next basic
1680 // block may start new inlined function's body.
1681 unsigned LSSize = LexicalScopeStack.size();
1682 if (LSSize != 0 && LSSize != 1)
1683 LexicalScopeStack.pop_back();
1685 if (TimePassesIsEnabled)
1686 DebugTimer->stopTimer();
1691 /// RecordVariable - Indicate the declaration of a local variable.
1692 void DwarfDebug::RecordVariable(GlobalVariable *GV, unsigned FrameIndex,
1693 const MachineInstr *MI) {
1694 if (TimePassesIsEnabled)
1695 DebugTimer->startTimer();
1697 DIDescriptor Desc(GV);
1698 DbgScope *Scope = NULL;
1699 bool InlinedFnVar = false;
1701 if (Desc.getTag() == dwarf::DW_TAG_variable) {
1702 // GV is a global variable.
1703 DIGlobalVariable DG(GV);
1704 Scope = getOrCreateScope(DG.getContext().getGV());
1706 DenseMap<const MachineInstr *, DbgScope *>::iterator
1707 SI = InlinedVariableScopes.find(MI);
1709 if (SI != InlinedVariableScopes.end()) {
1710 // or GV is an inlined local variable.
1714 GlobalVariable *V = DV.getContext().getGV();
1716 // FIXME: The code that checks for the inlined local variable is a hack!
1717 DenseMap<const GlobalVariable *, DbgScope *>::iterator
1718 AI = AbstractInstanceRootMap.find(V);
1720 if (AI != AbstractInstanceRootMap.end()) {
1721 // This method is called each time a DECLARE node is encountered. For an
1722 // inlined function, this could be many, many times. We don't want to
1723 // re-add variables to that DIE for each time. We just want to add them
1724 // once. Check to make sure that we haven't added them already.
1725 DenseMap<const GlobalVariable *,
1726 SmallSet<const GlobalVariable *, 32> >::iterator
1727 IP = InlinedParamMap.find(V);
1729 if (IP != InlinedParamMap.end() && IP->second.count(GV) > 0) {
1730 if (TimePassesIsEnabled)
1731 DebugTimer->stopTimer();
1735 // or GV is an inlined local variable.
1737 InlinedParamMap[V].insert(GV);
1738 InlinedFnVar = true;
1740 // or GV is a local variable.
1741 Scope = getOrCreateScope(V);
1746 assert(Scope && "Unable to find the variable's scope");
1747 DbgVariable *DV = new DbgVariable(DIVariable(GV), FrameIndex, InlinedFnVar);
1748 Scope->AddVariable(DV);
1750 if (TimePassesIsEnabled)
1751 DebugTimer->stopTimer();
1754 //// RecordInlinedFnStart - Indicate the start of inlined subroutine.
1755 unsigned DwarfDebug::RecordInlinedFnStart(DISubprogram &SP, DICompileUnit CU,
1756 unsigned Line, unsigned Col) {
1757 unsigned LabelID = MMI->NextLabelID();
1759 if (!TAI->doesDwarfUsesInlineInfoSection())
1762 if (TimePassesIsEnabled)
1763 DebugTimer->startTimer();
1765 CompileUnit *Unit = MainCU;
1767 Unit = &FindCompileUnit(SP.getCompileUnit());
1768 GlobalVariable *GV = SP.getGV();
1769 DenseMap<const GlobalVariable *, DbgScope *>::iterator
1770 II = AbstractInstanceRootMap.find(GV);
1772 if (II == AbstractInstanceRootMap.end()) {
1773 // Create an abstract instance entry for this inlined function if it doesn't
1775 DbgScope *Scope = new DbgScope(NULL, DIDescriptor(GV));
1777 // Get the compile unit context.
1778 DIE *SPDie = Unit->getDieMapSlotFor(GV);
1780 SPDie = CreateSubprogramDIE(Unit, SP, false, true);
1782 // Mark as being inlined. This makes this subprogram entry an abstract
1784 // FIXME: Our debugger doesn't care about the value of DW_AT_inline, only
1785 // that it's defined. That probably won't change in the future. However,
1786 // this could be more elegant.
1787 AddUInt(SPDie, dwarf::DW_AT_inline, 0, dwarf::DW_INL_declared_not_inlined);
1789 // Keep track of the abstract scope for this function.
1790 DbgAbstractScopeMap[GV] = Scope;
1792 AbstractInstanceRootMap[GV] = Scope;
1793 AbstractInstanceRootList.push_back(Scope);
1796 // Create a concrete inlined instance for this inlined function.
1797 DbgConcreteScope *ConcreteScope = new DbgConcreteScope(DIDescriptor(GV));
1798 DIE *ScopeDie = new DIE(dwarf::DW_TAG_inlined_subroutine);
1799 ScopeDie->setAbstractCompileUnit(Unit);
1801 DIE *Origin = Unit->getDieMapSlotFor(GV);
1802 AddDIEEntry(ScopeDie, dwarf::DW_AT_abstract_origin,
1803 dwarf::DW_FORM_ref4, Origin);
1804 AddUInt(ScopeDie, dwarf::DW_AT_call_file, 0, Unit->getID());
1805 AddUInt(ScopeDie, dwarf::DW_AT_call_line, 0, Line);
1806 AddUInt(ScopeDie, dwarf::DW_AT_call_column, 0, Col);
1808 ConcreteScope->setDie(ScopeDie);
1809 ConcreteScope->setStartLabelID(LabelID);
1810 MMI->RecordUsedDbgLabel(LabelID);
1812 LexicalScopeStack.back()->AddConcreteInst(ConcreteScope);
1814 // Keep track of the concrete scope that's inlined into this function.
1815 DenseMap<GlobalVariable *, SmallVector<DbgScope *, 8> >::iterator
1816 SI = DbgConcreteScopeMap.find(GV);
1818 if (SI == DbgConcreteScopeMap.end())
1819 DbgConcreteScopeMap[GV].push_back(ConcreteScope);
1821 SI->second.push_back(ConcreteScope);
1823 // Track the start label for this inlined function.
1824 DenseMap<GlobalVariable *, SmallVector<unsigned, 4> >::iterator
1825 I = InlineInfo.find(GV);
1827 if (I == InlineInfo.end())
1828 InlineInfo[GV].push_back(LabelID);
1830 I->second.push_back(LabelID);
1832 if (TimePassesIsEnabled)
1833 DebugTimer->stopTimer();
1838 /// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
1839 unsigned DwarfDebug::RecordInlinedFnEnd(DISubprogram &SP) {
1840 if (!TAI->doesDwarfUsesInlineInfoSection())
1843 if (TimePassesIsEnabled)
1844 DebugTimer->startTimer();
1846 GlobalVariable *GV = SP.getGV();
1847 DenseMap<GlobalVariable *, SmallVector<DbgScope *, 8> >::iterator
1848 I = DbgConcreteScopeMap.find(GV);
1850 if (I == DbgConcreteScopeMap.end()) {
1851 // FIXME: Can this situation actually happen? And if so, should it?
1852 if (TimePassesIsEnabled)
1853 DebugTimer->stopTimer();
1858 SmallVector<DbgScope *, 8> &Scopes = I->second;
1859 if (Scopes.empty()) {
1860 // Returned ID is 0 if this is unbalanced "end of inlined
1861 // scope". This could happen if optimizer eats dbg intrinsics
1862 // or "beginning of inlined scope" is not recoginized due to
1863 // missing location info. In such cases, ignore this region.end.
1867 DbgScope *Scope = Scopes.back(); Scopes.pop_back();
1868 unsigned ID = MMI->NextLabelID();
1869 MMI->RecordUsedDbgLabel(ID);
1870 Scope->setEndLabelID(ID);
1872 if (TimePassesIsEnabled)
1873 DebugTimer->stopTimer();
1878 /// RecordVariableScope - Record scope for the variable declared by
1879 /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE. Record scopes
1880 /// for only inlined subroutine variables. Other variables's scopes are
1881 /// determined during RecordVariable().
1882 void DwarfDebug::RecordVariableScope(DIVariable &DV,
1883 const MachineInstr *DeclareMI) {
1884 if (TimePassesIsEnabled)
1885 DebugTimer->startTimer();
1887 DISubprogram SP(DV.getContext().getGV());
1890 if (TimePassesIsEnabled)
1891 DebugTimer->stopTimer();
1896 DenseMap<GlobalVariable *, DbgScope *>::iterator
1897 I = DbgAbstractScopeMap.find(SP.getGV());
1898 if (I != DbgAbstractScopeMap.end())
1899 InlinedVariableScopes[DeclareMI] = I->second;
1901 if (TimePassesIsEnabled)
1902 DebugTimer->stopTimer();
1905 //===----------------------------------------------------------------------===//
1907 //===----------------------------------------------------------------------===//
1909 /// SizeAndOffsetDie - Compute the size and offset of a DIE.
1911 unsigned DwarfDebug::SizeAndOffsetDie(DIE *Die, unsigned Offset, bool Last) {
1912 // Get the children.
1913 const std::vector<DIE *> &Children = Die->getChildren();
1915 // If not last sibling and has children then add sibling offset attribute.
1916 if (!Last && !Children.empty()) Die->AddSiblingOffset();
1918 // Record the abbreviation.
1919 AssignAbbrevNumber(Die->getAbbrev());
1921 // Get the abbreviation for this DIE.
1922 unsigned AbbrevNumber = Die->getAbbrevNumber();
1923 const DIEAbbrev *Abbrev = Abbreviations[AbbrevNumber - 1];
1926 Die->setOffset(Offset);
1928 // Start the size with the size of abbreviation code.
1929 Offset += TargetAsmInfo::getULEB128Size(AbbrevNumber);
1931 const SmallVector<DIEValue*, 32> &Values = Die->getValues();
1932 const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData();
1934 // Size the DIE attribute values.
1935 for (unsigned i = 0, N = Values.size(); i < N; ++i)
1936 // Size attribute value.
1937 Offset += Values[i]->SizeOf(TD, AbbrevData[i].getForm());
1939 // Size the DIE children if any.
1940 if (!Children.empty()) {
1941 assert(Abbrev->getChildrenFlag() == dwarf::DW_CHILDREN_yes &&
1942 "Children flag not set");
1944 for (unsigned j = 0, M = Children.size(); j < M; ++j)
1945 Offset = SizeAndOffsetDie(Children[j], Offset, (j + 1) == M);
1947 // End of children marker.
1948 Offset += sizeof(int8_t);
1951 Die->setSize(Offset - Die->getOffset());
1955 /// SizeAndOffsets - Compute the size and offset of all the DIEs.
1957 void DwarfDebug::SizeAndOffsets() {
1958 // Compute size of compile unit header.
1959 static unsigned Offset =
1960 sizeof(int32_t) + // Length of Compilation Unit Info
1961 sizeof(int16_t) + // DWARF version number
1962 sizeof(int32_t) + // Offset Into Abbrev. Section
1963 sizeof(int8_t); // Pointer Size (in bytes)
1965 // Process base compile unit.
1967 SizeAndOffsetDie(MainCU->getDie(), Offset, true);
1968 CompileUnitOffsets[MainCU] = 0;
1972 // Process all compile units.
1973 unsigned PrevOffset = 0;
1975 for (unsigned i = 0, e = CompileUnits.size(); i != e; ++i) {
1976 CompileUnit *Unit = CompileUnits[i];
1977 CompileUnitOffsets[Unit] = PrevOffset;
1978 PrevOffset += SizeAndOffsetDie(Unit->getDie(), Offset, true)
1979 + sizeof(int32_t); // FIXME - extra pad for gdb bug.
1983 /// EmitInitial - Emit initial Dwarf declarations. This is necessary for cc
1984 /// tools to recognize the object file contains Dwarf information.
1985 void DwarfDebug::EmitInitial() {
1986 // Check to see if we already emitted intial headers.
1987 if (didInitial) return;
1990 // Dwarf sections base addresses.
1991 if (TAI->doesDwarfRequireFrameSection()) {
1992 Asm->SwitchToDataSection(TAI->getDwarfFrameSection());
1993 EmitLabel("section_debug_frame", 0);
1996 Asm->SwitchToDataSection(TAI->getDwarfInfoSection());
1997 EmitLabel("section_info", 0);
1998 Asm->SwitchToDataSection(TAI->getDwarfAbbrevSection());
1999 EmitLabel("section_abbrev", 0);
2000 Asm->SwitchToDataSection(TAI->getDwarfARangesSection());
2001 EmitLabel("section_aranges", 0);
2003 if (const char *LineInfoDirective = TAI->getDwarfMacroInfoSection()) {
2004 Asm->SwitchToDataSection(LineInfoDirective);
2005 EmitLabel("section_macinfo", 0);
2008 Asm->SwitchToDataSection(TAI->getDwarfLineSection());
2009 EmitLabel("section_line", 0);
2010 Asm->SwitchToDataSection(TAI->getDwarfLocSection());
2011 EmitLabel("section_loc", 0);
2012 Asm->SwitchToDataSection(TAI->getDwarfPubNamesSection());
2013 EmitLabel("section_pubnames", 0);
2014 Asm->SwitchToDataSection(TAI->getDwarfStrSection());
2015 EmitLabel("section_str", 0);
2016 Asm->SwitchToDataSection(TAI->getDwarfRangesSection());
2017 EmitLabel("section_ranges", 0);
2019 Asm->SwitchToSection(TAI->getTextSection());
2020 EmitLabel("text_begin", 0);
2021 Asm->SwitchToSection(TAI->getDataSection());
2022 EmitLabel("data_begin", 0);
2025 /// EmitDIE - Recusively Emits a debug information entry.
2027 void DwarfDebug::EmitDIE(DIE *Die) {
2028 // Get the abbreviation for this DIE.
2029 unsigned AbbrevNumber = Die->getAbbrevNumber();
2030 const DIEAbbrev *Abbrev = Abbreviations[AbbrevNumber - 1];
2034 // Emit the code (index) for the abbreviation.
2035 Asm->EmitULEB128Bytes(AbbrevNumber);
2037 if (Asm->isVerbose())
2038 Asm->EOL(std::string("Abbrev [" +
2039 utostr(AbbrevNumber) +
2040 "] 0x" + utohexstr(Die->getOffset()) +
2041 ":0x" + utohexstr(Die->getSize()) + " " +
2042 dwarf::TagString(Abbrev->getTag())));
2046 SmallVector<DIEValue*, 32> &Values = Die->getValues();
2047 const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData();
2049 // Emit the DIE attribute values.
2050 for (unsigned i = 0, N = Values.size(); i < N; ++i) {
2051 unsigned Attr = AbbrevData[i].getAttribute();
2052 unsigned Form = AbbrevData[i].getForm();
2053 assert(Form && "Too many attributes for DIE (check abbreviation)");
2056 case dwarf::DW_AT_sibling:
2057 Asm->EmitInt32(Die->SiblingOffset());
2059 case dwarf::DW_AT_abstract_origin: {
2060 DIEEntry *E = cast<DIEEntry>(Values[i]);
2061 DIE *Origin = E->getEntry();
2063 CompileUnitOffsets[Die->getAbstractCompileUnit()] +
2064 Origin->getOffset();
2066 Asm->EmitInt32(Addr);
2070 // Emit an attribute using the defined form.
2071 Values[i]->EmitValue(this, Form);
2075 Asm->EOL(dwarf::AttributeString(Attr));
2078 // Emit the DIE children if any.
2079 if (Abbrev->getChildrenFlag() == dwarf::DW_CHILDREN_yes) {
2080 const std::vector<DIE *> &Children = Die->getChildren();
2082 for (unsigned j = 0, M = Children.size(); j < M; ++j)
2083 EmitDIE(Children[j]);
2085 Asm->EmitInt8(0); Asm->EOL("End Of Children Mark");
2089 /// EmitDebugInfo / EmitDebugInfoPerCU - Emit the debug info section.
2091 void DwarfDebug::EmitDebugInfoPerCU(CompileUnit *Unit) {
2092 DIE *Die = Unit->getDie();
2094 // Emit the compile units header.
2095 EmitLabel("info_begin", Unit->getID());
2097 // Emit size of content not including length itself
2098 unsigned ContentSize = Die->getSize() +
2099 sizeof(int16_t) + // DWARF version number
2100 sizeof(int32_t) + // Offset Into Abbrev. Section
2101 sizeof(int8_t) + // Pointer Size (in bytes)
2102 sizeof(int32_t); // FIXME - extra pad for gdb bug.
2104 Asm->EmitInt32(ContentSize); Asm->EOL("Length of Compilation Unit Info");
2105 Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("DWARF version number");
2106 EmitSectionOffset("abbrev_begin", "section_abbrev", 0, 0, true, false);
2107 Asm->EOL("Offset Into Abbrev. Section");
2108 Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)");
2111 // FIXME - extra padding for gdb bug.
2112 Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
2113 Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
2114 Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
2115 Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
2116 EmitLabel("info_end", Unit->getID());
2121 void DwarfDebug::EmitDebugInfo() {
2122 // Start debug info section.
2123 Asm->SwitchToDataSection(TAI->getDwarfInfoSection());
2126 EmitDebugInfoPerCU(MainCU);
2130 for (unsigned i = 0, e = CompileUnits.size(); i != e; ++i)
2131 EmitDebugInfoPerCU(CompileUnits[i]);
2134 /// EmitAbbreviations - Emit the abbreviation section.
2136 void DwarfDebug::EmitAbbreviations() const {
2137 // Check to see if it is worth the effort.
2138 if (!Abbreviations.empty()) {
2139 // Start the debug abbrev section.
2140 Asm->SwitchToDataSection(TAI->getDwarfAbbrevSection());
2142 EmitLabel("abbrev_begin", 0);
2144 // For each abbrevation.
2145 for (unsigned i = 0, N = Abbreviations.size(); i < N; ++i) {
2146 // Get abbreviation data
2147 const DIEAbbrev *Abbrev = Abbreviations[i];
2149 // Emit the abbrevations code (base 1 index.)
2150 Asm->EmitULEB128Bytes(Abbrev->getNumber());
2151 Asm->EOL("Abbreviation Code");
2153 // Emit the abbreviations data.
2159 // Mark end of abbreviations.
2160 Asm->EmitULEB128Bytes(0); Asm->EOL("EOM(3)");
2162 EmitLabel("abbrev_end", 0);
2167 /// EmitEndOfLineMatrix - Emit the last address of the section and the end of
2168 /// the line matrix.
2170 void DwarfDebug::EmitEndOfLineMatrix(unsigned SectionEnd) {
2171 // Define last address of section.
2172 Asm->EmitInt8(0); Asm->EOL("Extended Op");
2173 Asm->EmitInt8(TD->getPointerSize() + 1); Asm->EOL("Op size");
2174 Asm->EmitInt8(dwarf::DW_LNE_set_address); Asm->EOL("DW_LNE_set_address");
2175 EmitReference("section_end", SectionEnd); Asm->EOL("Section end label");
2177 // Mark end of matrix.
2178 Asm->EmitInt8(0); Asm->EOL("DW_LNE_end_sequence");
2179 Asm->EmitULEB128Bytes(1); Asm->EOL();
2180 Asm->EmitInt8(1); Asm->EOL();
2183 /// EmitDebugLines - Emit source line information.
2185 void DwarfDebug::EmitDebugLines() {
2186 // If the target is using .loc/.file, the assembler will be emitting the
2187 // .debug_line table automatically.
2188 if (TAI->hasDotLocAndDotFile())
2191 // Minimum line delta, thus ranging from -10..(255-10).
2192 const int MinLineDelta = -(dwarf::DW_LNS_fixed_advance_pc + 1);
2193 // Maximum line delta, thus ranging from -10..(255-10).
2194 const int MaxLineDelta = 255 + MinLineDelta;
2196 // Start the dwarf line section.
2197 Asm->SwitchToDataSection(TAI->getDwarfLineSection());
2199 // Construct the section header.
2200 EmitDifference("line_end", 0, "line_begin", 0, true);
2201 Asm->EOL("Length of Source Line Info");
2202 EmitLabel("line_begin", 0);
2204 Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("DWARF version number");
2206 EmitDifference("line_prolog_end", 0, "line_prolog_begin", 0, true);
2207 Asm->EOL("Prolog Length");
2208 EmitLabel("line_prolog_begin", 0);
2210 Asm->EmitInt8(1); Asm->EOL("Minimum Instruction Length");
2212 Asm->EmitInt8(1); Asm->EOL("Default is_stmt_start flag");
2214 Asm->EmitInt8(MinLineDelta); Asm->EOL("Line Base Value (Special Opcodes)");
2216 Asm->EmitInt8(MaxLineDelta); Asm->EOL("Line Range Value (Special Opcodes)");
2218 Asm->EmitInt8(-MinLineDelta); Asm->EOL("Special Opcode Base");
2220 // Line number standard opcode encodings argument count
2221 Asm->EmitInt8(0); Asm->EOL("DW_LNS_copy arg count");
2222 Asm->EmitInt8(1); Asm->EOL("DW_LNS_advance_pc arg count");
2223 Asm->EmitInt8(1); Asm->EOL("DW_LNS_advance_line arg count");
2224 Asm->EmitInt8(1); Asm->EOL("DW_LNS_set_file arg count");
2225 Asm->EmitInt8(1); Asm->EOL("DW_LNS_set_column arg count");
2226 Asm->EmitInt8(0); Asm->EOL("DW_LNS_negate_stmt arg count");
2227 Asm->EmitInt8(0); Asm->EOL("DW_LNS_set_basic_block arg count");
2228 Asm->EmitInt8(0); Asm->EOL("DW_LNS_const_add_pc arg count");
2229 Asm->EmitInt8(1); Asm->EOL("DW_LNS_fixed_advance_pc arg count");
2231 // Emit directories.
2232 for (unsigned DI = 1, DE = getNumSourceDirectories()+1; DI != DE; ++DI) {
2233 Asm->EmitString(getSourceDirectoryName(DI));
2234 Asm->EOL("Directory");
2237 Asm->EmitInt8(0); Asm->EOL("End of directories");
2240 for (unsigned SI = 1, SE = getNumSourceIds()+1; SI != SE; ++SI) {
2241 // Remember source id starts at 1.
2242 std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(SI);
2243 Asm->EmitString(getSourceFileName(Id.second));
2245 Asm->EmitULEB128Bytes(Id.first);
2246 Asm->EOL("Directory #");
2247 Asm->EmitULEB128Bytes(0);
2248 Asm->EOL("Mod date");
2249 Asm->EmitULEB128Bytes(0);
2250 Asm->EOL("File size");
2253 Asm->EmitInt8(0); Asm->EOL("End of files");
2255 EmitLabel("line_prolog_end", 0);
2257 // A sequence for each text section.
2258 unsigned SecSrcLinesSize = SectionSourceLines.size();
2260 for (unsigned j = 0; j < SecSrcLinesSize; ++j) {
2261 // Isolate current sections line info.
2262 const std::vector<SrcLineInfo> &LineInfos = SectionSourceLines[j];
2264 if (Asm->isVerbose()) {
2265 const Section* S = SectionMap[j + 1];
2266 O << '\t' << TAI->getCommentString() << " Section"
2267 << S->getName() << '\n';
2272 // Dwarf assumes we start with first line of first source file.
2273 unsigned Source = 1;
2276 // Construct rows of the address, source, line, column matrix.
2277 for (unsigned i = 0, N = LineInfos.size(); i < N; ++i) {
2278 const SrcLineInfo &LineInfo = LineInfos[i];
2279 unsigned LabelID = MMI->MappedLabel(LineInfo.getLabelID());
2280 if (!LabelID) continue;
2282 if (!Asm->isVerbose())
2285 std::pair<unsigned, unsigned> SourceID =
2286 getSourceDirectoryAndFileIds(LineInfo.getSourceID());
2287 O << '\t' << TAI->getCommentString() << ' '
2288 << getSourceDirectoryName(SourceID.first) << ' '
2289 << getSourceFileName(SourceID.second)
2290 <<" :" << utostr_32(LineInfo.getLine()) << '\n';
2293 // Define the line address.
2294 Asm->EmitInt8(0); Asm->EOL("Extended Op");
2295 Asm->EmitInt8(TD->getPointerSize() + 1); Asm->EOL("Op size");
2296 Asm->EmitInt8(dwarf::DW_LNE_set_address); Asm->EOL("DW_LNE_set_address");
2297 EmitReference("label", LabelID); Asm->EOL("Location label");
2299 // If change of source, then switch to the new source.
2300 if (Source != LineInfo.getSourceID()) {
2301 Source = LineInfo.getSourceID();
2302 Asm->EmitInt8(dwarf::DW_LNS_set_file); Asm->EOL("DW_LNS_set_file");
2303 Asm->EmitULEB128Bytes(Source); Asm->EOL("New Source");
2306 // If change of line.
2307 if (Line != LineInfo.getLine()) {
2308 // Determine offset.
2309 int Offset = LineInfo.getLine() - Line;
2310 int Delta = Offset - MinLineDelta;
2313 Line = LineInfo.getLine();
2315 // If delta is small enough and in range...
2316 if (Delta >= 0 && Delta < (MaxLineDelta - 1)) {
2317 // ... then use fast opcode.
2318 Asm->EmitInt8(Delta - MinLineDelta); Asm->EOL("Line Delta");
2320 // ... otherwise use long hand.
2321 Asm->EmitInt8(dwarf::DW_LNS_advance_line);
2322 Asm->EOL("DW_LNS_advance_line");
2323 Asm->EmitSLEB128Bytes(Offset); Asm->EOL("Line Offset");
2324 Asm->EmitInt8(dwarf::DW_LNS_copy); Asm->EOL("DW_LNS_copy");
2327 // Copy the previous row (different address or source)
2328 Asm->EmitInt8(dwarf::DW_LNS_copy); Asm->EOL("DW_LNS_copy");
2332 EmitEndOfLineMatrix(j + 1);
2335 if (SecSrcLinesSize == 0)
2336 // Because we're emitting a debug_line section, we still need a line
2337 // table. The linker and friends expect it to exist. If there's nothing to
2338 // put into it, emit an empty table.
2339 EmitEndOfLineMatrix(1);
2341 EmitLabel("line_end", 0);
2345 /// EmitCommonDebugFrame - Emit common frame info into a debug frame section.
2347 void DwarfDebug::EmitCommonDebugFrame() {
2348 if (!TAI->doesDwarfRequireFrameSection())
2352 Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
2353 TargetFrameInfo::StackGrowsUp ?
2354 TD->getPointerSize() : -TD->getPointerSize();
2356 // Start the dwarf frame section.
2357 Asm->SwitchToDataSection(TAI->getDwarfFrameSection());
2359 EmitLabel("debug_frame_common", 0);
2360 EmitDifference("debug_frame_common_end", 0,
2361 "debug_frame_common_begin", 0, true);
2362 Asm->EOL("Length of Common Information Entry");
2364 EmitLabel("debug_frame_common_begin", 0);
2365 Asm->EmitInt32((int)dwarf::DW_CIE_ID);
2366 Asm->EOL("CIE Identifier Tag");
2367 Asm->EmitInt8(dwarf::DW_CIE_VERSION);
2368 Asm->EOL("CIE Version");
2369 Asm->EmitString("");
2370 Asm->EOL("CIE Augmentation");
2371 Asm->EmitULEB128Bytes(1);
2372 Asm->EOL("CIE Code Alignment Factor");
2373 Asm->EmitSLEB128Bytes(stackGrowth);
2374 Asm->EOL("CIE Data Alignment Factor");
2375 Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), false));
2376 Asm->EOL("CIE RA Column");
2378 std::vector<MachineMove> Moves;
2379 RI->getInitialFrameState(Moves);
2381 EmitFrameMoves(NULL, 0, Moves, false);
2383 Asm->EmitAlignment(2, 0, 0, false);
2384 EmitLabel("debug_frame_common_end", 0);
2389 /// EmitFunctionDebugFrame - Emit per function frame info into a debug frame
2392 DwarfDebug::EmitFunctionDebugFrame(const FunctionDebugFrameInfo&DebugFrameInfo){
2393 if (!TAI->doesDwarfRequireFrameSection())
2396 // Start the dwarf frame section.
2397 Asm->SwitchToDataSection(TAI->getDwarfFrameSection());
2399 EmitDifference("debug_frame_end", DebugFrameInfo.Number,
2400 "debug_frame_begin", DebugFrameInfo.Number, true);
2401 Asm->EOL("Length of Frame Information Entry");
2403 EmitLabel("debug_frame_begin", DebugFrameInfo.Number);
2405 EmitSectionOffset("debug_frame_common", "section_debug_frame",
2407 Asm->EOL("FDE CIE offset");
2409 EmitReference("func_begin", DebugFrameInfo.Number);
2410 Asm->EOL("FDE initial location");
2411 EmitDifference("func_end", DebugFrameInfo.Number,
2412 "func_begin", DebugFrameInfo.Number);
2413 Asm->EOL("FDE address range");
2415 EmitFrameMoves("func_begin", DebugFrameInfo.Number, DebugFrameInfo.Moves,
2418 Asm->EmitAlignment(2, 0, 0, false);
2419 EmitLabel("debug_frame_end", DebugFrameInfo.Number);
2424 void DwarfDebug::EmitDebugPubNamesPerCU(CompileUnit *Unit) {
2425 EmitDifference("pubnames_end", Unit->getID(),
2426 "pubnames_begin", Unit->getID(), true);
2427 Asm->EOL("Length of Public Names Info");
2429 EmitLabel("pubnames_begin", Unit->getID());
2431 Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("DWARF Version");
2433 EmitSectionOffset("info_begin", "section_info",
2434 Unit->getID(), 0, true, false);
2435 Asm->EOL("Offset of Compilation Unit Info");
2437 EmitDifference("info_end", Unit->getID(), "info_begin", Unit->getID(),
2439 Asm->EOL("Compilation Unit Length");
2441 StringMap<DIE*> &Globals = Unit->getGlobals();
2442 for (StringMap<DIE*>::const_iterator
2443 GI = Globals.begin(), GE = Globals.end(); GI != GE; ++GI) {
2444 const char *Name = GI->getKeyData();
2445 DIE * Entity = GI->second;
2447 Asm->EmitInt32(Entity->getOffset()); Asm->EOL("DIE offset");
2448 Asm->EmitString(Name, strlen(Name)); Asm->EOL("External Name");
2451 Asm->EmitInt32(0); Asm->EOL("End Mark");
2452 EmitLabel("pubnames_end", Unit->getID());
2457 /// EmitDebugPubNames - Emit visible names into a debug pubnames section.
2459 void DwarfDebug::EmitDebugPubNames() {
2460 // Start the dwarf pubnames section.
2461 Asm->SwitchToDataSection(TAI->getDwarfPubNamesSection());
2464 EmitDebugPubNamesPerCU(MainCU);
2468 for (unsigned i = 0, e = CompileUnits.size(); i != e; ++i)
2469 EmitDebugPubNamesPerCU(CompileUnits[i]);
2472 /// EmitDebugStr - Emit visible names into a debug str section.
2474 void DwarfDebug::EmitDebugStr() {
2475 // Check to see if it is worth the effort.
2476 if (!StringPool.empty()) {
2477 // Start the dwarf str section.
2478 Asm->SwitchToDataSection(TAI->getDwarfStrSection());
2480 // For each of strings in the string pool.
2481 for (unsigned StringID = 1, N = StringPool.size();
2482 StringID <= N; ++StringID) {
2483 // Emit a label for reference from debug information entries.
2484 EmitLabel("string", StringID);
2486 // Emit the string itself.
2487 const std::string &String = StringPool[StringID];
2488 Asm->EmitString(String); Asm->EOL();
2495 /// EmitDebugLoc - Emit visible names into a debug loc section.
2497 void DwarfDebug::EmitDebugLoc() {
2498 // Start the dwarf loc section.
2499 Asm->SwitchToDataSection(TAI->getDwarfLocSection());
2503 /// EmitDebugARanges - Emit visible names into a debug aranges section.
2505 void DwarfDebug::EmitDebugARanges() {
2506 // Start the dwarf aranges section.
2507 Asm->SwitchToDataSection(TAI->getDwarfARangesSection());
2511 CompileUnit *Unit = GetBaseCompileUnit();
2513 // Don't include size of length
2514 Asm->EmitInt32(0x1c); Asm->EOL("Length of Address Ranges Info");
2516 Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("Dwarf Version");
2518 EmitReference("info_begin", Unit->getID());
2519 Asm->EOL("Offset of Compilation Unit Info");
2521 Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Size of Address");
2523 Asm->EmitInt8(0); Asm->EOL("Size of Segment Descriptor");
2525 Asm->EmitInt16(0); Asm->EOL("Pad (1)");
2526 Asm->EmitInt16(0); Asm->EOL("Pad (2)");
2529 EmitReference("text_begin", 0); Asm->EOL("Address");
2530 EmitDifference("text_end", 0, "text_begin", 0, true); Asm->EOL("Length");
2532 Asm->EmitInt32(0); Asm->EOL("EOM (1)");
2533 Asm->EmitInt32(0); Asm->EOL("EOM (2)");
2539 /// EmitDebugRanges - Emit visible names into a debug ranges section.
2541 void DwarfDebug::EmitDebugRanges() {
2542 // Start the dwarf ranges section.
2543 Asm->SwitchToDataSection(TAI->getDwarfRangesSection());
2547 /// EmitDebugMacInfo - Emit visible names into a debug macinfo section.
2549 void DwarfDebug::EmitDebugMacInfo() {
2550 if (const char *LineInfoDirective = TAI->getDwarfMacroInfoSection()) {
2551 // Start the dwarf macinfo section.
2552 Asm->SwitchToDataSection(LineInfoDirective);
2557 /// EmitDebugInlineInfo - Emit inline info using following format.
2559 /// 1. length of section
2560 /// 2. Dwarf version number
2561 /// 3. address size.
2563 /// Entries (one "entry" for each function that was inlined):
2565 /// 1. offset into __debug_str section for MIPS linkage name, if exists;
2566 /// otherwise offset into __debug_str for regular function name.
2567 /// 2. offset into __debug_str section for regular function name.
2568 /// 3. an unsigned LEB128 number indicating the number of distinct inlining
2569 /// instances for the function.
2571 /// The rest of the entry consists of a {die_offset, low_pc} pair for each
2572 /// inlined instance; the die_offset points to the inlined_subroutine die in the
2573 /// __debug_info section, and the low_pc is the starting address for the
2574 /// inlining instance.
2575 void DwarfDebug::EmitDebugInlineInfo() {
2576 if (!TAI->doesDwarfUsesInlineInfoSection())
2582 Asm->SwitchToDataSection(TAI->getDwarfDebugInlineSection());
2584 EmitDifference("debug_inlined_end", 1,
2585 "debug_inlined_begin", 1, true);
2586 Asm->EOL("Length of Debug Inlined Information Entry");
2588 EmitLabel("debug_inlined_begin", 1);
2590 Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("Dwarf Version");
2591 Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)");
2593 for (DenseMap<GlobalVariable *, SmallVector<unsigned, 4> >::iterator
2594 I = InlineInfo.begin(), E = InlineInfo.end(); I != E; ++I) {
2595 GlobalVariable *GV = I->first;
2596 SmallVector<unsigned, 4> &Labels = I->second;
2597 DISubprogram SP(GV);
2601 SP.getLinkageName(LName);
2604 Asm->EmitString(LName.empty() ? Name : LName);
2605 Asm->EOL("MIPS linkage name");
2607 Asm->EmitString(Name); Asm->EOL("Function name");
2609 Asm->EmitULEB128Bytes(Labels.size()); Asm->EOL("Inline count");
2611 for (SmallVector<unsigned, 4>::iterator LI = Labels.begin(),
2612 LE = Labels.end(); LI != LE; ++LI) {
2613 DIE *SP = MainCU->getDieMapSlotFor(GV);
2614 Asm->EmitInt32(SP->getOffset()); Asm->EOL("DIE offset");
2616 if (TD->getPointerSize() == sizeof(int32_t))
2617 O << TAI->getData32bitsDirective();
2619 O << TAI->getData64bitsDirective();
2621 PrintLabelName("label", *LI); Asm->EOL("low_pc");
2625 EmitLabel("debug_inlined_end", 1);