summaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/thread/step_out_line0/TestThreadStepOutLine0.py
blob: 2707ca852f6626a7c3f0ffb0ece6a0bf071f2ffd (plain)
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
"""
Test stepping out of a function when the return location is an unsuitable
stopping point.
"""


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


class ThreadStepOutLine0TestCase(TestBase):
    def test(self):
        self.build()
        target, process, thread, _ = lldbutil.run_to_source_breakpoint(
            self, "// Set breakpoint here", lldb.SBFileSpec("main.c")
        )
        correct_stepped_out_line = line_number("main.c", "// Should stop here")
        return_statement_line = line_number("main.c", "// Ran too far")
        safety_bp = target.BreakpointCreateByLocation(
            lldb.SBFileSpec("main.c"), return_statement_line
        )
        self.assertTrue(safety_bp.IsValid())

        error = lldb.SBError()
        thread.StepOut(error)
        self.assertTrue(error.Success())

        frame = thread.GetSelectedFrame()
        self.assertEqual(
            frame.line_entry.GetLine(),
            correct_stepped_out_line,
            "Step-out lost control of execution, ran too far",
        )