mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
DebugInfo: Simplify line table parsing to take all the units together, rather than CUs and TUs separately
This commit is contained in:
parent
3c2a4cc1bc
commit
c717659738
@ -319,8 +319,7 @@ public:
|
||||
using tu_range = DWARFUnitVector::iterator_range;
|
||||
using LineToUnitMap = std::map<uint64_t, DWARFUnit *>;
|
||||
|
||||
SectionParser(DWARFDataExtractor &Data, const DWARFContext &C, cu_range CUs,
|
||||
tu_range TUs);
|
||||
SectionParser(DWARFDataExtractor &Data, const DWARFContext &C, DWARFUnitVector::iterator_range Units);
|
||||
|
||||
/// Get the next line table from the section. Report any issues via the
|
||||
/// handlers.
|
||||
|
@ -548,8 +548,7 @@ void DWARFContext::dump(
|
||||
DObj->getLineSection().Data)) {
|
||||
DWARFDataExtractor LineData(*DObj, DObj->getLineSection(), isLittleEndian(),
|
||||
0);
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *this, compile_units(),
|
||||
type_units());
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *this, normal_units());
|
||||
DumpLineSection(Parser, DumpOpts, *Off);
|
||||
}
|
||||
|
||||
@ -558,8 +557,7 @@ void DWARFContext::dump(
|
||||
DObj->getLineDWOSection().Data)) {
|
||||
DWARFDataExtractor LineData(*DObj, DObj->getLineDWOSection(),
|
||||
isLittleEndian(), 0);
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *this, dwo_compile_units(),
|
||||
dwo_type_units());
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *this, dwo_units());
|
||||
DumpLineSection(Parser, DumpOpts, *Off);
|
||||
}
|
||||
|
||||
|
@ -1418,25 +1418,20 @@ bool DWARFDebugLine::LineTable::getFileLineInfoForAddress(
|
||||
// Therefore, collect up handles on all the Units that point into the
|
||||
// line-table section.
|
||||
static DWARFDebugLine::SectionParser::LineToUnitMap
|
||||
buildLineToUnitMap(DWARFDebugLine::SectionParser::cu_range CUs,
|
||||
DWARFDebugLine::SectionParser::tu_range TUs) {
|
||||
buildLineToUnitMap(DWARFUnitVector::iterator_range Units) {
|
||||
DWARFDebugLine::SectionParser::LineToUnitMap LineToUnit;
|
||||
for (const auto &CU : CUs)
|
||||
if (auto CUDIE = CU->getUnitDIE())
|
||||
for (const auto &U : Units)
|
||||
if (auto CUDIE = U->getUnitDIE())
|
||||
if (auto StmtOffset = toSectionOffset(CUDIE.find(DW_AT_stmt_list)))
|
||||
LineToUnit.insert(std::make_pair(*StmtOffset, &*CU));
|
||||
for (const auto &TU : TUs)
|
||||
if (auto TUDIE = TU->getUnitDIE())
|
||||
if (auto StmtOffset = toSectionOffset(TUDIE.find(DW_AT_stmt_list)))
|
||||
LineToUnit.insert(std::make_pair(*StmtOffset, &*TU));
|
||||
LineToUnit.insert(std::make_pair(*StmtOffset, &*U));
|
||||
return LineToUnit;
|
||||
}
|
||||
|
||||
DWARFDebugLine::SectionParser::SectionParser(DWARFDataExtractor &Data,
|
||||
const DWARFContext &C,
|
||||
cu_range CUs, tu_range TUs)
|
||||
DWARFDebugLine::SectionParser::SectionParser(
|
||||
DWARFDataExtractor &Data, const DWARFContext &C,
|
||||
DWARFUnitVector::iterator_range Units)
|
||||
: DebugLineData(Data), Context(C) {
|
||||
LineToUnit = buildLineToUnitMap(CUs, TUs);
|
||||
LineToUnit = buildLineToUnitMap(Units);
|
||||
if (!DebugLineData.isValidOffset(Offset))
|
||||
Done = true;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ struct CommonFixture {
|
||||
|
||||
generate();
|
||||
|
||||
return DWARFDebugLine::SectionParser(LineData, *Context, CUs, TUs);
|
||||
return DWARFDebugLine::SectionParser(LineData, *Context, Units);
|
||||
}
|
||||
|
||||
void recordRecoverable(Error Err) {
|
||||
@ -114,8 +114,7 @@ struct CommonFixture {
|
||||
Error Unrecoverable;
|
||||
std::function<void(Error)> RecordUnrecoverable;
|
||||
|
||||
SmallVector<std::unique_ptr<DWARFUnit>, 2> CUs;
|
||||
SmallVector<std::unique_ptr<DWARFUnit>, 2> TUs;
|
||||
SmallVector<std::unique_ptr<DWARFUnit>, 2> Units;
|
||||
};
|
||||
|
||||
// Fixtures must derive from "Test", but parameterised fixtures from
|
||||
@ -1087,7 +1086,7 @@ TEST_F(DebugLineBasicFixture, ParserAlwaysDoneForEmptySection) {
|
||||
return;
|
||||
|
||||
generate();
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, Units);
|
||||
|
||||
EXPECT_TRUE(Parser.done());
|
||||
}
|
||||
@ -1101,7 +1100,7 @@ TEST_F(DebugLineBasicFixture, ParserMarkedAsDoneForBadLengthWhenParsing) {
|
||||
Gen->addLineTable();
|
||||
generate();
|
||||
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, Units);
|
||||
Parser.parseNext(RecordRecoverable, RecordUnrecoverable);
|
||||
|
||||
EXPECT_EQ(Parser.getOffset(), 0u);
|
||||
@ -1124,7 +1123,7 @@ TEST_F(DebugLineBasicFixture, ParserMarkedAsDoneForBadLengthWhenSkipping) {
|
||||
Gen->addLineTable();
|
||||
generate();
|
||||
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, Units);
|
||||
Parser.skip(RecordRecoverable, RecordUnrecoverable);
|
||||
|
||||
EXPECT_EQ(Parser.getOffset(), 0u);
|
||||
@ -1148,7 +1147,7 @@ TEST_F(DebugLineBasicFixture, ParserReportsFirstErrorInEachTableWhenParsing) {
|
||||
LT2.setCustomPrologue({{2, LineTable::Long}, {1, LineTable::Half}});
|
||||
generate();
|
||||
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, Units);
|
||||
Parser.parseNext(RecordRecoverable, RecordUnrecoverable);
|
||||
ASSERT_FALSE(Parser.done());
|
||||
Parser.parseNext(RecordRecoverable, RecordUnrecoverable);
|
||||
@ -1177,7 +1176,7 @@ TEST_F(DebugLineBasicFixture, ParserReportsNonPrologueProblemsWhenParsing) {
|
||||
LT2.addByte(0xbb);
|
||||
generate();
|
||||
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, Units);
|
||||
Parser.parseNext(RecordRecoverable, RecordUnrecoverable);
|
||||
EXPECT_FALSE(Unrecoverable);
|
||||
ASSERT_FALSE(Parser.done());
|
||||
@ -1207,7 +1206,7 @@ TEST_F(DebugLineBasicFixture,
|
||||
LT2.setCustomPrologue({{2, LineTable::Long}, {1, LineTable::Half}});
|
||||
generate();
|
||||
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, Units);
|
||||
Parser.skip(RecordRecoverable, RecordUnrecoverable);
|
||||
ASSERT_FALSE(Parser.done());
|
||||
Parser.skip(RecordRecoverable, RecordUnrecoverable);
|
||||
@ -1231,7 +1230,7 @@ TEST_F(DebugLineBasicFixture, ParserIgnoresNonPrologueErrorsWhenSkipping) {
|
||||
LT.addExtendedOpcode(42, DW_LNE_end_sequence, {});
|
||||
generate();
|
||||
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, Units);
|
||||
Parser.skip(RecordRecoverable, RecordUnrecoverable);
|
||||
|
||||
EXPECT_TRUE(Parser.done());
|
||||
@ -1290,7 +1289,7 @@ TEST_F(DebugLineBasicFixture, VerboseOutput) {
|
||||
|
||||
generate();
|
||||
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, Units);
|
||||
std::string Output;
|
||||
raw_string_ostream OS(Output);
|
||||
Parser.parseNext(RecordRecoverable, RecordUnrecoverable, &OS,
|
||||
@ -1527,7 +1526,7 @@ struct TruncatedOpcodeFixtureBase : public CommonFixture {
|
||||
|
||||
void runTest(uint8_t OpcodeValue) {
|
||||
generate();
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, CUs, TUs);
|
||||
DWARFDebugLine::SectionParser Parser(LineData, *Context, Units);
|
||||
std::string Output;
|
||||
raw_string_ostream OS(Output);
|
||||
Parser.parseNext(RecordRecoverable, RecordUnrecoverable, &OS,
|
||||
|
Loading…
Reference in New Issue
Block a user