forked from OSchip/llvm-project
Revert "dwarfgen: Add support for generating the debug_str_offsets section, take 2"
This reverts commit r337933. The build error is fixed but the test now fails on the darwin buildbots. Investigating... llvm-svn: 337935
This commit is contained in:
parent
4e07509d18
commit
da3c4fb5fe
|
@ -1506,9 +1506,8 @@ void DwarfDebug::emitAbbreviations() {
|
||||||
|
|
||||||
void DwarfDebug::emitStringOffsetsTableHeader() {
|
void DwarfDebug::emitStringOffsetsTableHeader() {
|
||||||
DwarfFile &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder;
|
DwarfFile &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder;
|
||||||
Holder.getStringPool().emitStringOffsetsTableHeader(
|
Holder.emitStringOffsetsTableHeader(
|
||||||
*Asm, Asm->getObjFileLowering().getDwarfStrOffSection(),
|
Asm->getObjFileLowering().getDwarfStrOffSection());
|
||||||
Holder.getStringOffsetsStartSym());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename AccelTableT>
|
template <typename AccelTableT>
|
||||||
|
@ -2293,9 +2292,8 @@ void DwarfDebug::emitDebugLineDWO() {
|
||||||
|
|
||||||
void DwarfDebug::emitStringOffsetsTableHeaderDWO() {
|
void DwarfDebug::emitStringOffsetsTableHeaderDWO() {
|
||||||
assert(useSplitDwarf() && "No split dwarf?");
|
assert(useSplitDwarf() && "No split dwarf?");
|
||||||
InfoHolder.getStringPool().emitStringOffsetsTableHeader(
|
InfoHolder.emitStringOffsetsTableHeader(
|
||||||
*Asm, Asm->getObjFileLowering().getDwarfStrOffDWOSection(),
|
Asm->getObjFileLowering().getDwarfStrOffDWOSection());
|
||||||
InfoHolder.getStringOffsetsStartSym());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit the .debug_str.dwo section for separated dwarf. This contains the
|
// Emit the .debug_str.dwo section for separated dwarf. This contains the
|
||||||
|
|
|
@ -28,6 +28,26 @@ void DwarfFile::addUnit(std::unique_ptr<DwarfCompileUnit> U) {
|
||||||
CUs.push_back(std::move(U));
|
CUs.push_back(std::move(U));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DwarfFile::emitStringOffsetsTableHeader(MCSection *Section) {
|
||||||
|
if (StrPool.empty())
|
||||||
|
return;
|
||||||
|
Asm->OutStreamer->SwitchSection(Section);
|
||||||
|
unsigned EntrySize = 4;
|
||||||
|
// FIXME: DWARF64
|
||||||
|
// We are emitting the header for a contribution to the string offsets
|
||||||
|
// table. The header consists of an entry with the contribution's
|
||||||
|
// size (not including the size of the length field), the DWARF version and
|
||||||
|
// 2 bytes of padding.
|
||||||
|
Asm->emitInt32(StrPool.size() * EntrySize + 4);
|
||||||
|
Asm->emitInt16(Asm->getDwarfVersion());
|
||||||
|
Asm->emitInt16(0);
|
||||||
|
// Define the symbol that marks the start of the contribution. It is
|
||||||
|
// referenced by most unit headers via DW_AT_str_offsets_base.
|
||||||
|
// Split units do not use the attribute.
|
||||||
|
if (StringOffsetsStartSym)
|
||||||
|
Asm->OutStreamer->EmitLabel(StringOffsetsStartSym);
|
||||||
|
}
|
||||||
|
|
||||||
// Emit the various dwarf units to the unit section USection with
|
// Emit the various dwarf units to the unit section USection with
|
||||||
// the abbreviations going into ASection.
|
// the abbreviations going into ASection.
|
||||||
void DwarfFile::emitUnits(bool UseOffsets) {
|
void DwarfFile::emitUnits(bool UseOffsets) {
|
||||||
|
|
|
@ -91,6 +91,9 @@ public:
|
||||||
/// Add a unit to the list of CUs.
|
/// Add a unit to the list of CUs.
|
||||||
void addUnit(std::unique_ptr<DwarfCompileUnit> U);
|
void addUnit(std::unique_ptr<DwarfCompileUnit> U);
|
||||||
|
|
||||||
|
/// Emit the string table offsets header.
|
||||||
|
void emitStringOffsetsTableHeader(MCSection *Section);
|
||||||
|
|
||||||
/// Emit all of the units to the section listed with the given
|
/// Emit all of the units to the section listed with the given
|
||||||
/// abbreviation section.
|
/// abbreviation section.
|
||||||
void emitUnits(bool UseOffsets);
|
void emitUnits(bool UseOffsets);
|
||||||
|
|
|
@ -39,28 +39,6 @@ DwarfStringPool::EntryRef DwarfStringPool::getEntry(AsmPrinter &Asm,
|
||||||
return EntryRef(*I.first);
|
return EntryRef(*I.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfStringPool::emitStringOffsetsTableHeader(AsmPrinter &Asm,
|
|
||||||
MCSection *Section,
|
|
||||||
MCSymbol *StartSym) {
|
|
||||||
if (empty())
|
|
||||||
return;
|
|
||||||
Asm.OutStreamer->SwitchSection(Section);
|
|
||||||
unsigned EntrySize = 4;
|
|
||||||
// FIXME: DWARF64
|
|
||||||
// We are emitting the header for a contribution to the string offsets
|
|
||||||
// table. The header consists of an entry with the contribution's
|
|
||||||
// size (not including the size of the length field), the DWARF version and
|
|
||||||
// 2 bytes of padding.
|
|
||||||
Asm.emitInt32(size() * EntrySize + 4);
|
|
||||||
Asm.emitInt16(Asm.getDwarfVersion());
|
|
||||||
Asm.emitInt16(0);
|
|
||||||
// Define the symbol that marks the start of the contribution. It is
|
|
||||||
// referenced by most unit headers via DW_AT_str_offsets_base.
|
|
||||||
// Split units do not use the attribute.
|
|
||||||
if (StartSym)
|
|
||||||
Asm.OutStreamer->EmitLabel(StartSym);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DwarfStringPool::emit(AsmPrinter &Asm, MCSection *StrSection,
|
void DwarfStringPool::emit(AsmPrinter &Asm, MCSection *StrSection,
|
||||||
MCSection *OffsetSection, bool UseRelativeOffsets) {
|
MCSection *OffsetSection, bool UseRelativeOffsets) {
|
||||||
if (Pool.empty())
|
if (Pool.empty())
|
||||||
|
|
|
@ -19,7 +19,6 @@ namespace llvm {
|
||||||
|
|
||||||
class AsmPrinter;
|
class AsmPrinter;
|
||||||
class MCSection;
|
class MCSection;
|
||||||
class MCSymbol;
|
|
||||||
|
|
||||||
// Collection of strings for this unit and assorted symbols.
|
// Collection of strings for this unit and assorted symbols.
|
||||||
// A String->Symbol mapping of strings used by indirect
|
// A String->Symbol mapping of strings used by indirect
|
||||||
|
@ -37,9 +36,6 @@ public:
|
||||||
|
|
||||||
DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix);
|
DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix);
|
||||||
|
|
||||||
void emitStringOffsetsTableHeader(AsmPrinter &Asm, MCSection *OffsetSection,
|
|
||||||
MCSymbol *StartSym);
|
|
||||||
|
|
||||||
void emit(AsmPrinter &Asm, MCSection *StrSection,
|
void emit(AsmPrinter &Asm, MCSection *StrSection,
|
||||||
MCSection *OffsetSection = nullptr,
|
MCSection *OffsetSection = nullptr,
|
||||||
bool UseRelativeOffsets = false);
|
bool UseRelativeOffsets = false);
|
||||||
|
|
|
@ -67,23 +67,12 @@ void TestAllForms() {
|
||||||
const uint32_t Dwarf32Values[] = {1, 2, 3, 4, 5, 6, 7, 8};
|
const uint32_t Dwarf32Values[] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||||
const char *StringValue = "Hello";
|
const char *StringValue = "Hello";
|
||||||
const char *StrpValue = "World";
|
const char *StrpValue = "World";
|
||||||
const char *StrxValue = "Indexed";
|
|
||||||
const char *Strx1Value = "Indexed1";
|
|
||||||
const char *Strx2Value = "Indexed2";
|
|
||||||
const char *Strx3Value = "Indexed3";
|
|
||||||
const char *Strx4Value = "Indexed4";
|
|
||||||
|
|
||||||
auto ExpectedDG = dwarfgen::Generator::create(Triple, Version);
|
auto ExpectedDG = dwarfgen::Generator::create(Triple, Version);
|
||||||
ASSERT_THAT_EXPECTED(ExpectedDG, Succeeded());
|
ASSERT_THAT_EXPECTED(ExpectedDG, Succeeded());
|
||||||
dwarfgen::Generator *DG = ExpectedDG.get().get();
|
dwarfgen::Generator *DG = ExpectedDG.get().get();
|
||||||
dwarfgen::CompileUnit &CU = DG->addCompileUnit();
|
dwarfgen::CompileUnit &CU = DG->addCompileUnit();
|
||||||
dwarfgen::DIE CUDie = CU.getUnitDIE();
|
dwarfgen::DIE CUDie = CU.getUnitDIE();
|
||||||
|
|
||||||
if (Version >= 5)
|
|
||||||
CUDie.addAttribute(dwarf::DW_AT_str_offsets_base, dwarf::DW_FORM_sec_offset,
|
|
||||||
*MCSymbolRefExpr::create(DG->getStringOffsetsStartSym(),
|
|
||||||
*DG->getMCContext()));
|
|
||||||
|
|
||||||
uint16_t Attr = DW_AT_lo_user;
|
uint16_t Attr = DW_AT_lo_user;
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -133,19 +122,6 @@ void TestAllForms() {
|
||||||
const auto Attr_DW_FORM_string = static_cast<dwarf::Attribute>(Attr++);
|
const auto Attr_DW_FORM_string = static_cast<dwarf::Attribute>(Attr++);
|
||||||
CUDie.addAttribute(Attr_DW_FORM_string, DW_FORM_string, StringValue);
|
CUDie.addAttribute(Attr_DW_FORM_string, DW_FORM_string, StringValue);
|
||||||
|
|
||||||
const auto Attr_DW_FORM_strx = static_cast<dwarf::Attribute>(Attr++);
|
|
||||||
const auto Attr_DW_FORM_strx1 = static_cast<dwarf::Attribute>(Attr++);
|
|
||||||
const auto Attr_DW_FORM_strx2 = static_cast<dwarf::Attribute>(Attr++);
|
|
||||||
const auto Attr_DW_FORM_strx3 = static_cast<dwarf::Attribute>(Attr++);
|
|
||||||
const auto Attr_DW_FORM_strx4 = static_cast<dwarf::Attribute>(Attr++);
|
|
||||||
if (Version >= 5) {
|
|
||||||
CUDie.addAttribute(Attr_DW_FORM_strx, DW_FORM_strx, StrxValue);
|
|
||||||
CUDie.addAttribute(Attr_DW_FORM_strx1, DW_FORM_strx1, Strx1Value);
|
|
||||||
CUDie.addAttribute(Attr_DW_FORM_strx2, DW_FORM_strx2, Strx2Value);
|
|
||||||
CUDie.addAttribute(Attr_DW_FORM_strx3, DW_FORM_strx3, Strx3Value);
|
|
||||||
CUDie.addAttribute(Attr_DW_FORM_strx4, DW_FORM_strx4, Strx4Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto Attr_DW_FORM_strp = static_cast<dwarf::Attribute>(Attr++);
|
const auto Attr_DW_FORM_strp = static_cast<dwarf::Attribute>(Attr++);
|
||||||
CUDie.addAttribute(Attr_DW_FORM_strp, DW_FORM_strp, StrpValue);
|
CUDie.addAttribute(Attr_DW_FORM_strp, DW_FORM_strp, StrpValue);
|
||||||
|
|
||||||
|
@ -305,33 +281,11 @@ void TestAllForms() {
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
auto ExtractedStringValue = toString(DieDG.find(Attr_DW_FORM_string));
|
auto ExtractedStringValue = toString(DieDG.find(Attr_DW_FORM_string));
|
||||||
EXPECT_TRUE((bool)ExtractedStringValue);
|
EXPECT_TRUE((bool)ExtractedStringValue);
|
||||||
EXPECT_STREQ(StringValue, *ExtractedStringValue);
|
EXPECT_TRUE(strcmp(StringValue, *ExtractedStringValue) == 0);
|
||||||
|
|
||||||
if (Version >= 5) {
|
|
||||||
auto ExtractedStrxValue = toString(DieDG.find(Attr_DW_FORM_strx));
|
|
||||||
EXPECT_TRUE((bool)ExtractedStrxValue);
|
|
||||||
EXPECT_STREQ(StrxValue, *ExtractedStrxValue);
|
|
||||||
|
|
||||||
auto ExtractedStrx1Value = toString(DieDG.find(Attr_DW_FORM_strx1));
|
|
||||||
EXPECT_TRUE((bool)ExtractedStrx1Value);
|
|
||||||
EXPECT_STREQ(Strx1Value, *ExtractedStrx1Value);
|
|
||||||
|
|
||||||
auto ExtractedStrx2Value = toString(DieDG.find(Attr_DW_FORM_strx2));
|
|
||||||
EXPECT_TRUE((bool)ExtractedStrx2Value);
|
|
||||||
EXPECT_STREQ(Strx2Value, *ExtractedStrx2Value);
|
|
||||||
|
|
||||||
auto ExtractedStrx3Value = toString(DieDG.find(Attr_DW_FORM_strx3));
|
|
||||||
EXPECT_TRUE((bool)ExtractedStrx3Value);
|
|
||||||
EXPECT_STREQ(Strx3Value, *ExtractedStrx3Value);
|
|
||||||
|
|
||||||
auto ExtractedStrx4Value = toString(DieDG.find(Attr_DW_FORM_strx4));
|
|
||||||
EXPECT_TRUE((bool)ExtractedStrx4Value);
|
|
||||||
EXPECT_STREQ(Strx4Value, *ExtractedStrx4Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ExtractedStrpValue = toString(DieDG.find(Attr_DW_FORM_strp));
|
auto ExtractedStrpValue = toString(DieDG.find(Attr_DW_FORM_strp));
|
||||||
EXPECT_TRUE((bool)ExtractedStrpValue);
|
EXPECT_TRUE((bool)ExtractedStrpValue);
|
||||||
EXPECT_STREQ(StrpValue, *ExtractedStrpValue);
|
EXPECT_TRUE(strcmp(StrpValue, *ExtractedStrpValue) == 0);
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Test reference forms
|
// Test reference forms
|
||||||
|
|
|
@ -53,37 +53,17 @@ void dwarfgen::DIE::addAttribute(uint16_t A, dwarf::Form Form, uint64_t U) {
|
||||||
DIEInteger(U));
|
DIEInteger(U));
|
||||||
}
|
}
|
||||||
|
|
||||||
void dwarfgen::DIE::addAttribute(uint16_t A, dwarf::Form Form,
|
|
||||||
const MCExpr &Expr) {
|
|
||||||
auto &DG = CU->getGenerator();
|
|
||||||
Die->addValue(DG.getAllocator(), static_cast<dwarf::Attribute>(A), Form,
|
|
||||||
DIEExpr(&Expr));
|
|
||||||
}
|
|
||||||
|
|
||||||
void dwarfgen::DIE::addAttribute(uint16_t A, dwarf::Form Form,
|
void dwarfgen::DIE::addAttribute(uint16_t A, dwarf::Form Form,
|
||||||
StringRef String) {
|
StringRef String) {
|
||||||
auto &DG = CU->getGenerator();
|
auto &DG = CU->getGenerator();
|
||||||
switch (Form) {
|
if (Form == DW_FORM_string) {
|
||||||
case DW_FORM_string:
|
|
||||||
Die->addValue(DG.getAllocator(), static_cast<dwarf::Attribute>(A), Form,
|
Die->addValue(DG.getAllocator(), static_cast<dwarf::Attribute>(A), Form,
|
||||||
new (DG.getAllocator())
|
new (DG.getAllocator())
|
||||||
DIEInlineString(String, DG.getAllocator()));
|
DIEInlineString(String, DG.getAllocator()));
|
||||||
break;
|
} else {
|
||||||
|
|
||||||
case DW_FORM_strp:
|
|
||||||
case DW_FORM_GNU_str_index:
|
|
||||||
case DW_FORM_strx:
|
|
||||||
case DW_FORM_strx1:
|
|
||||||
case DW_FORM_strx2:
|
|
||||||
case DW_FORM_strx3:
|
|
||||||
case DW_FORM_strx4:
|
|
||||||
Die->addValue(
|
Die->addValue(
|
||||||
DG.getAllocator(), static_cast<dwarf::Attribute>(A), Form,
|
DG.getAllocator(), static_cast<dwarf::Attribute>(A), Form,
|
||||||
DIEString(DG.getStringPool().getEntry(*DG.getAsmPrinter(), String)));
|
DIEString(DG.getStringPool().getEntry(*DG.getAsmPrinter(), String)));
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
llvm_unreachable("Unhandled form!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,7 +427,6 @@ llvm::Error dwarfgen::Generator::init(Triple TheTriple, uint16_t V) {
|
||||||
Asm->setDwarfVersion(Version);
|
Asm->setDwarfVersion(Version);
|
||||||
|
|
||||||
StringPool = llvm::make_unique<DwarfStringPool>(Allocator, *Asm, StringRef());
|
StringPool = llvm::make_unique<DwarfStringPool>(Allocator, *Asm, StringRef());
|
||||||
StringOffsetsStartSym = Asm->createTempSymbol("str_offsets_base");
|
|
||||||
|
|
||||||
return Error::success();
|
return Error::success();
|
||||||
}
|
}
|
||||||
|
@ -469,12 +448,7 @@ StringRef dwarfgen::Generator::generate() {
|
||||||
CU->setLength(CUOffset - 4);
|
CU->setLength(CUOffset - 4);
|
||||||
}
|
}
|
||||||
Abbreviations.Emit(Asm.get(), MOFI->getDwarfAbbrevSection());
|
Abbreviations.Emit(Asm.get(), MOFI->getDwarfAbbrevSection());
|
||||||
|
StringPool->emit(*Asm, MOFI->getDwarfStrSection());
|
||||||
StringPool->emitStringOffsetsTableHeader(*Asm, MOFI->getDwarfStrOffSection(),
|
|
||||||
StringOffsetsStartSym);
|
|
||||||
StringPool->emit(*Asm, MOFI->getDwarfStrSection(),
|
|
||||||
MOFI->getDwarfStrOffSection());
|
|
||||||
|
|
||||||
MS->SwitchSection(MOFI->getDwarfInfoSection());
|
MS->SwitchSection(MOFI->getDwarfInfoSection());
|
||||||
for (auto &CU : CompileUnits) {
|
for (auto &CU : CompileUnits) {
|
||||||
uint16_t Version = CU->getVersion();
|
uint16_t Version = CU->getVersion();
|
||||||
|
|
|
@ -89,14 +89,6 @@ public:
|
||||||
/// \param U the unsigned integer to encode.
|
/// \param U the unsigned integer to encode.
|
||||||
void addAttribute(uint16_t Attr, dwarf::Form Form, uint64_t U);
|
void addAttribute(uint16_t Attr, dwarf::Form Form, uint64_t U);
|
||||||
|
|
||||||
/// Add an attribute value to be encoded as a DIEExpr
|
|
||||||
///
|
|
||||||
/// \param Attr a dwarf::Attribute enumeration value or any uint16_t that
|
|
||||||
/// represents a user defined DWARF attribute.
|
|
||||||
/// \param Form the dwarf::Form to use when encoding the attribute.
|
|
||||||
/// \param Expr the MC expression used to compute the value
|
|
||||||
void addAttribute(uint16_t Attr, dwarf::Form Form, const MCExpr &Expr);
|
|
||||||
|
|
||||||
/// Add an attribute value to be encoded as a DIEString or DIEInlinedString.
|
/// Add an attribute value to be encoded as a DIEString or DIEInlinedString.
|
||||||
///
|
///
|
||||||
/// \param Attr a dwarf::Attribute enumeration value or any uint16_t that
|
/// \param Attr a dwarf::Attribute enumeration value or any uint16_t that
|
||||||
|
@ -250,8 +242,6 @@ class Generator {
|
||||||
std::vector<std::unique_ptr<LineTable>> LineTables;
|
std::vector<std::unique_ptr<LineTable>> LineTables;
|
||||||
DIEAbbrevSet Abbreviations;
|
DIEAbbrevSet Abbreviations;
|
||||||
|
|
||||||
MCSymbol *StringOffsetsStartSym;
|
|
||||||
|
|
||||||
SmallString<4096> FileBytes;
|
SmallString<4096> FileBytes;
|
||||||
/// The stream we use to generate the DWARF into as an ELF file.
|
/// The stream we use to generate the DWARF into as an ELF file.
|
||||||
std::unique_ptr<raw_svector_ostream> Stream;
|
std::unique_ptr<raw_svector_ostream> Stream;
|
||||||
|
@ -303,7 +293,6 @@ public:
|
||||||
MCContext *getMCContext() const { return MC.get(); }
|
MCContext *getMCContext() const { return MC.get(); }
|
||||||
DIEAbbrevSet &getAbbrevSet() { return Abbreviations; }
|
DIEAbbrevSet &getAbbrevSet() { return Abbreviations; }
|
||||||
DwarfStringPool &getStringPool() { return *StringPool; }
|
DwarfStringPool &getStringPool() { return *StringPool; }
|
||||||
MCSymbol *getStringOffsetsStartSym() const { return StringOffsetsStartSym; }
|
|
||||||
|
|
||||||
/// Save the generated DWARF file to disk.
|
/// Save the generated DWARF file to disk.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue