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