X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FAsmPrinter%2FDwarfDebug.cpp;h=45a90dc12d7b61add8dfb3a8f0ec1e508520168e;hb=ef953d6399f396b129417e1cdadcd6dc53b9a0ec;hp=17bb6857cdc926915419a541e0e48f099e8b38fd;hpb=bd86fbe0d721aaa949d9a7be25fa7ae4d89972b7;p=oota-llvm.git diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 17bb6857cdc..45a90dc12d7 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -501,8 +501,7 @@ DIE *DwarfDebug::constructLexicalScopeDIE(DwarfCompileUnit *TheCU, assert(Start->isDefined() && "Invalid starting label for an inlined scope!"); assert(End->isDefined() && "Invalid end label for an inlined scope!"); - TheCU->addLabelAddress(ScopeDIE, dwarf::DW_AT_low_pc, Start); - TheCU->addLabelAddress(ScopeDIE, dwarf::DW_AT_high_pc, End); + attachLowHighPC(TheCU, ScopeDIE, Start, End); return ScopeDIE; } @@ -1186,26 +1185,23 @@ bool DwarfDebug::addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope) { void DwarfDebug::collectVariableInfoFromMMITable( SmallPtrSet &Processed) { for (const auto &VI : MMI->getVariableDbgInfo()) { - const MDNode *Var = VI.first; - if (!Var) + if (!VI.Var) continue; - Processed.insert(Var); - DIVariable DV(Var); - const std::pair &VP = VI.second; - - LexicalScope *Scope = LScopes.findLexicalScope(VP.second); + Processed.insert(VI.Var); + DIVariable DV(VI.Var); + LexicalScope *Scope = LScopes.findLexicalScope(VI.Loc); // If variable scope is not found then skip this variable. if (Scope == 0) continue; - DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.second); + DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VI.Loc); DbgVariable *RegVar = new DbgVariable(DV, AbsDbgVariable, this); - RegVar->setFrameIndex(VP.first); + RegVar->setFrameIndex(VI.Slot); if (!addCurrentFnArgument(RegVar, Scope)) addScopeVariable(Scope, RegVar); if (AbsDbgVariable) - AbsDbgVariable->setFrameIndex(VP.first); + AbsDbgVariable->setFrameIndex(VI.Slot); } } @@ -2208,8 +2204,17 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) { GnuStyle ? Asm->getObjFileLowering().getDwarfGnuPubNamesSection() : Asm->getObjFileLowering().getDwarfPubNamesSection(); + emitDebugPubSection(GnuStyle, PSec, "Names", &DwarfUnit::getGlobalNames); +} + +void DwarfDebug::emitDebugPubSection( + bool GnuStyle, const MCSection *PSec, StringRef Name, + const StringMap &(DwarfUnit::*Accessor)() const) { for (const auto &NU : CUMap) { DwarfCompileUnit *TheU = NU.second; + + const auto &Globals = (TheU->*Accessor)(); + if (auto Skeleton = static_cast(TheU->getSkeleton())) TheU = Skeleton; unsigned ID = TheU->getUniqueID(); @@ -2217,14 +2222,10 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) { // Start the dwarf pubnames section. Asm->OutStreamer.SwitchSection(PSec); - // Emit a label so we can reference the beginning of this pubname section. - if (GnuStyle) - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("gnu_pubnames", ID)); - // Emit the header. - Asm->OutStreamer.AddComment("Length of Public Names Info"); - MCSymbol *BeginLabel = Asm->GetTempSymbol("pubnames_begin", ID); - MCSymbol *EndLabel = Asm->GetTempSymbol("pubnames_end", ID); + Asm->OutStreamer.AddComment("Length of Public " + Name + " Info"); + MCSymbol *BeginLabel = Asm->GetTempSymbol("pub" + Name + "_begin", ID); + MCSymbol *EndLabel = Asm->GetTempSymbol("pub" + Name + "_end", ID); Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); Asm->OutStreamer.EmitLabel(BeginLabel); @@ -2239,7 +2240,7 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) { Asm->EmitLabelDifference(TheU->getLabelEnd(), TheU->getLabelBegin(), 4); // Emit the pubnames for this compilation unit. - for (const auto &GI : getUnits()[ID]->getGlobalNames()) { + for (const auto &GI : Globals) { const char *Name = GI.getKeyData(); const DIE *Entity = GI.second; @@ -2269,62 +2270,7 @@ void DwarfDebug::emitDebugPubTypes(bool GnuStyle) { GnuStyle ? Asm->getObjFileLowering().getDwarfGnuPubTypesSection() : Asm->getObjFileLowering().getDwarfPubTypesSection(); - for (const auto &NU : CUMap) { - DwarfCompileUnit *TheU = NU.second; - if (auto Skeleton = static_cast(TheU->getSkeleton())) - TheU = Skeleton; - unsigned ID = TheU->getUniqueID(); - - // Start the dwarf pubtypes section. - Asm->OutStreamer.SwitchSection(PSec); - - // Emit a label so we can reference the beginning of this pubtype section. - if (GnuStyle) - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("gnu_pubtypes", ID)); - - // Emit the header. - Asm->OutStreamer.AddComment("Length of Public Types Info"); - MCSymbol *BeginLabel = Asm->GetTempSymbol("pubtypes_begin", ID); - MCSymbol *EndLabel = Asm->GetTempSymbol("pubtypes_end", ID); - Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); - - Asm->OutStreamer.EmitLabel(BeginLabel); - - Asm->OutStreamer.AddComment("DWARF Version"); - Asm->EmitInt16(dwarf::DW_PUBTYPES_VERSION); - - Asm->OutStreamer.AddComment("Offset of Compilation Unit Info"); - Asm->EmitSectionOffset(TheU->getLabelBegin(), TheU->getSectionSym()); - - Asm->OutStreamer.AddComment("Compilation Unit Length"); - Asm->EmitLabelDifference(TheU->getLabelEnd(), TheU->getLabelBegin(), 4); - - // Emit the pubtypes. - for (const auto &GI : getUnits()[ID]->getGlobalTypes()) { - const char *Name = GI.getKeyData(); - const DIE *Entity = GI.second; - - Asm->OutStreamer.AddComment("DIE offset"); - Asm->EmitInt32(Entity->getOffset()); - - if (GnuStyle) { - dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheU, Entity); - Asm->OutStreamer.AddComment( - Twine("Kind: ") + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " + - dwarf::GDBIndexEntryLinkageString(Desc.Linkage)); - Asm->EmitInt8(Desc.toBits()); - } - - Asm->OutStreamer.AddComment("External Name"); - - // Emit the name with a terminating null byte. - Asm->OutStreamer.EmitBytes(StringRef(Name, GI.getKeyLength() + 1)); - } - - Asm->OutStreamer.AddComment("End Mark"); - Asm->EmitInt32(0); - Asm->OutStreamer.EmitLabel(EndLabel); - } + emitDebugPubSection(GnuStyle, PSec, "Types", &DwarfUnit::getGlobalTypes); } // Emit strings into a string section.