"""
Test thread stepping features in combination with frame select.
"""
import lldb
from lldbsuite.test.lldbtest import *
import lldbsuite.test.lldbutil as lldbutil
class ThreadSteppingTestCase(TestBase):
def setUp(self):
TestBase.setUp(self)
self.line1 = line_number(
"main.c", '// Find the line number of function "c" here.'
)
self.line2 = line_number(
"main.c", '// frame select 2, thread step-out while stopped at "c(1)"'
)
self.line3 = line_number("main.c", '// thread step-out while stopped at "c(2)"')
self.line4 = line_number(
"main.c", '// frame select 1, thread step-out while stopped at "c(3)"'
)
def test_step_out_with_run_command(self):
"""Exercise thread step-out and frame select followed by thread step-out."""
self.build()
exe = self.getBuildArtifact("a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
lldbutil.run_break_set_by_file_and_line(
self, "main.c", self.line1, num_expected_locations=1, loc_exact=True
)
self.runCmd("run", RUN_SUCCEEDED)
self.expect("process status", PROCESS_STOPPED, patterns=["Process .* stopped"])
self.expect(
"thread backtrace",
STOPPED_DUE_TO_BREAKPOINT,
substrs=["stop reason = breakpoint"],
patterns=[
"frame #0.*main.c:%d" % self.line1,
"frame #3.*main.c:%d" % self.line2,
],
)
self.runCmd("frame select 2")
self.runCmd("thread step-out")
self.expect(
"thread backtrace",
STEP_OUT_SUCCEEDED,
substrs=["stop reason = step out"],
patterns=["frame #0.*main.c:%d" % self.line2],
)
self.runCmd("process continue")
self.expect("process status", PROCESS_STOPPED, patterns=["Process .* stopped"])
self.runCmd("thread step-out")
self.expect(
"thread backtrace",
STEP_OUT_SUCCEEDED,
substrs=["stop reason = step out"],
patterns=["frame #0.*main.c:%d" % self.line3],
)
self.runCmd("process continue")
self.expect("process status", PROCESS_STOPPED, patterns=["Process .* stopped"])
self.runCmd("frame select 1")
self.runCmd("thread step-out")
self.expect(
"thread backtrace",
STEP_OUT_SUCCEEDED,
substrs=["stop reason = step out"],
patterns=["frame #0.*main.c:%d" % self.line4],
)