Split out abbreviations for the skeleton info from the rest of

the abbreviations. Part of implementing split dwarf.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170589 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher 2012-12-19 22:02:53 +00:00
parent 37a942cd52
commit 6eebe47060
3 changed files with 68 additions and 21 deletions

View File

@ -158,12 +158,15 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
SourceIdMap(DIEValueAllocator), StringPool(DIEValueAllocator),
PrevLabel(NULL), GlobalCUIndexCount(0),
InfoHolder(A, &AbbreviationsSet, &Abbreviations),
SkeletonCU(0), SkeletonHolder(A, &AbbreviationsSet, &Abbreviations) {
SkeletonCU(0),
SkeletonAbbrevSet(InitAbbreviationsSetSize),
SkeletonHolder(A, &SkeletonAbbrevSet, &SkeletonAbbrevs) {
NextStringPoolNumber = 0;
DwarfInfoSectionSym = DwarfAbbrevSectionSym = 0;
DwarfStrSectionSym = TextSectionSym = 0;
DwarfDebugRangeSectionSym = DwarfDebugLocSectionSym = 0;
DwarfAbbrevDWOSectionSym = 0;
FunctionBeginSym = FunctionEndSym = 0;
// Turn on accelerator tables and older gdb compatibility
@ -944,6 +947,7 @@ void DwarfDebug::endModule() {
// Corresponding abbreviations into a abbrev section.
emitAbbreviations();
emitDebugAbbrevDWO();
// Emit info into a debug loc section.
emitDebugLoc();
@ -1705,6 +1709,10 @@ void DwarfDebug::emitSectionLabels() {
emitSectionSym(Asm, TLOF.getDwarfInfoSection(), "section_info");
DwarfAbbrevSectionSym =
emitSectionSym(Asm, TLOF.getDwarfAbbrevSection(), "section_abbrev");
if (useSplitDwarf())
DwarfAbbrevDWOSectionSym =
emitSectionSym(Asm, TLOF.getDwarfAbbrevDWOSection(),
"section_abbrev_dwo");
emitSectionSym(Asm, TLOF.getDwarfARangesSection());
if (const MCSection *MacroInfo = TLOF.getDwarfMacroInfoSection())
@ -1726,10 +1734,10 @@ void DwarfDebug::emitSectionLabels() {
}
// Recursively emits a debug information entry.
void DwarfDebug::emitDIE(DIE *Die) {
void DwarfDebug::emitDIE(DIE *Die, std::vector<DIEAbbrev *> *Abbrevs) {
// Get the abbreviation for this DIE.
unsigned AbbrevNumber = Die->getAbbrevNumber();
const DIEAbbrev *Abbrev = Abbreviations[AbbrevNumber - 1];
const DIEAbbrev *Abbrev = Abbrevs->at(AbbrevNumber - 1);
// Emit the code (index) for the abbreviation.
if (Asm->isVerbose())
@ -1806,7 +1814,7 @@ void DwarfDebug::emitDIE(DIE *Die) {
const std::vector<DIE *> &Children = Die->getChildren();
for (unsigned j = 0, M = Children.size(); j < M; ++j)
emitDIE(Children[j]);
emitDIE(Children[j], Abbrevs);
if (Asm->isVerbose())
Asm->OutStreamer.AddComment("End Of Children Mark");
@ -1847,7 +1855,7 @@ void DwarfUnits::emitUnits(DwarfDebug *DD,
Asm->OutStreamer.AddComment("Address Size (in bytes)");
Asm->EmitInt8(Asm->getDataLayout().getPointerSize());
DD->emitDIE(Die);
DD->emitDIE(Die, Abbreviations);
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol(USection->getLabelEndName(),
TheCU->getUniqueID()));
}
@ -1864,19 +1872,27 @@ void DwarfDebug::emitDebugInfo() {
// Emit the abbreviation section.
void DwarfDebug::emitAbbreviations() {
// Check to see if it is worth the effort.
if (!Abbreviations.empty()) {
// Start the debug abbrev section.
const MCSection *ASec = Asm->getObjFileLowering().getDwarfAbbrevSection();
Asm->OutStreamer.SwitchSection(ASec);
if (!useSplitDwarf())
emitAbbrevs(Asm->getObjFileLowering().getDwarfAbbrevSection(),
&Abbreviations);
else
emitSkeletonAbbrevs(Asm->getObjFileLowering().getDwarfAbbrevSection());
}
MCSymbol *Begin = Asm->GetTempSymbol(ASec->getLabelBeginName());
void DwarfDebug::emitAbbrevs(const MCSection *Section,
std::vector<DIEAbbrev *> *Abbrevs) {
// Check to see if it is worth the effort.
if (!Abbrevs->empty()) {
// Start the debug abbrev section.
Asm->OutStreamer.SwitchSection(Section);
MCSymbol *Begin = Asm->GetTempSymbol(Section->getLabelBeginName());
Asm->OutStreamer.EmitLabel(Begin);
// For each abbrevation.
for (unsigned i = 0, N = Abbreviations.size(); i < N; ++i) {
for (unsigned i = 0, N = Abbrevs->size(); i < N; ++i) {
// Get abbreviation data
const DIEAbbrev *Abbrev = Abbreviations[i];
const DIEAbbrev *Abbrev = Abbrevs->at(i);
// Emit the abbrevations code (base 1 index.)
Asm->EmitULEB128(Abbrev->getNumber(), "Abbreviation Code");
@ -1888,7 +1904,7 @@ void DwarfDebug::emitAbbreviations() {
// Mark end of abbreviations.
Asm->EmitULEB128(0, "EOM(3)");
MCSymbol *End = Asm->GetTempSymbol(ASec->getLabelEndName());
MCSymbol *End = Asm->GetTempSymbol(Section->getLabelEndName());
Asm->OutStreamer.EmitLabel(End);
}
}
@ -2382,24 +2398,35 @@ void DwarfDebug::emitSkeletonCU(const MCSection *Section) {
Asm->OutStreamer.AddComment("DWARF version number");
Asm->EmitInt16(dwarf::DWARF_VERSION);
Asm->OutStreamer.AddComment("Offset Into Abbrev. Section");
Asm->EmitSectionOffset(Asm->GetTempSymbol("abbrev_begin"),
const MCSection *ASec = Asm->getObjFileLowering().getDwarfAbbrevSection();
Asm->EmitSectionOffset(Asm->GetTempSymbol(ASec->getLabelBeginName()),
DwarfAbbrevSectionSym);
Asm->OutStreamer.AddComment("Address Size (in bytes)");
Asm->EmitInt8(Asm->getDataLayout().getPointerSize());
emitDIE(Die);
emitDIE(Die, &SkeletonAbbrevs);
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol(Section->getLabelEndName(),
SkeletonCU->getUniqueID()));
}
void DwarfDebug::emitSkeletonAbbrevs(const MCSection *Section) {
assert(useSplitDwarf() && "No split dwarf debug info?");
emitAbbrevs(Section, &SkeletonAbbrevs);
}
// Emit the .debug_info.dwo section for separated dwarf. This contains the
// compile units that would normally be in debug_info.
void DwarfDebug::emitDebugInfoDWO() {
assert(useSplitDwarf() && "No split dwarf debug info?");
// FIXME for Abbrev DWO.
InfoHolder.emitUnits(this, Asm->getObjFileLowering().getDwarfInfoDWOSection(),
Asm->getObjFileLowering().getDwarfAbbrevSection(),
DwarfAbbrevSectionSym);
Asm->getObjFileLowering().getDwarfAbbrevDWOSection(),
DwarfAbbrevDWOSectionSym);
}
// Emit the .debug_abbrev.dwo section for separated dwarf. This contains the
// abbreviations for the .debug_info.dwo section.
void DwarfDebug::emitDebugAbbrevDWO() {
assert(useSplitDwarf() && "No split dwarf?");
emitAbbrevs(Asm->getObjFileLowering().getDwarfAbbrevDWOSection(), &Abbreviations);
}

View File

@ -343,6 +343,7 @@ class DwarfDebug {
MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
MCSymbol *DwarfDebugLocSectionSym;
MCSymbol *FunctionBeginSym, *FunctionEndSym;
MCSymbol *DwarfAbbrevDWOSectionSym;
// As an optimization, there is no need to emit an entry in the directory
// table for the same directory as DW_at_comp_dir.
@ -371,6 +372,13 @@ class DwarfDebug {
// The CU left in the original object file for separated debug info.
CompileUnit *SkeletonCU;
// Used to uniquely define abbreviations for the skeleton emission.
FoldingSet<DIEAbbrev> SkeletonAbbrevSet;
// A list of all the unique abbreviations in use.
std::vector<DIEAbbrev *> SkeletonAbbrevs;
DwarfUnits SkeletonHolder;
private:
@ -420,6 +428,9 @@ private:
/// open.
void endSections();
/// \brief Emit a set of abbreviations to the specific section.
void emitAbbrevs(const MCSection *, std::vector<DIEAbbrev*> *);
/// \brief Emit the debug info section.
void emitDebugInfo();
@ -473,9 +484,15 @@ private:
/// \brief Emit the local split debug info section.
void emitSkeletonCU(const MCSection *);
/// \brief Emit the local split abbreviations.
void emitSkeletonAbbrevs(const MCSection *);
/// \brief Emit the debug info dwo section.
void emitDebugInfoDWO();
/// \brief Emit the debug abbrev dwo section.
void emitDebugAbbrevDWO();
/// \brief Create new CompileUnit for the given metadata node with tag
/// DW_TAG_compile_unit.
CompileUnit *constructCompileUnit(const MDNode *N);
@ -570,7 +587,7 @@ public:
MCSymbol *getStringPoolEntry(StringRef Str);
/// \brief Recursively Emits a debug information entry.
void emitDIE(DIE *Die);
void emitDIE(DIE *Die, std::vector<DIEAbbrev *> *Abbrevs);
/// \brief Returns whether or not to limit some of our debug
/// output to the limitations of darwin gdb.

View File

@ -24,3 +24,6 @@
; CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
; CHECK: DW_AT_stmt_list [DW_FORM_data4] (0x00000000)
; CHECK: DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x0000003b] = "/usr/local/google/home/echristo/tmp")
; Make sure there's only one compile unit for now.
; CHECK-NOT: DW_TAG_compile_unit