1"""
2Test that we can hit breakpoints in global constructors
3"""
4
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12
13class TestBreakpointInGlobalConstructors(TestBase):
14    NO_DEBUG_INFO_TESTCASE = True
15
16    def test(self):
17        self.build()
18        self.line_foo = line_number('foo.cpp', '// !BR_foo')
19        self.line_main = line_number('main.cpp', '// !BR_main')
20
21        target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
22        self.assertTrue(target, VALID_TARGET)
23
24        env= self.registerSharedLibrariesWithTarget(target, ["foo"])
25
26        bp_main = lldbutil.run_break_set_by_file_and_line(
27            self, 'main.cpp', self.line_main)
28
29        bp_foo = lldbutil.run_break_set_by_file_and_line(
30            self, 'foo.cpp', self.line_foo, num_expected_locations=-2)
31
32        process = target.LaunchSimple(
33            None, env, self.get_process_working_directory())
34
35        self.assertIsNotNone(
36            lldbutil.get_one_thread_stopped_at_breakpoint_id(
37                self.process(), bp_foo))
38
39        self.runCmd("continue")
40
41        self.assertIsNotNone(
42            lldbutil.get_one_thread_stopped_at_breakpoint_id(
43                self.process(), bp_main))
44