xref: /llvm-project/lldb/test/API/commands/expression/entry-bp/TestExprEntryBP.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Tests expressions evaluation when the breakpoint on module's entry is set.
3"""
4
5import lldb
6import lldbsuite.test.lldbutil as lldbutil
7from lldbsuite.test.lldbtest import *
8
9
10class ExprEntryBPTestCase(TestBase):
11    NO_DEBUG_INFO_TESTCASE = True
12
13    def test_expr_entry_bp(self):
14        """Tests expressions evaluation when the breakpoint on module's entry is set."""
15        self.build()
16        self.main_source_file = lldb.SBFileSpec("main.c")
17
18        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
19            self, "Set a breakpoint here", self.main_source_file
20        )
21
22        self.assertEqual(1, bkpt.GetNumLocations())
23        entry = (
24            bkpt.GetLocationAtIndex(0)
25            .GetAddress()
26            .GetModule()
27            .GetObjectFileEntryPointAddress()
28        )
29        self.assertTrue(entry.IsValid(), "Can't get a module entry point")
30
31        entry_bp = target.BreakpointCreateBySBAddress(entry)
32        self.assertTrue(
33            entry_bp.IsValid(), "Can't set a breakpoint on the module entry point"
34        )
35
36        self.expect_expr("sum(7, 1)", result_type="int", result_value="8")
37