aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
diff options
context:
space:
mode:
authorHyoun Kyu Cho <netforce@google.com>2022-05-24 03:04:40 +0000
committerDavid Blaikie <dblaikie@gmail.com>2022-05-24 03:23:24 +0000
commit6c12ae8163c77c508aa846958360aa96d1c2c00d (patch)
tree25a4d4f10ae7b15d94e3b38cef5eeaad18cde9e3 /llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
parentca81abcfd752e65c533825a5fadac19ce5a33578 (diff)
downloadllvm-6c12ae8163c77c508aa846958360aa96d1c2c00d.zip
llvm-6c12ae8163c77c508aa846958360aa96d1c2c00d.tar.gz
llvm-6c12ae8163c77c508aa846958360aa96d1c2c00d.tar.bz2
Exposes interface to free up caching data structure in DWARFDebugLine and DWARFUnit for memory management
This is minimum changes extracted from https://reviews.llvm.org/D78950. The old patch tried to add LRU eviction of caching data structure. Due to multiple layers of interfaces that users could be using, it was not clear where to put the functionality. While we work out on where to put that functionality, it'll be great to add this minimum interface change so that the user could implement their own memory management. More specifically: * Add a clearLineTable method for DWARFDebugLine which erases the given offset from the LineTableMap. * DWARFDebugContext adds the clearLineTableForUnit method that leverages clearLineTable to remove the object corresponding to a given compile unit, for memory management purposes. When it is referred to again, the line table object will be repopulated. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D90006
Diffstat (limited to 'llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp')
-rw-r--r--llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
index 731aa4f..9c5e1c1 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
@@ -331,6 +331,82 @@ TEST_P(DebugLineParameterisedFixture, GetOrParseLineTableValidTable) {
}
#ifdef _AIX
+TEST_P(DebugLineParameterisedFixture, DISABLED_ClearLineValidTable) {
+#else
+TEST_P(DebugLineParameterisedFixture, ClearLineValidTable) {
+#endif
+ if (!setupGenerator(Version))
+ GTEST_SKIP();
+
+ SCOPED_TRACE("Checking Version " + std::to_string(Version) + ", Format " +
+ (Format == DWARF64 ? "DWARF64" : "DWARF32"));
+
+ LineTable &LT = Gen->addLineTable(Format);
+ LT.addExtendedOpcode(9, DW_LNE_set_address, {{0xadd4e55, LineTable::Quad}});
+ LT.addStandardOpcode(DW_LNS_copy, {});
+ LT.addByte(0xaa);
+ LT.addExtendedOpcode(1, DW_LNE_end_sequence, {});
+
+ LineTable &LT2 = Gen->addLineTable(Format);
+ LT2.addExtendedOpcode(9, DW_LNE_set_address, {{0x11223344, LineTable::Quad}});
+ LT2.addStandardOpcode(DW_LNS_copy, {});
+ LT2.addByte(0xbb);
+ LT2.addExtendedOpcode(1, DW_LNE_end_sequence, {});
+ LT2.addExtendedOpcode(9, DW_LNE_set_address, {{0x55667788, LineTable::Quad}});
+ LT2.addStandardOpcode(DW_LNS_copy, {});
+ LT2.addByte(0xcc);
+ LT2.addExtendedOpcode(1, DW_LNE_end_sequence, {});
+
+ generate();
+
+ // Check that we have what we expect before calling clearLineTable().
+ auto ExpectedLineTable = Line.getOrParseLineTable(LineData, 0, *Context,
+ nullptr, RecordRecoverable);
+ ASSERT_TRUE((bool)ExpectedLineTable);
+ EXPECT_FALSE(Recoverable);
+ const DWARFDebugLine::LineTable *Expected = *ExpectedLineTable;
+ checkDefaultPrologue(Version, Format, Expected->Prologue, 16);
+ EXPECT_EQ(Expected->Sequences.size(), 1u);
+
+ uint64_t SecondOffset =
+ Expected->Prologue.sizeofTotalLength() + Expected->Prologue.TotalLength;
+ Recoverable = Error::success();
+ auto ExpectedLineTable2 = Line.getOrParseLineTable(
+ LineData, SecondOffset, *Context, nullptr, RecordRecoverable);
+ ASSERT_TRUE((bool)ExpectedLineTable2);
+ EXPECT_FALSE(Recoverable);
+ const DWARFDebugLine::LineTable *Expected2 = *ExpectedLineTable2;
+ checkDefaultPrologue(Version, Format, Expected2->Prologue, 32);
+ EXPECT_EQ(Expected2->Sequences.size(), 2u);
+
+ // Check that we no longer get the line tables after clearLineTable().
+ Line.clearLineTable(0);
+ Line.clearLineTable(SecondOffset);
+ EXPECT_EQ(Line.getLineTable(0), nullptr);
+ EXPECT_EQ(Line.getLineTable(SecondOffset), nullptr);
+
+ // Check that if the same offset is requested, the contents match what we
+ // had before.
+ Recoverable = Error::success();
+ auto ExpectedLineTable3 = Line.getOrParseLineTable(
+ LineData, 0, *Context, nullptr, RecordRecoverable);
+ ASSERT_TRUE((bool)ExpectedLineTable3);
+ EXPECT_FALSE(Recoverable);
+ const DWARFDebugLine::LineTable *Expected3 = *ExpectedLineTable3;
+ checkDefaultPrologue(Version, Format, Expected3->Prologue, 16);
+ EXPECT_EQ(Expected3->Sequences.size(), 1u);
+
+ Recoverable = Error::success();
+ auto ExpectedLineTable4 = Line.getOrParseLineTable(
+ LineData, SecondOffset, *Context, nullptr, RecordRecoverable);
+ ASSERT_TRUE((bool)ExpectedLineTable4);
+ EXPECT_FALSE(Recoverable);
+ const DWARFDebugLine::LineTable *Expected4 = *ExpectedLineTable4;
+ checkDefaultPrologue(Version, Format, Expected4->Prologue, 32);
+ EXPECT_EQ(Expected4->Sequences.size(), 2u);
+}
+
+#ifdef _AIX
TEST_F(DebugLineBasicFixture, DISABLED_ErrorForReservedLength) {
#else
TEST_F(DebugLineBasicFixture, ErrorForReservedLength) {