blob: 13ebf9003f2a2ad0f02ac11f4167b45becf55236 [file] [log] [blame]
Sean Callanan72e49402011-08-05 23:43:37 +00001"""
2Tests that C++ member and static variables are available where they should be.
3"""
4
5from lldbtest import *
6
7class CPPThisTestCase(TestBase):
8
9 mydir = os.path.join("lang", "cpp", "this")
10
11 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
Johnny Chen49996272011-08-23 01:00:14 +000012 #rdar://problem/9962849
13 @expectedFailureClang
Sean Callanan72e49402011-08-05 23:43:37 +000014 def test_with_dsym_and_run_command(self):
15 """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods"""
16 self.buildDsym()
17 self.static_method_commands()
18
Johnny Chen49996272011-08-23 01:00:14 +000019 #rdar://problem/9962849
20 @expectedFailureClang
Sean Callanan72e49402011-08-05 23:43:37 +000021 def test_with_dwarf_and_run_command(self):
22 """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods"""
23 self.buildDwarf()
24 self.static_method_commands()
25
26 def setUp(self):
27 TestBase.setUp(self)
28
29 def set_breakpoint(self, line):
30 self.expect("breakpoint set -f main.cpp -l %d" % line,
31 BREAKPOINT_CREATED,
32 startstr = "Breakpoint created")
33
34 def static_method_commands(self):
35 """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods"""
36 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
37
38 self.set_breakpoint(line_number('main.cpp', '// breakpoint 1'))
39 self.set_breakpoint(line_number('main.cpp', '// breakpoint 2'))
40 self.set_breakpoint(line_number('main.cpp', '// breakpoint 3'))
41 self.set_breakpoint(line_number('main.cpp', '// breakpoint 4'))
42
43 self.runCmd("process launch", RUN_SUCCEEDED)
44
45 self.expect("expression -- m_a = 2",
46 startstr = "(int) $0 = 2")
47
48 self.runCmd("process continue")
49
50 # This would be disallowed if we enforced const. But we don't.
51 self.expect("expression -- m_a = 2",
52 startstr = "(int) $1 = 2")
53
54 self.expect("expression -- m_a",
55 startstr = "(int) $2 = 2")
56
57 self.runCmd("process continue")
58
59 self.expect("expression -- s_a",
60 startstr = "(int) $3 = 5")
61
62 self.runCmd("process continue")
63
64 self.expect("expression -- m_a",
65 startstr = "(int) $4 = 2")
66
67if __name__ == '__main__':
68 import atexit
69 lldb.SBDebugger.Initialize()
70 atexit.register(lambda: lldb.SBDebugger.Terminate())
71 unittest2.main()