To simplify some code move the unit emission into the holders.

Make emitDIE public accordingly. No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170258 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher
2012-12-15 00:04:07 +00:00
parent cf6b8ad784
commit b1e66d0c4f
2 changed files with 34 additions and 23 deletions

View File

@ -1814,16 +1814,22 @@ void DwarfDebug::emitDIE(DIE *Die) {
} }
} }
void DwarfDebug::emitCompileUnits(const MCSection *Section) { // Emit the various dwarf units to the unit section USection with
Asm->OutStreamer.SwitchSection(Section); // the abbreviations going into ASection.
for (DenseMap<const MDNode *, CompileUnit *>::iterator I = CUMap.begin(), void DwarfUnits::emitUnits(DwarfDebug *DD,
E = CUMap.end(); I != E; ++I) { const MCSection *USection,
CompileUnit *TheCU = I->second; const MCSection *ASection,
const MCSymbol *ASectionSym) {
Asm->OutStreamer.SwitchSection(USection);
for (SmallVector<CompileUnit *, 1>::iterator I = CUs.begin(),
E = CUs.end(); I != E; ++I) {
CompileUnit *TheCU = *I;
DIE *Die = TheCU->getCUDie(); DIE *Die = TheCU->getCUDie();
// Emit the compile units header. // Emit the compile units header.
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol(Section->getLabelBeginName(), Asm->OutStreamer
TheCU->getUniqueID())); .EmitLabel(Asm->GetTempSymbol(USection->getLabelBeginName(),
TheCU->getUniqueID()));
// Emit size of content not including length itself // Emit size of content not including length itself
unsigned ContentSize = Die->getSize() + unsigned ContentSize = Die->getSize() +
@ -1836,24 +1842,24 @@ void DwarfDebug::emitCompileUnits(const MCSection *Section) {
Asm->OutStreamer.AddComment("DWARF version number"); Asm->OutStreamer.AddComment("DWARF version number");
Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EmitInt16(dwarf::DWARF_VERSION);
Asm->OutStreamer.AddComment("Offset Into Abbrev. Section"); Asm->OutStreamer.AddComment("Offset Into Abbrev. Section");
const MCSection *ASec = Asm->getObjFileLowering().getDwarfAbbrevSection(); Asm->EmitSectionOffset(Asm->GetTempSymbol(ASection->getLabelBeginName()),
Asm->EmitSectionOffset(Asm->GetTempSymbol(ASec->getLabelBeginName()), ASectionSym);
DwarfAbbrevSectionSym);
Asm->OutStreamer.AddComment("Address Size (in bytes)"); Asm->OutStreamer.AddComment("Address Size (in bytes)");
Asm->EmitInt8(Asm->getDataLayout().getPointerSize()); Asm->EmitInt8(Asm->getDataLayout().getPointerSize());
emitDIE(Die); DD->emitDIE(Die);
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol(Section->getLabelEndName(), Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol(USection->getLabelEndName(),
TheCU->getUniqueID())); TheCU->getUniqueID()));
} }
} }
// Emit the debug info section. // Emit the debug info section.
void DwarfDebug::emitDebugInfo() { void DwarfDebug::emitDebugInfo() {
if (!useSplitDwarf()) DwarfUnits &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder;
emitCompileUnits(Asm->getObjFileLowering().getDwarfInfoSection());
else Holder.emitUnits(this, Asm->getObjFileLowering().getDwarfInfoSection(),
emitSkeletonCU(Asm->getObjFileLowering().getDwarfInfoSection()); Asm->getObjFileLowering().getDwarfAbbrevSection(),
DwarfAbbrevSectionSym);
} }
// Emit the abbreviation section. // Emit the abbreviation section.
@ -2392,5 +2398,8 @@ void DwarfDebug::emitSkeletonCU(const MCSection *Section) {
// compile units that would normally be in debug_info. // compile units that would normally be in debug_info.
void DwarfDebug::emitDebugInfoDWO() { void DwarfDebug::emitDebugInfoDWO() {
assert(useSplitDwarf() && "No split dwarf debug info?"); assert(useSplitDwarf() && "No split dwarf debug info?");
emitCompileUnits(Asm->getObjFileLowering().getDwarfInfoDWOSection()); // FIXME for Abbrev DWO.
InfoHolder.emitUnits(this, Asm->getObjFileLowering().getDwarfInfoDWOSection(),
Asm->getObjFileLowering().getDwarfAbbrevSection(),
DwarfAbbrevSectionSym);
} }

View File

@ -219,6 +219,11 @@ public:
/// \brief Add a unit to the list of CUs. /// \brief Add a unit to the list of CUs.
void addUnit(CompileUnit *CU) { CUs.push_back(CU); } void addUnit(CompileUnit *CU) { CUs.push_back(CU); }
/// \brief Emit all of the units to the section listed with the given
/// abbreviation section.
void emitUnits(DwarfDebug *, const MCSection *, const MCSection *,
const MCSymbol *);
}; };
/// \brief Collects and handles dwarf debug information. /// \brief Collects and handles dwarf debug information.
@ -394,9 +399,6 @@ private:
/// \brief Emit initial Dwarf sections with a label at the start of each one. /// \brief Emit initial Dwarf sections with a label at the start of each one.
void emitSectionLabels(); void emitSectionLabels();
/// \brief Recursively Emits a debug information entry.
void emitDIE(DIE *Die);
/// \brief Compute the size and offset of a DIE given an incoming Offset. /// \brief Compute the size and offset of a DIE given an incoming Offset.
unsigned computeSizeAndOffset(DIE *Die, unsigned Offset); unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
@ -417,9 +419,6 @@ private:
/// open. /// open.
void endSections(); void endSections();
/// \brief Emit all of the compile units to the target section.
void emitCompileUnits(const MCSection *);
/// \brief Emit the debug info section. /// \brief Emit the debug info section.
void emitDebugInfo(); void emitDebugInfo();
@ -569,6 +568,9 @@ public:
/// string text. /// string text.
MCSymbol *getStringPoolEntry(StringRef Str); MCSymbol *getStringPoolEntry(StringRef Str);
/// \brief Recursively Emits a debug information entry.
void emitDIE(DIE *Die);
/// \brief Returns whether or not to limit some of our debug /// \brief Returns whether or not to limit some of our debug
/// output to the limitations of darwin gdb. /// output to the limitations of darwin gdb.
bool useDarwinGDBCompat() { return IsDarwinGDBCompat; } bool useDarwinGDBCompat() { return IsDarwinGDBCompat; }