1 """Test the 'step target' feature."""
5 from lldbsuite
.test
.decorators
import *
6 from lldbsuite
.test
.lldbtest
import *
7 from lldbsuite
.test
import lldbutil
10 class TestStepTarget(TestBase
):
12 # Call super's setUp().
14 # Find the line numbers that we will step to in main:
15 self
.main_source
= "main.c"
16 self
.end_line
= line_number(self
.main_source
, "All done")
18 @add_test_categories(["pyapi"])
19 def get_to_start(self
):
21 exe
= self
.getBuildArtifact("a.out")
23 target
= self
.dbg
.CreateTarget(exe
)
24 self
.assertTrue(target
, VALID_TARGET
)
26 self
.main_source_spec
= lldb
.SBFileSpec(self
.main_source
)
28 break_in_main
= target
.BreakpointCreateBySourceRegex(
29 "Break here to try targetted stepping", self
.main_source_spec
31 self
.assertTrue(break_in_main
, VALID_BREAKPOINT
)
32 self
.assertGreater(break_in_main
.GetNumLocations(), 0, "Has locations.")
34 # Now launch the process, and do not stop at entry point.
35 process
= target
.LaunchSimple(None, None, self
.get_process_working_directory())
37 self
.assertTrue(process
, PROCESS_IS_VALID
)
39 # The stop reason of the thread should be breakpoint.
40 threads
= lldbutil
.get_threads_stopped_at_breakpoint(process
, break_in_main
)
43 self
.fail("Failed to stop at first breakpoint in main.")
48 @expectedFailureAll(oslist
=["windows"], bugnumber
="llvm.org/pr32343")
49 def test_with_end_line(self
):
50 """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
52 thread
= self
.get_to_start()
54 error
= lldb
.SBError()
55 thread
.StepInto("lotsOfArgs", self
.end_line
, error
)
56 frame
= thread
.frames
[0]
58 self
.assertEqual(frame
.name
, "lotsOfArgs", "Stepped to lotsOfArgs.")
60 @expectedFailureAll(oslist
=["windows"], bugnumber
="llvm.org/pr32343")
61 def test_with_end_line_bad_name(self
):
62 """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
64 thread
= self
.get_to_start()
66 error
= lldb
.SBError()
67 thread
.StepInto("lotsOfArgssss", self
.end_line
, error
)
68 frame
= thread
.frames
[0]
70 frame
.line_entry
.line
, self
.end_line
, "Stepped to the block end."
73 def test_with_end_line_deeper(self
):
74 """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
76 thread
= self
.get_to_start()
78 error
= lldb
.SBError()
79 thread
.StepInto("modifyInt", self
.end_line
, error
)
80 frame
= thread
.frames
[0]
81 self
.assertEqual(frame
.name
, "modifyInt", "Stepped to modifyInt.")
83 @expectedFailureAll(oslist
=["windows"], bugnumber
="llvm.org/pr32343")
84 def test_with_command_and_block(self
):
85 """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
87 thread
= self
.get_to_start()
89 result
= lldb
.SBCommandReturnObject()
90 self
.dbg
.GetCommandInterpreter().HandleCommand(
91 'thread step-in -t "lotsOfArgs" -e block', result
93 self
.assertTrue(result
.Succeeded(), "thread step-in command succeeded.")
95 frame
= thread
.frames
[0]
96 self
.assertEqual(frame
.name
, "lotsOfArgs", "Stepped to lotsOfArgs.")
98 @expectedFailureAll(oslist
=["windows"], bugnumber
="llvm.org/pr32343")
99 def test_with_command_and_block_and_bad_name(self
):
100 """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
102 thread
= self
.get_to_start()
104 result
= lldb
.SBCommandReturnObject()
105 self
.dbg
.GetCommandInterpreter().HandleCommand(
106 'thread step-in -t "lotsOfArgsssss" -e block', result
108 self
.assertTrue(result
.Succeeded(), "thread step-in command succeeded.")
110 frame
= thread
.frames
[0]
112 self
.assertEqual(frame
.name
, "main", "Stepped back out to main.")
113 # end_line is set to the line after the containing block. Check that
115 self
.assertEqual(frame
.line_entry
.line
, self
.end_line
, "Got out of the block")