Skip to content

Commit 88a816f

Browse files
committed
Dont pass DIE, pass offset
1 parent cc8df97 commit 88a816f

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,14 @@ class DWARFDebugLine {
254254
/// \param Address - The starting address of the range.
255255
/// \param Size - The size of the address range.
256256
/// \param Result - The vector to fill with row indices.
257-
/// \param Die - if provided, the function will check for a
258-
/// DW_AT_LLVM_stmt_sequence attribute. If present, only rows from the
259-
/// sequence starting at the matching offset will be added to the result.
257+
/// \param StmtSequenceOffset - if provided, only rows from the sequence
258+
/// starting at the matching offset will be added to the result.
260259
///
261260
/// Returns true if any rows were found.
262-
bool lookupAddressRange(object::SectionedAddress Address, uint64_t Size,
263-
std::vector<uint32_t> &Result,
264-
const DWARFDie *Die = nullptr) const;
261+
bool lookupAddressRange(
262+
object::SectionedAddress Address, uint64_t Size,
263+
std::vector<uint32_t> &Result,
264+
std::optional<uint64_t> StmtSequenceOffset = std::nullopt) const;
265265

266266
bool hasFileAtIndex(uint64_t FileIndex) const {
267267
return Prologue.hasFileAtIndex(FileIndex);

llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,15 +1374,8 @@ DWARFDebugLine::LineTable::lookupAddressImpl(object::SectionedAddress Address,
13741374

13751375
bool DWARFDebugLine::LineTable::lookupAddressRange(
13761376
object::SectionedAddress Address, uint64_t Size,
1377-
std::vector<uint32_t> &Result, const DWARFDie *Die) const {
1378-
1379-
// If DIE is provided, check for DW_AT_LLVM_stmt_sequence
1380-
std::optional<uint64_t> StmtSequenceOffset;
1381-
if (Die) {
1382-
if (auto StmtSeqAttr = Die->find(dwarf::DW_AT_LLVM_stmt_sequence)) {
1383-
StmtSequenceOffset = toSectionOffset(StmtSeqAttr);
1384-
}
1385-
}
1377+
std::vector<uint32_t> &Result,
1378+
std::optional<uint64_t> StmtSequenceOffset) const {
13861379

13871380
// Search for relocatable addresses
13881381
if (lookupAddressRangeImpl(Address, Size, Result, StmtSequenceOffset))

llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,27 +2140,31 @@ TEST_F(DebugLineBasicFixture, LookupAddressRangeWithStmtSequenceOffset) {
21402140
std::vector<uint32_t> Rows;
21412141
bool Found;
21422142

2143-
// Look up using Sub3Die, which has an invalid DW_AT_LLVM_stmt_sequence
2143+
// Look up using Sub3Die's invalid stmt_sequence offset
2144+
auto StmtSeqAttr3 = Sub3Die.find(dwarf::DW_AT_LLVM_stmt_sequence);
2145+
ASSERT_TRUE(StmtSeqAttr3);
21442146
Found = Table->lookupAddressRange(
21452147
{0x1000, object::SectionedAddress::UndefSection}, /*Size=*/1, Rows,
2146-
&Sub3Die);
2148+
toSectionOffset(StmtSeqAttr3));
21472149
EXPECT_FALSE(Found);
21482150

2149-
// Look up using Sub1Die, which has a valid DW_AT_LLVM_stmt_sequence and
2150-
// should return row 0
2151+
// Look up using Sub1Die's valid stmt_sequence offset
2152+
auto StmtSeqAttr1 = Sub1Die.find(dwarf::DW_AT_LLVM_stmt_sequence);
2153+
ASSERT_TRUE(StmtSeqAttr1);
21512154
Found = Table->lookupAddressRange(
21522155
{0x1000, object::SectionedAddress::UndefSection}, /*Size=*/1, Rows,
2153-
&Sub1Die);
2156+
toSectionOffset(StmtSeqAttr1));
21542157
EXPECT_TRUE(Found);
21552158
ASSERT_EQ(Rows.size(), 1u);
21562159
EXPECT_EQ(Rows[0], 0U);
21572160

2158-
// Look up using Sub2Die, which has a valid DW_AT_LLVM_stmt_sequence and
2159-
// should return row 3
2161+
// Look up using Sub2Die's valid stmt_sequence offset
21602162
Rows.clear();
2163+
auto StmtSeqAttr2 = Sub2Die.find(dwarf::DW_AT_LLVM_stmt_sequence);
2164+
ASSERT_TRUE(StmtSeqAttr2);
21612165
Found = Table->lookupAddressRange(
21622166
{0x1000, object::SectionedAddress::UndefSection}, /*Size=*/1, Rows,
2163-
&Sub2Die);
2167+
toSectionOffset(StmtSeqAttr2));
21642168
EXPECT_TRUE(Found);
21652169
ASSERT_EQ(Rows.size(), 1u);
21662170
EXPECT_EQ(Rows[0], 3u);

0 commit comments

Comments
 (0)