If multiple compile units are seen then emit them independently. In other words, do not force all DIEs into first, whatever it is, compile unit.

Note, multiple compile unit support is not well tested (it did not work correctly until now anyway.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62116 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2009-01-12 23:05:55 +00:00
parent f6bac3e4bd
commit 72b663575f

View File

@ -2952,13 +2952,16 @@ private:
/// ///
void SizeAndOffsets() { void SizeAndOffsets() {
// Process base compile unit. // Process base compile unit.
CompileUnit *Unit = GetBaseCompileUnit(); for (DenseMap<Value *, CompileUnit *>::iterator CI = DW_CUs.begin(),
// Compute size of compile unit header CE = DW_CUs.end(); CI != CE; ++CI) {
unsigned Offset = sizeof(int32_t) + // Length of Compilation Unit Info CompileUnit *Unit = CI->second;
sizeof(int16_t) + // DWARF version number // Compute size of compile unit header
sizeof(int32_t) + // Offset Into Abbrev. Section unsigned Offset = sizeof(int32_t) + // Length of Compilation Unit Info
sizeof(int8_t); // Pointer Size (in bytes) sizeof(int16_t) + // DWARF version number
SizeAndOffsetDie(Unit->getDie(), Offset, true); sizeof(int32_t) + // Offset Into Abbrev. Section
sizeof(int8_t); // Pointer Size (in bytes)
SizeAndOffsetDie(Unit->getDie(), Offset, true);
}
} }
/// EmitDebugInfo - Emit the debug info section. /// EmitDebugInfo - Emit the debug info section.
@ -2967,32 +2970,35 @@ private:
// Start debug info section. // Start debug info section.
Asm->SwitchToDataSection(TAI->getDwarfInfoSection()); Asm->SwitchToDataSection(TAI->getDwarfInfoSection());
CompileUnit *Unit = GetBaseCompileUnit(); for (DenseMap<Value *, CompileUnit *>::iterator CI = DW_CUs.begin(),
DIE *Die = Unit->getDie(); CE = DW_CUs.end(); CI != CE; ++CI) {
// Emit the compile units header. CompileUnit *Unit = CI->second;
EmitLabel("info_begin", Unit->getID()); DIE *Die = Unit->getDie();
// Emit size of content not including length itself // Emit the compile units header.
unsigned ContentSize = Die->getSize() + EmitLabel("info_begin", Unit->getID());
sizeof(int16_t) + // DWARF version number // Emit size of content not including length itself
sizeof(int32_t) + // Offset Into Abbrev. Section unsigned ContentSize = Die->getSize() +
sizeof(int8_t) + // Pointer Size (in bytes) sizeof(int16_t) + // DWARF version number
sizeof(int32_t); // FIXME - extra pad for gdb bug. sizeof(int32_t) + // Offset Into Abbrev. Section
sizeof(int8_t) + // Pointer Size (in bytes)
Asm->EmitInt32(ContentSize); Asm->EOL("Length of Compilation Unit Info"); sizeof(int32_t); // FIXME - extra pad for gdb bug.
Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF version number");
EmitSectionOffset("abbrev_begin", "section_abbrev", 0, 0, true, false); Asm->EmitInt32(ContentSize); Asm->EOL("Length of Compilation Unit Info");
Asm->EOL("Offset Into Abbrev. Section"); Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF version number");
Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)"); EmitSectionOffset("abbrev_begin", "section_abbrev", 0, 0, true, false);
Asm->EOL("Offset Into Abbrev. Section");
EmitDIE(Die); Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)");
// FIXME - extra padding for gdb bug.
Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB"); EmitDIE(Die);
Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB"); // FIXME - extra padding for gdb bug.
Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB"); Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB"); Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
EmitLabel("info_end", Unit->getID()); Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB");
Asm->EOL(); EmitLabel("info_end", Unit->getID());
Asm->EOL();
}
} }
/// EmitAbbreviations - Emit the abbreviation section. /// EmitAbbreviations - Emit the abbreviation section.
@ -3290,39 +3296,42 @@ private:
// Start the dwarf pubnames section. // Start the dwarf pubnames section.
Asm->SwitchToDataSection(TAI->getDwarfPubNamesSection()); Asm->SwitchToDataSection(TAI->getDwarfPubNamesSection());
CompileUnit *Unit = GetBaseCompileUnit(); for (DenseMap<Value *, CompileUnit *>::iterator CI = DW_CUs.begin(),
CE = DW_CUs.end(); CI != CE; ++CI) {
CompileUnit *Unit = CI->second;
EmitDifference("pubnames_end", Unit->getID(), EmitDifference("pubnames_end", Unit->getID(),
"pubnames_begin", Unit->getID(), true); "pubnames_begin", Unit->getID(), true);
Asm->EOL("Length of Public Names Info"); Asm->EOL("Length of Public Names Info");
EmitLabel("pubnames_begin", Unit->getID()); EmitLabel("pubnames_begin", Unit->getID());
Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF Version"); Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF Version");
EmitSectionOffset("info_begin", "section_info", EmitSectionOffset("info_begin", "section_info",
Unit->getID(), 0, true, false); Unit->getID(), 0, true, false);
Asm->EOL("Offset of Compilation Unit Info"); Asm->EOL("Offset of Compilation Unit Info");
EmitDifference("info_end", Unit->getID(), "info_begin", Unit->getID(),true); EmitDifference("info_end", Unit->getID(), "info_begin", Unit->getID(),true);
Asm->EOL("Compilation Unit Length"); Asm->EOL("Compilation Unit Length");
std::map<std::string, DIE *> &Globals = Unit->getGlobals(); std::map<std::string, DIE *> &Globals = Unit->getGlobals();
for (std::map<std::string, DIE *>::iterator GI = Globals.begin(), for (std::map<std::string, DIE *>::iterator GI = Globals.begin(),
GE = Globals.end(); GE = Globals.end();
GI != GE; ++GI) { GI != GE; ++GI) {
const std::string &Name = GI->first; const std::string &Name = GI->first;
DIE * Entity = GI->second; DIE * Entity = GI->second;
Asm->EmitInt32(Entity->getOffset()); Asm->EOL("DIE offset"); Asm->EmitInt32(Entity->getOffset()); Asm->EOL("DIE offset");
Asm->EmitString(Name); Asm->EOL("External Name"); Asm->EmitString(Name); Asm->EOL("External Name");
}
Asm->EmitInt32(0); Asm->EOL("End Mark");
EmitLabel("pubnames_end", Unit->getID());
Asm->EOL();
} }
Asm->EmitInt32(0); Asm->EOL("End Mark");
EmitLabel("pubnames_end", Unit->getID());
Asm->EOL();
} }
/// EmitDebugStr - Emit visible names into a debug str section. /// EmitDebugStr - Emit visible names into a debug str section.