Skip to content
DwarfDebug.cpp 113 KiB
Newer Older
void DwarfDebug::emitSkeletonAbbrevs(const MCSection *Section) {
  assert(useSplitDwarf() && "No split dwarf debug info?");
  emitAbbrevs(Section, &SkeletonAbbrevs);
Eric Christopher's avatar
Eric Christopher committed
// 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?");
  InfoHolder.emitUnits(this, Asm->getObjFileLowering().getDwarfInfoDWOSection(),
                       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);

// 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?");
Eric Christopher's avatar
Eric Christopher committed
  const MCSection *OffSec = Asm->getObjFileLowering()
                            .getDwarfStrOffDWOSection();
  const MCSymbol *StrSym = DwarfStrSectionSym;
  InfoHolder.emitStrings(Asm->getObjFileLowering().getDwarfStrDWOSection(),
                         OffSec, StrSym);

/// When we don't know whether the correct form is ref4 or ref_addr, we create
/// a worklist item and insert it to DIEEntryWorklist.
void DwarfDebug::addDIEEntry(DIE *Die, uint16_t Attribute, uint16_t Form,
                             DIEEntry *Entry) {
  /// Early exit when we only have a single CU.
  if (GlobalCUIndexCount == 1 || Form != dwarf::DW_FORM_ref4) {
    Die->addValue(Attribute, Form, Entry);
    return;
  }
  DIE *DieCU = Die->checkCompileUnit();
  DIE *EntryCU = Entry->getEntry()->checkCompileUnit();
  if (!DieCU || !EntryCU) {
    // Die or Entry is not added to an owner yet.
    insertDIEEntryWorklist(Die, Attribute, Entry);
    return;
  }
  Die->addValue(Attribute,
         EntryCU == DieCU ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr,
         Entry);
}