Skip to content

Commit d588fce

Browse files
committed
[lldb/Symbol] Relax LineEntry validity for PC-less frames
LineEntry::IsValid() no longer requires a valid address range, enabling line entries created using the SBAPI to be set in SBSymbolContext. Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 93ebe63 commit d588fce

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

lldb/source/API/SBLineEntry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ SBAddress SBLineEntry::GetStartAddress() const {
5050
LLDB_INSTRUMENT_VA(this);
5151

5252
SBAddress sb_address;
53-
if (m_opaque_up)
53+
if (m_opaque_up && m_opaque_up->range.IsValid())
5454
sb_address.SetAddress(m_opaque_up->range.GetBaseAddress());
5555

5656
return sb_address;
@@ -60,7 +60,7 @@ SBAddress SBLineEntry::GetEndAddress() const {
6060
LLDB_INSTRUMENT_VA(this);
6161

6262
SBAddress sb_address;
63-
if (m_opaque_up) {
63+
if (m_opaque_up && m_opaque_up->range.IsValid()) {
6464
sb_address.SetAddress(m_opaque_up->range.GetBaseAddress());
6565
sb_address.OffsetAddress(m_opaque_up->range.GetByteSize());
6666
}

lldb/source/Symbol/LineEntry.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ void LineEntry::Clear() {
3232
is_terminal_entry = 0;
3333
}
3434

35-
bool LineEntry::IsValid() const {
36-
return range.GetBaseAddress().IsValid() && line != LLDB_INVALID_LINE_NUMBER;
37-
}
35+
bool LineEntry::IsValid() const { return line != LLDB_INVALID_LINE_NUMBER; }
3836

3937
bool LineEntry::DumpStopContext(Stream *s, bool show_fullpaths) const {
4038
const FileSpec &file = file_sp->GetSpecOnly();

lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ def __init__(self, process, args):
7474
self.frames.append(DummyScriptedFrame(self, args, len(self.frames), "bar"))
7575
self.frames.append(DummyScriptedFrame(self, args, len(self.frames), "foo"))
7676

77+
cwd = os.path.dirname(os.path.abspath(__file__))
78+
79+
le = lldb.SBLineEntry()
80+
le.SetFileSpec(lldb.SBFileSpec(os.path.join(cwd, "baz.cpp"), True))
81+
le.SetLine(9)
82+
le.SetColumn(10)
83+
84+
sym_ctx = lldb.SBSymbolContext()
85+
sym_ctx.SetLineEntry(le)
86+
87+
self.frames.append(
88+
DummyScriptedFrame(self, args, len(self.frames), "baz", sym_ctx)
89+
)
90+
7791
def get_thread_id(self) -> int:
7892
return 0x19
7993

0 commit comments

Comments
 (0)