Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 1 | """ |
| 2 | Tests that C++ member and static variables are available where they should be. |
| 3 | """ |
Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 4 | import lldb |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 5 | from lldbtest import * |
Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 6 | import lldbutil |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 7 | |
| 8 | class CPPThisTestCase(TestBase): |
| 9 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 10 | mydir = TestBase.compute_mydir(__file__) |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 11 | |
Johnny Chen | 4999627 | 2011-08-23 01:00:14 +0000 | [diff] [blame] | 12 | #rdar://problem/9962849 |
Daniel Malea | 658fd57 | 2013-03-04 23:15:08 +0000 | [diff] [blame] | 13 | @expectedFailureGcc # llvm.org/pr15439 The 'this' pointer isn't available during expression evaluation when stopped in an inlined member function. |
Matt Kopec | 9c99030 | 2013-08-02 17:53:28 +0000 | [diff] [blame] | 14 | @expectedFailureIcc # ICC doesn't emit correct DWARF inline debug info for inlined member functions |
Zachary Turner | 2878bf4 | 2015-08-18 20:01:28 +0000 | [diff] [blame] | 15 | @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 Harron | 7ac3ea4 | 2015-06-26 15:13:21 +0000 | [diff] [blame] | 17 | @expectedFlakeyClang(bugnumber='llvm.org/pr23012', compiler_version=['>=','3.6']) # failed with totclang - clang3.7 |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 18 | def test_with_run_command(self): |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 19 | """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 20 | self.build() |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 21 | 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 Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 28 | self.runCmd("process launch", RUN_SUCCEEDED) |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 29 | |
| 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 Callanan | 0259e51 | 2012-05-21 21:29:52 +0000 | [diff] [blame] | 39 | self.expect("expression -- (int)getpid(); m_a", |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 40 | 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 Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 51 | |
| 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 Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 54 | |
| 55 | if __name__ == '__main__': |
| 56 | import atexit |
| 57 | lldb.SBDebugger.Initialize() |
| 58 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 59 | unittest2.main() |