Sean Callanan | 974e9fd | 2013-04-30 22:05:15 +0000 | [diff] [blame] | 1 | """ |
| 2 | Tests calling a function by basename |
| 3 | """ |
| 4 | |
| 5 | import lldb |
| 6 | from lldbtest import * |
| 7 | import lldbutil |
| 8 | |
| 9 | class CallCPPFunctionTestCase(TestBase): |
| 10 | |
| 11 | mydir = os.path.join("lang", "cpp", "call-function") |
| 12 | |
| 13 | @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") |
| 14 | @dsym_test |
| 15 | def test_with_dsym_and_run_command(self): |
| 16 | """Test calling a function by basename""" |
| 17 | self.buildDsym() |
| 18 | self.call_cpp_function() |
| 19 | |
Sean Callanan | d7bb1ba | 2013-04-30 23:52:02 +0000 | [diff] [blame^] | 20 | @expectedFailureLinux # bugzilla 15854 |
Sean Callanan | 974e9fd | 2013-04-30 22:05:15 +0000 | [diff] [blame] | 21 | @dwarf_test |
| 22 | def test_with_dwarf_and_run_command(self): |
| 23 | """Test calling a function by basename""" |
| 24 | self.buildDwarf() |
| 25 | self.call_cpp_function() |
| 26 | |
| 27 | def setUp(self): |
| 28 | TestBase.setUp(self) |
| 29 | self.line = line_number('main.cpp', '// breakpoint') |
| 30 | |
| 31 | def call_cpp_function(self): |
| 32 | """Test calling a function by basename""" |
| 33 | self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) |
| 34 | |
| 35 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) |
| 36 | |
| 37 | self.runCmd("process launch", RUN_SUCCEEDED) |
| 38 | |
| 39 | # The stop reason of the thread should be breakpoint. |
| 40 | self.expect("thread list", |
| 41 | STOPPED_DUE_TO_BREAKPOINT, |
| 42 | substrs = ['stopped', 'stop reason = breakpoint']) |
| 43 | |
| 44 | self.expect("expression -- a_function_to_call()", |
| 45 | startstr = "(int) $0 = 0") |
| 46 | |
| 47 | if __name__ == '__main__': |
| 48 | import atexit |
| 49 | lldb.SBDebugger.Initialize() |
| 50 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 51 | unittest2.main() |