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 | |
Robert Flack | 13c7ad9 | 2015-03-30 14:12:17 +0000 | [diff] [blame] | 12 | @skipUnlessDarwin |
Johnny Chen | 4999627 | 2011-08-23 01:00:14 +0000 | [diff] [blame] | 13 | #rdar://problem/9962849 |
Johnny Chen | 1e4cd1f | 2011-12-12 22:07:36 +0000 | [diff] [blame] | 14 | #@expectedFailureClang |
Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 15 | @dsym_test |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 16 | 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 Chen | 4999627 | 2011-08-23 01:00:14 +0000 | [diff] [blame] | 21 | #rdar://problem/9962849 |
Daniel Malea | 658fd57 | 2013-03-04 23:15:08 +0000 | [diff] [blame] | 22 | @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] | 23 | @expectedFailureIcc # ICC doesn't emit correct DWARF inline debug info for inlined member functions |
Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 24 | @dwarf_test |
Vince Harron | 7ac3ea4 | 2015-06-26 15:13:21 +0000 | [diff] [blame] | 25 | @expectedFlakeyClang(bugnumber='llvm.org/pr23012', compiler_version=['>=','3.6']) # failed with totclang - clang3.7 |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 26 | def test_with_dwarf_and_run_command(self): |
| 27 | """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" |
| 28 | self.buildDwarf() |
| 29 | self.static_method_commands() |
| 30 | |
| 31 | def setUp(self): |
| 32 | TestBase.setUp(self) |
| 33 | |
| 34 | def set_breakpoint(self, line): |
Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 35 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", line, num_expected_locations=1, loc_exact=False) |
| 36 | |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 37 | def static_method_commands(self): |
| 38 | """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" |
| 39 | self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) |
| 40 | |
| 41 | self.set_breakpoint(line_number('main.cpp', '// breakpoint 1')) |
| 42 | self.set_breakpoint(line_number('main.cpp', '// breakpoint 2')) |
| 43 | self.set_breakpoint(line_number('main.cpp', '// breakpoint 3')) |
| 44 | self.set_breakpoint(line_number('main.cpp', '// breakpoint 4')) |
| 45 | |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame^] | 46 | self.runCmd("process launch", RUN_SUCCEEDED) |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 47 | |
| 48 | self.expect("expression -- m_a = 2", |
| 49 | startstr = "(int) $0 = 2") |
| 50 | |
| 51 | self.runCmd("process continue") |
| 52 | |
| 53 | # This would be disallowed if we enforced const. But we don't. |
| 54 | self.expect("expression -- m_a = 2", |
| 55 | startstr = "(int) $1 = 2") |
| 56 | |
Sean Callanan | 0259e51 | 2012-05-21 21:29:52 +0000 | [diff] [blame] | 57 | self.expect("expression -- (int)getpid(); m_a", |
Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 58 | startstr = "(int) $2 = 2") |
| 59 | |
| 60 | self.runCmd("process continue") |
| 61 | |
| 62 | self.expect("expression -- s_a", |
| 63 | startstr = "(int) $3 = 5") |
| 64 | |
| 65 | self.runCmd("process continue") |
| 66 | |
| 67 | self.expect("expression -- m_a", |
| 68 | startstr = "(int) $4 = 2") |
| 69 | |
| 70 | if __name__ == '__main__': |
| 71 | import atexit |
| 72 | lldb.SBDebugger.Initialize() |
| 73 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 74 | unittest2.main() |