mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
DebugInfo: Refactor emitDebugPubNames/Types into a common implementation
I could fold the callers into their one call site, but the indirection (given how verbose choosing the section is) seemed helpful. The use of a member function pointer's a bit "tricky", but seems limited enough, the call sites are simple/clean/clear, and there's only one use. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203619 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0932a749a3
commit
e98b0e466f
@ -2204,6 +2204,12 @@ 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<const DIE *> &(DwarfUnit::*Accessor)() const) {
|
||||
for (const auto &NU : CUMap) {
|
||||
DwarfCompileUnit *TheU = NU.second;
|
||||
if (auto Skeleton = static_cast<DwarfCompileUnit *>(TheU->getSkeleton()))
|
||||
@ -2214,9 +2220,9 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) {
|
||||
Asm->OutStreamer.SwitchSection(PSec);
|
||||
|
||||
// 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);
|
||||
@ -2231,7 +2237,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 : (getUnits()[ID]->*Accessor)()) {
|
||||
const char *Name = GI.getKeyData();
|
||||
const DIE *Entity = GI.second;
|
||||
|
||||
@ -2261,58 +2267,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<DwarfCompileUnit *>(TheU->getSkeleton()))
|
||||
TheU = Skeleton;
|
||||
unsigned ID = TheU->getUniqueID();
|
||||
|
||||
// Start the dwarf pubtypes section.
|
||||
Asm->OutStreamer.SwitchSection(PSec);
|
||||
|
||||
// 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.
|
||||
|
@ -585,6 +585,11 @@ class DwarfDebug : public AsmPrinterHandler {
|
||||
/// index.
|
||||
void emitDebugPubTypes(bool GnuStyle = false);
|
||||
|
||||
void
|
||||
emitDebugPubSection(bool GnuStyle, const MCSection *PSec, StringRef Name,
|
||||
const StringMap<const DIE *> &(DwarfUnit::*Accessor)()
|
||||
const);
|
||||
|
||||
/// \brief Emit visible names into a debug str section.
|
||||
void emitDebugStr();
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
; Check that we get a symbol off of the debug_info section when using split dwarf and pubnames.
|
||||
|
||||
; CHECK: .Lpubtypes_begin0:
|
||||
; CHECK: .LpubTypes_begin0:
|
||||
; CHECK-NEXT: .short 2 # DWARF Version
|
||||
; CHECK-NEXT: .long .L.debug_info_begin0 # Offset of Compilation Unit Info
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user