blob: 3efb84d102b3ec26cc029cfcb8b6b205ffff54bc [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")
12 def test_with_dsym_and_run_command(self):
13 """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods"""
14 self.buildDsym()
15 self.static_method_commands()
16
17 def test_with_dwarf_and_run_command(self):
18 """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods"""
19 self.buildDwarf()
20 self.static_method_commands()
21
22 def setUp(self):
23 TestBase.setUp(self)
24
25 def set_breakpoint(self, line):
26 self.expect("breakpoint set -f main.cpp -l %d" % line,
27 BREAKPOINT_CREATED,
28 startstr = "Breakpoint created")
29
30 def static_method_commands(self):
31 """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods"""
32 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
33
34 self.set_breakpoint(line_number('main.cpp', '// breakpoint 1'))
35 self.set_breakpoint(line_number('main.cpp', '// breakpoint 2'))
36 self.set_breakpoint(line_number('main.cpp', '// breakpoint 3'))
37 self.set_breakpoint(line_number('main.cpp', '// breakpoint 4'))
38
39 self.runCmd("process launch", RUN_SUCCEEDED)
40
41 self.expect("expression -- m_a = 2",
42 startstr = "(int) $0 = 2")
43
44 self.runCmd("process continue")
45
46 # This would be disallowed if we enforced const. But we don't.
47 self.expect("expression -- m_a = 2",
48 startstr = "(int) $1 = 2")
49
50 self.expect("expression -- m_a",
51 startstr = "(int) $2 = 2")
52
53 self.runCmd("process continue")
54
55 self.expect("expression -- s_a",
56 startstr = "(int) $3 = 5")
57
58 self.runCmd("process continue")
59
60 self.expect("expression -- m_a",
61 startstr = "(int) $4 = 2")
62
63if __name__ == '__main__':
64 import atexit
65 lldb.SBDebugger.Initialize()
66 atexit.register(lambda: lldb.SBDebugger.Terminate())
67 unittest2.main()