Skip to content

Commit 9861c7d

Browse files
committed
Enforce that a "PreferredLineEntry" can't change the location address.
1 parent e3c26b0 commit 9861c7d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lldb/include/lldb/Breakpoint/BreakpointLocation.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,15 @@ class BreakpointLocation
288288
/// It is up to the caller to verify that this is a valid entry to show.
289289
/// The current use of this is to distinguish among line entries from a
290290
/// virtual inlined call stack that all share the same address.
291-
void SetPreferredLineEntry(const LineEntry &line_entry) {
292-
m_preferred_line_entry = line_entry;
291+
/// The line entry must have the same start address as the address for this
292+
/// location.
293+
bool SetPreferredLineEntry(const LineEntry &line_entry) {
294+
if (m_address == line_entry.range.GetBaseAddress()) {
295+
m_preferred_line_entry = line_entry;
296+
return true;
297+
}
298+
assert(0 && "Tried to set a preferred line entry with a different address");
299+
return false;
293300
}
294301

295302
const std::optional<LineEntry> GetPreferredLineEntry() {

lldb/source/Breakpoint/BreakpointResolver.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,11 @@ void BreakpointResolver::AddLocation(SearchFilter &filter,
350350
// FIXME: The function name will also be wrong here. Do we need to record
351351
// that as well, or can we figure that out again when we report this
352352
// breakpoint location.
353-
bp_loc_sp->SetPreferredLineEntry(sc.line_entry);
353+
if (!bp_loc_sp->SetPreferredLineEntry(sc.line_entry)) {
354+
LLDB_LOG(log, "Tried to add a preferred line entry that didn't have the "
355+
"same address as this location's address.");
356+
357+
}
354358
}
355359
if (log && bp_loc_sp && !GetBreakpoint()->IsInternal()) {
356360
StreamString s;

0 commit comments

Comments
 (0)