1"""
2Tests expressions that distinguish between static and non-static methods.
3"""
4
5import lldb
6from lldbtest import *
7import lldbutil
8
9class CPPStaticMethodsTestCase(TestBase):
10
11    mydir = os.path.join("lang", "cpp", "static_methods")
12
13    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
14    @dsym_test
15    def test_with_dsym_and_run_command(self):
16        """Test that static methods are properly distinguished from regular methods"""
17        self.buildDsym()
18        self.static_method_commands()
19
20    @expectedFailureFreeBSD('llvm.org/pr16697') # Expression fails with 'there is no JIT compiled function'
21    @dwarf_test
22    def test_with_dwarf_and_run_command(self):
23        """Test that static methods are properly distinguished from regular methods"""
24        self.buildDwarf()
25        self.static_method_commands()
26
27    def setUp(self):
28        TestBase.setUp(self)
29        self.line = line_number('main.cpp', '// Break at this line')
30
31    def static_method_commands(self):
32        """Test that static methods are properly distinguished from regular methods"""
33        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
34
35        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
36
37        self.runCmd("process launch", RUN_SUCCEEDED)
38
39        # The stop reason of the thread should be breakpoint.
40        self.expect("thread list",
41                    STOPPED_DUE_TO_BREAKPOINT,
42                    substrs = ['stopped', 'stop reason = breakpoint'])
43
44        self.expect("expression -- A::getStaticValue()",
45                    startstr = "(int) $0 = 5")
46
47        self.expect("expression -- my_a.getMemberValue()",
48                    startstr = "(int) $1 = 3")
49
50if __name__ == '__main__':
51    import atexit
52    lldb.SBDebugger.Initialize()
53    atexit.register(lambda: lldb.SBDebugger.Terminate())
54    unittest2.main()
55