AbbreviationsSet(InitAbbreviationsSetSize),
SourceIdMap(DIEValueAllocator), InfoStringPool(DIEValueAllocator),
PrevLabel(NULL), GlobalCUIndexCount(0),
- InfoHolder(A, &AbbreviationsSet, &Abbreviations, &InfoStringPool),
+ InfoHolder(A, &AbbreviationsSet, &Abbreviations,
+ &InfoStringPool, "info_string"),
SkeletonCU(0),
SkeletonAbbrevSet(InitAbbreviationsSetSize),
- SkeletonHolder(A, &SkeletonAbbrevSet, &SkeletonAbbrevs, &InfoStringPool) {
+ SkeletonStringPool(DIEValueAllocator),
+ SkeletonHolder(A, &SkeletonAbbrevSet, &SkeletonAbbrevs,
+ &SkeletonStringPool, "skel_string") {
DwarfInfoSectionSym = DwarfAbbrevSectionSym = 0;
DwarfStrSectionSym = TextSectionSym = 0;
DwarfDebugRangeSectionSym = DwarfDebugLocSectionSym = 0;
- DwarfAbbrevDWOSectionSym = 0;
+ DwarfAbbrevDWOSectionSym = DwarfStrDWOSectionSym = 0;
FunctionBeginSym = FunctionEndSym = 0;
// Turn on accelerator tables and older gdb compatibility
}
MCSymbol *DwarfUnits::getStringPoolSym() {
- return Asm->GetTempSymbol("section_str");
+ return Asm->GetTempSymbol(StringPref);
}
MCSymbol *DwarfUnits::getStringPoolEntry(StringRef Str) {
if (Entry.first) return Entry.first;
Entry.second = NextStringPoolNumber++;
- return Entry.first = Asm->GetTempSymbol("string", Entry.second);
+ return Entry.first = Asm->GetTempSymbol(StringPref, Entry.second);
}
// Define a unique number for the abbreviation.
// Finally emit string information into a string table.
emitDebugStr();
+ if (useSplitDwarf())
+ emitDebugStrDWO();
// clean up.
SPMap.clear();
emitSectionSym(Asm, TLOF.getDwarfLocSection());
emitSectionSym(Asm, TLOF.getDwarfPubTypesSection());
DwarfStrSectionSym =
- emitSectionSym(Asm, TLOF.getDwarfStrSection(), "section_str");
+ emitSectionSym(Asm, TLOF.getDwarfStrSection(), "info_string");
+ if (useSplitDwarf())
+ DwarfStrDWOSectionSym =
+ emitSectionSym(Asm, TLOF.getDwarfStrDWOSection(), "skel_string");
DwarfDebugRangeSectionSym = emitSectionSym(Asm, TLOF.getDwarfRangesSection(),
"debug_range");
}
}
-// Emit visible names into a debug str section.
-void DwarfDebug::emitDebugStr() {
- // Check to see if it is worth the effort.
- if (InfoHolder.getStringPool()->empty()) return;
+// Emit strings into a string section.
+void DwarfUnits::emitStrings(const MCSection *Section) {
+
+ if (StringPool->empty()) return;
// Start the dwarf str section.
- Asm->OutStreamer.SwitchSection(
- Asm->getObjFileLowering().getDwarfStrSection());
+ Asm->OutStreamer.SwitchSection(Section);
// Get all of the string pool entries and put them in an array by their ID so
// we can sort them.
SmallVector<std::pair<unsigned,
- StringMapEntry<std::pair<MCSymbol*, unsigned> >*>, 64> Entries;
+ StringMapEntry<std::pair<MCSymbol*, unsigned> >*>, 64> Entries;
for (StringMap<std::pair<MCSymbol*, unsigned> >::iterator
- I = InfoHolder.getStringPool()->begin(),
- E = InfoHolder.getStringPool()->end();
+ I = StringPool->begin(), E = StringPool->end();
I != E; ++I)
Entries.push_back(std::make_pair(I->second.second, &*I));
}
}
+// Emit visible names into a debug str section.
+void DwarfDebug::emitDebugStr() {
+ DwarfUnits &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder;
+ Holder.emitStrings(Asm->getObjFileLowering().getDwarfStrSection());
+}
+
// Emit visible names into a debug loc section.
void DwarfDebug::emitDebugLoc() {
if (DotDebugLocEntries.empty())
DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
CompileUnit *NewCU = new CompileUnit(GlobalCUIndexCount++,
DIUnit.getLanguage(), Die, Asm,
- this, &InfoHolder);
+ this, &SkeletonHolder);
// FIXME: This should be the .dwo file.
NewCU->addString(Die, dwarf::DW_AT_GNU_dwo_name, FN);
emitAbbrevs(Asm->getObjFileLowering().getDwarfAbbrevDWOSection(),
&Abbreviations);
}
+
+// Emit the .debug_str.dwo section for separated dwarf. This contains the
+// string section and is identical in format to traditional .debug_str
+// sections.
+void DwarfDebug::emitDebugStrDWO() {
+ assert(useSplitDwarf() && "No split dwarf?");
+ InfoHolder.emitStrings(Asm->getObjFileLowering().getDwarfStrDWOSection());
+}
// A pointer to all units in the section.
SmallVector<CompileUnit *, 1> CUs;
- // Collection of strings for this unit.
+ // Collection of strings for this unit and assorted symbols.
StrPool *StringPool;
unsigned NextStringPoolNumber;
+ std::string StringPref;
public:
DwarfUnits(AsmPrinter *AP, FoldingSet<DIEAbbrev> *AS,
- std::vector<DIEAbbrev *> *A, StrPool *SP) :
+ std::vector<DIEAbbrev *> *A,
+ StrPool *SP, const char *Pref) :
Asm(AP), AbbreviationsSet(AS), Abbreviations(A),
- StringPool(SP), NextStringPoolNumber(0) {}
+ StringPool(SP), NextStringPoolNumber(0), StringPref(Pref) {}
/// \brief Compute the size and offset of a DIE given an incoming Offset.
unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
void emitUnits(DwarfDebug *, const MCSection *, const MCSection *,
const MCSymbol *);
+ /// \brief Emit all of the strings to the section given.
+ void emitStrings(const MCSection *);
+
/// \brief Returns the entry into the start of the pool.
MCSymbol *getStringPoolSym();
MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
MCSymbol *DwarfDebugLocSectionSym;
MCSymbol *FunctionBeginSym, *FunctionEndSym;
- MCSymbol *DwarfAbbrevDWOSectionSym;
+ MCSymbol *DwarfAbbrevDWOSectionSym, *DwarfStrDWOSectionSym;
// As an optimization, there is no need to emit an entry in the directory
// table for the same directory as DW_at_comp_dir.
// The CU left in the original object file for separated debug info.
CompileUnit *SkeletonCU;
- // Used to uniquely define abbreviations for the skeleton emission.
+ // 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;
+ // List of strings used in the skeleton.
+ StrPool SkeletonStringPool;
+
+ // Holder for the skeleton information.
DwarfUnits SkeletonHolder;
private:
/// \brief Emit the debug abbrev dwo section.
void emitDebugAbbrevDWO();
+ /// \brief Emit the debug str dwo section.
+ void emitDebugStrDWO();
+
/// \brief Create new CompileUnit for the given metadata node with tag
/// DW_TAG_compile_unit.
CompileUnit *constructCompileUnit(const MDNode *N);