Skip to content

Commit 3243e3d

Browse files
authored
Fix stepping away from the bottom-most frame of a virtual inlined call stack. (#114337)
The computation of 'Thread::IsVirtualStep" was wrong - it called being at the bottom of a virtual call stack a "virtual step" but that is actually when you've gotten to concrete code and need to step for real. I also added a test for this.
1 parent e99c490 commit 3243e3d

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

lldb/source/Target/ThreadPlanStepInRange.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ bool ThreadPlanStepInRange::DoWillResume(lldb::StateType resume_state,
489489
bool ThreadPlanStepInRange::IsVirtualStep() {
490490
if (m_virtual_step == eLazyBoolCalculate) {
491491
Thread &thread = GetThread();
492-
if (thread.GetCurrentInlinedDepth() == UINT32_MAX)
492+
uint32_t cur_inline_depth = thread.GetCurrentInlinedDepth();
493+
if (cur_inline_depth == UINT32_MAX || cur_inline_depth == 0)
493494
m_virtual_step = eLazyBoolNo;
494495
else
495496
m_virtual_step = eLazyBoolYes;

lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ def step_in_template(self):
364364
step_sequence = [["// In max_value specialized", "into"]]
365365
self.run_step_sequence(step_sequence)
366366

367-
def run_to_call_site_and_step(self, source_regex, func_name, start_pos):
367+
def run_to_call_site_and_step(
368+
self, source_regex, func_name, start_pos, one_more_step_loc=None
369+
):
368370
main_spec = lldb.SBFileSpec("calling.cpp")
369371
# Set the breakpoint by file and line, not sourced regex because
370372
# we want to make sure we can set breakpoints on call sites:
@@ -408,6 +410,14 @@ def run_to_call_site_and_step(self, source_regex, func_name, start_pos):
408410
# stepping for this function...
409411
break
410412

413+
if one_more_step_loc:
414+
thread.StepInto()
415+
frame_0 = thread.frame[0]
416+
self.assertEqual(
417+
frame_0.line_entry.line,
418+
line_number(self.main_source, one_more_step_loc),
419+
"Was able to step one more time",
420+
)
411421
process.Kill()
412422
target.Clear()
413423

@@ -420,3 +430,9 @@ def virtual_inline_stepping(self):
420430
self.run_to_call_site_and_step(
421431
"In caller_trivial_inline_2", "caller_trivial_inline_2", 3
422432
)
433+
self.run_to_call_site_and_step(
434+
"In caller_trivial_inline_3",
435+
"caller_trivial_inline_3",
436+
4,
437+
"After caller_trivial_inline_3",
438+
)

lldb/test/API/functionalities/inline-stepping/calling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void caller_trivial_inline_1() {
9595

9696
void caller_trivial_inline_2() {
9797
caller_trivial_inline_3(); // In caller_trivial_inline_2.
98-
inline_value += 1;
98+
inline_value += 1; // After caller_trivial_inline_3
9999
}
100100

101101
void caller_trivial_inline_3() {

0 commit comments

Comments
 (0)