[mlir][acc] Introduce MappableType interface (#122146)
[llvm-project.git] / lldb / test / API / lang / c / stepping / TestThreadStepping.py
blobf577cb62e715efe699d4ba82db69c70eada6daf1
1 """
2 Test thread stepping features in combination with frame select.
3 """
6 import lldb
7 from lldbsuite.test.lldbtest import *
8 import lldbsuite.test.lldbutil as lldbutil
11 class ThreadSteppingTestCase(TestBase):
12 def setUp(self):
13 # Call super's setUp().
14 TestBase.setUp(self)
15 # Find the line number to of function 'c'.
16 self.line1 = line_number(
17 "main.c", '// Find the line number of function "c" here.'
19 self.line2 = line_number(
20 "main.c", '// frame select 2, thread step-out while stopped at "c(1)"'
22 self.line3 = line_number("main.c", '// thread step-out while stopped at "c(2)"')
23 self.line4 = line_number(
24 "main.c", '// frame select 1, thread step-out while stopped at "c(3)"'
27 def test_step_out_with_run_command(self):
28 """Exercise thread step-out and frame select followed by thread step-out."""
29 self.build()
30 exe = self.getBuildArtifact("a.out")
31 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
33 # Create a breakpoint inside function 'c'.
34 lldbutil.run_break_set_by_file_and_line(
35 self, "main.c", self.line1, num_expected_locations=1, loc_exact=True
38 # Now run the program.
39 self.runCmd("run", RUN_SUCCEEDED)
41 # The process should be stopped at this point.
42 self.expect("process status", PROCESS_STOPPED, patterns=["Process .* stopped"])
44 # The frame #0 should correspond to main.c:32, the executable statement
45 # in function name 'c'. And frame #3 should point to main.c:37.
46 self.expect(
47 "thread backtrace",
48 STOPPED_DUE_TO_BREAKPOINT,
49 substrs=["stop reason = breakpoint"],
50 patterns=[
51 "frame #0.*main.c:%d" % self.line1,
52 "frame #3.*main.c:%d" % self.line2,
56 # We want to move the pc to frame #3. This can be accomplished by
57 # 'frame select 2', followed by 'thread step-out'.
58 self.runCmd("frame select 2")
59 self.runCmd("thread step-out")
60 self.expect(
61 "thread backtrace",
62 STEP_OUT_SUCCEEDED,
63 substrs=["stop reason = step out"],
64 patterns=["frame #0.*main.c:%d" % self.line2],
67 # Let's move on to a single step-out case.
68 self.runCmd("process continue")
70 # The process should be stopped at this point.
71 self.expect("process status", PROCESS_STOPPED, patterns=["Process .* stopped"])
72 self.runCmd("thread step-out")
73 self.expect(
74 "thread backtrace",
75 STEP_OUT_SUCCEEDED,
76 substrs=["stop reason = step out"],
77 patterns=["frame #0.*main.c:%d" % self.line3],
80 # Do another frame selct, followed by thread step-out.
81 self.runCmd("process continue")
83 # The process should be stopped at this point.
84 self.expect("process status", PROCESS_STOPPED, patterns=["Process .* stopped"])
85 self.runCmd("frame select 1")
86 self.runCmd("thread step-out")
87 self.expect(
88 "thread backtrace",
89 STEP_OUT_SUCCEEDED,
90 substrs=["stop reason = step out"],
91 patterns=["frame #0.*main.c:%d" % self.line4],