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
9class ExprEntryBPTestCase(TestBase):
10
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(self, "Set a breakpoint here", self.main_source_file)
19
20        self.assertEqual(1, bkpt.GetNumLocations())
21        entry = bkpt.GetLocationAtIndex(0).GetAddress().GetModule().GetObjectFileEntryPointAddress()
22        self.assertTrue(entry.IsValid(), "Can't get a module entry point")
23
24        entry_bp = target.BreakpointCreateBySBAddress(entry)
25        self.assertTrue(entry_bp.IsValid(), "Can't set a breakpoint on the module entry point")
26
27        self.expect_expr("sum(7, 1)", result_type="int", result_value="8")
28