blob: e4b5d615121033b495b44ebc357a9c424d482c01 [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
Johnny Chen49996272011-08-23 01:00:14 +000012 #rdar://problem/9962849
Daniel Malea658fd572013-03-04 23:15:08 +000013 @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 +000014 @expectedFailureIcc # ICC doesn't emit correct DWARF inline debug info for inlined member functions
Zachary Turner2878bf42015-08-18 20:01:28 +000015 @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows")
16 @expectedFailureWindows("llvm.org/pr24490: We shouldn't be using platform-specific names like `getpid` in tests")
Vince Harron7ac3ea42015-06-26 15:13:21 +000017 @expectedFlakeyClang(bugnumber='llvm.org/pr23012', compiler_version=['>=','3.6']) # failed with totclang - clang3.7
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000018 def test_with_run_command(self):
Sean Callanan72e49402011-08-05 23:43:37 +000019 """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods"""
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000020 self.build()
Sean Callanan72e49402011-08-05 23:43:37 +000021 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
22
23 self.set_breakpoint(line_number('main.cpp', '// breakpoint 1'))
24 self.set_breakpoint(line_number('main.cpp', '// breakpoint 2'))
25 self.set_breakpoint(line_number('main.cpp', '// breakpoint 3'))
26 self.set_breakpoint(line_number('main.cpp', '// breakpoint 4'))
27
Sean Callanan05834cd2015-07-01 23:56:30 +000028 self.runCmd("process launch", RUN_SUCCEEDED)
Sean Callanan72e49402011-08-05 23:43:37 +000029
30 self.expect("expression -- m_a = 2",
31 startstr = "(int) $0 = 2")
32
33 self.runCmd("process continue")
34
35 # This would be disallowed if we enforced const. But we don't.
36 self.expect("expression -- m_a = 2",
37 startstr = "(int) $1 = 2")
38
Sean Callanan0259e512012-05-21 21:29:52 +000039 self.expect("expression -- (int)getpid(); m_a",
Sean Callanan72e49402011-08-05 23:43:37 +000040 startstr = "(int) $2 = 2")
41
42 self.runCmd("process continue")
43
44 self.expect("expression -- s_a",
45 startstr = "(int) $3 = 5")
46
47 self.runCmd("process continue")
48
49 self.expect("expression -- m_a",
50 startstr = "(int) $4 = 2")
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000051
52 def set_breakpoint(self, line):
53 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", line, num_expected_locations=1, loc_exact=False)
Sean Callanan72e49402011-08-05 23:43:37 +000054
55if __name__ == '__main__':
56 import atexit
57 lldb.SBDebugger.Initialize()
58 atexit.register(lambda: lldb.SBDebugger.Terminate())
59 unittest2.main()