blob: 901202c908a15cb1a5332a4a2ffacb9ac7899ea8 [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"""
Jim Ingham63dfc722012-09-22 00:05:11 +00004import lldb
Sean Callanan72e49402011-08-05 23:43:37 +00005from lldbtest import *
Jim Ingham63dfc722012-09-22 00:05:11 +00006import lldbutil
Sean Callanan72e49402011-08-05 23:43:37 +00007
8class CPPThisTestCase(TestBase):
9
Greg Clayton4570d3e2013-12-10 23:19:29 +000010 mydir = TestBase.compute_mydir(__file__)
Sean Callanan72e49402011-08-05 23:43:37 +000011
Robert Flack13c7ad92015-03-30 14:12:17 +000012 @skipUnlessDarwin
Johnny Chen49996272011-08-23 01:00:14 +000013 #rdar://problem/9962849
Johnny Chen1e4cd1f2011-12-12 22:07:36 +000014 #@expectedFailureClang
Johnny Chen24086bc2012-04-06 19:54:10 +000015 @dsym_test
Sean Callanan72e49402011-08-05 23:43:37 +000016 def test_with_dsym_and_run_command(self):
17 """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods"""
18 self.buildDsym()
19 self.static_method_commands()
20
Johnny Chen49996272011-08-23 01:00:14 +000021 #rdar://problem/9962849
Daniel Malea658fd572013-03-04 23:15:08 +000022 @expectedFailureGcc # llvm.org/pr15439 The 'this' pointer isn't available during expression evaluation when stopped in an inlined member function.
Matt Kopec9c990302013-08-02 17:53:28 +000023 @expectedFailureIcc # ICC doesn't emit correct DWARF inline debug info for inlined member functions
Zachary Turner2878bf42015-08-18 20:01:28 +000024 @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows")
25 @expectedFailureWindows("llvm.org/pr24490: We shouldn't be using platform-specific names like `getpid` in tests")
Johnny Chen24086bc2012-04-06 19:54:10 +000026 @dwarf_test
Vince Harron7ac3ea42015-06-26 15:13:21 +000027 @expectedFlakeyClang(bugnumber='llvm.org/pr23012', compiler_version=['>=','3.6']) # failed with totclang - clang3.7
Sean Callanan72e49402011-08-05 23:43:37 +000028 def test_with_dwarf_and_run_command(self):
29 """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods"""
30 self.buildDwarf()
31 self.static_method_commands()
32
33 def setUp(self):
34 TestBase.setUp(self)
35
36 def set_breakpoint(self, line):
Jim Ingham63dfc722012-09-22 00:05:11 +000037 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", line, num_expected_locations=1, loc_exact=False)
38
Sean Callanan72e49402011-08-05 23:43:37 +000039 def static_method_commands(self):
40 """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods"""
41 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
42
43 self.set_breakpoint(line_number('main.cpp', '// breakpoint 1'))
44 self.set_breakpoint(line_number('main.cpp', '// breakpoint 2'))
45 self.set_breakpoint(line_number('main.cpp', '// breakpoint 3'))
46 self.set_breakpoint(line_number('main.cpp', '// breakpoint 4'))
47
Sean Callanan05834cd2015-07-01 23:56:30 +000048 self.runCmd("process launch", RUN_SUCCEEDED)
Sean Callanan72e49402011-08-05 23:43:37 +000049
50 self.expect("expression -- m_a = 2",
51 startstr = "(int) $0 = 2")
52
53 self.runCmd("process continue")
54
55 # This would be disallowed if we enforced const. But we don't.
56 self.expect("expression -- m_a = 2",
57 startstr = "(int) $1 = 2")
58
Sean Callanan0259e512012-05-21 21:29:52 +000059 self.expect("expression -- (int)getpid(); m_a",
Sean Callanan72e49402011-08-05 23:43:37 +000060 startstr = "(int) $2 = 2")
61
62 self.runCmd("process continue")
63
64 self.expect("expression -- s_a",
65 startstr = "(int) $3 = 5")
66
67 self.runCmd("process continue")
68
69 self.expect("expression -- m_a",
70 startstr = "(int) $4 = 2")
71
72if __name__ == '__main__':
73 import atexit
74 lldb.SBDebugger.Initialize()
75 atexit.register(lambda: lldb.SBDebugger.Terminate())
76 unittest2.main()