File: TestStepTarget.py

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (115 lines) | stat: -rw-r--r-- 4,293 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"""Test the 'step target' feature."""


import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class TestStepTarget(TestBase):
    def setUp(self):
        # Call super's setUp().
        TestBase.setUp(self)
        # Find the line numbers that we will step to in main:
        self.main_source = "main.c"
        self.end_line = line_number(self.main_source, "All done")

    @add_test_categories(["pyapi"])
    def get_to_start(self):
        self.build()
        exe = self.getBuildArtifact("a.out")

        target = self.dbg.CreateTarget(exe)
        self.assertTrue(target, VALID_TARGET)

        self.main_source_spec = lldb.SBFileSpec(self.main_source)

        break_in_main = target.BreakpointCreateBySourceRegex(
            "Break here to try targetted stepping", self.main_source_spec
        )
        self.assertTrue(break_in_main, VALID_BREAKPOINT)
        self.assertGreater(break_in_main.GetNumLocations(), 0, "Has locations.")

        # Now launch the process, and do not stop at entry point.
        process = target.LaunchSimple(None, None, self.get_process_working_directory())

        self.assertTrue(process, PROCESS_IS_VALID)

        # The stop reason of the thread should be breakpoint.
        threads = lldbutil.get_threads_stopped_at_breakpoint(process, break_in_main)

        if len(threads) != 1:
            self.fail("Failed to stop at first breakpoint in main.")

        thread = threads[0]
        return thread

    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
    def test_with_end_line(self):
        """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""

        thread = self.get_to_start()

        error = lldb.SBError()
        thread.StepInto("lotsOfArgs", self.end_line, error)
        frame = thread.frames[0]

        self.assertEqual(frame.name, "lotsOfArgs", "Stepped to lotsOfArgs.")

    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
    def test_with_end_line_bad_name(self):
        """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""

        thread = self.get_to_start()

        error = lldb.SBError()
        thread.StepInto("lotsOfArgssss", self.end_line, error)
        frame = thread.frames[0]
        self.assertEqual(
            frame.line_entry.line, self.end_line, "Stepped to the block end."
        )

    def test_with_end_line_deeper(self):
        """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""

        thread = self.get_to_start()

        error = lldb.SBError()
        thread.StepInto("modifyInt", self.end_line, error)
        frame = thread.frames[0]
        self.assertEqual(frame.name, "modifyInt", "Stepped to modifyInt.")

    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
    def test_with_command_and_block(self):
        """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""

        thread = self.get_to_start()

        result = lldb.SBCommandReturnObject()
        self.dbg.GetCommandInterpreter().HandleCommand(
            'thread step-in -t "lotsOfArgs" -e block', result
        )
        self.assertTrue(result.Succeeded(), "thread step-in command succeeded.")

        frame = thread.frames[0]
        self.assertEqual(frame.name, "lotsOfArgs", "Stepped to lotsOfArgs.")

    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
    def test_with_command_and_block_and_bad_name(self):
        """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""

        thread = self.get_to_start()

        result = lldb.SBCommandReturnObject()
        self.dbg.GetCommandInterpreter().HandleCommand(
            'thread step-in -t "lotsOfArgsssss" -e block', result
        )
        self.assertTrue(result.Succeeded(), "thread step-in command succeeded.")

        frame = thread.frames[0]

        self.assertEqual(frame.name, "main", "Stepped back out to main.")
        # end_line is set to the line after the containing block.  Check that
        # we got there:
        self.assertEqual(frame.line_entry.line, self.end_line, "Got out of the block")