| 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 | """ |
| 4 | |
| 5 | from lldbtest import * |
| 6 | |
| 7 | class CPPThisTestCase(TestBase): |
| 8 | |
| 9 | mydir = os.path.join("lang", "cpp", "this") |
| 10 | |
| 11 | @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") |
| Johnny Chen | 4999627 | 2011-08-23 01:00:14 +0000 | [diff] [blame] | 12 | #rdar://problem/9962849 |
| Johnny Chen | 1e4cd1f | 2011-12-12 22:07:36 +0000 | [diff] [blame] | 13 | #@expectedFailureClang |
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame^] | 14 | @dsym_test |
| Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 15 | def test_with_dsym_and_run_command(self): |
| 16 | """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" |
| 17 | self.buildDsym() |
| 18 | self.static_method_commands() |
| 19 | |
| Johnny Chen | 4999627 | 2011-08-23 01:00:14 +0000 | [diff] [blame] | 20 | #rdar://problem/9962849 |
| Johnny Chen | 1e4cd1f | 2011-12-12 22:07:36 +0000 | [diff] [blame] | 21 | #@expectedFailureClang |
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame^] | 22 | @dwarf_test |
| Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 23 | def test_with_dwarf_and_run_command(self): |
| 24 | """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" |
| 25 | self.buildDwarf() |
| 26 | self.static_method_commands() |
| 27 | |
| 28 | def setUp(self): |
| 29 | TestBase.setUp(self) |
| 30 | |
| 31 | def set_breakpoint(self, line): |
| 32 | self.expect("breakpoint set -f main.cpp -l %d" % line, |
| 33 | BREAKPOINT_CREATED, |
| 34 | startstr = "Breakpoint created") |
| 35 | |
| 36 | def static_method_commands(self): |
| 37 | """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" |
| 38 | self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) |
| 39 | |
| 40 | self.set_breakpoint(line_number('main.cpp', '// breakpoint 1')) |
| 41 | self.set_breakpoint(line_number('main.cpp', '// breakpoint 2')) |
| 42 | self.set_breakpoint(line_number('main.cpp', '// breakpoint 3')) |
| 43 | self.set_breakpoint(line_number('main.cpp', '// breakpoint 4')) |
| 44 | |
| 45 | self.runCmd("process launch", RUN_SUCCEEDED) |
| 46 | |
| 47 | self.expect("expression -- m_a = 2", |
| 48 | startstr = "(int) $0 = 2") |
| 49 | |
| 50 | self.runCmd("process continue") |
| 51 | |
| 52 | # This would be disallowed if we enforced const. But we don't. |
| 53 | self.expect("expression -- m_a = 2", |
| 54 | startstr = "(int) $1 = 2") |
| 55 | |
| 56 | self.expect("expression -- m_a", |
| 57 | startstr = "(int) $2 = 2") |
| 58 | |
| 59 | self.runCmd("process continue") |
| 60 | |
| 61 | self.expect("expression -- s_a", |
| 62 | startstr = "(int) $3 = 5") |
| 63 | |
| 64 | self.runCmd("process continue") |
| 65 | |
| 66 | self.expect("expression -- m_a", |
| 67 | startstr = "(int) $4 = 2") |
| 68 | |
| 69 | if __name__ == '__main__': |
| 70 | import atexit |
| 71 | lldb.SBDebugger.Initialize() |
| 72 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 73 | unittest2.main() |