Jim Ingham | 32fc960 | 2011-10-11 01:43:50 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test lldb breakpoint command for CPP methods & functions in a namespace. |
| 3 | """ |
| 4 | |
| 5 | import os, time |
| 6 | import unittest2 |
| 7 | import lldb |
| 8 | from lldbtest import * |
| 9 | |
Zachary Turner | 1132152 | 2015-09-09 18:25:13 +0000 | [diff] [blame] | 10 | class CPPBreakpointCommandsTestCase(TestBase): |
Jim Ingham | 32fc960 | 2011-10-11 01:43:50 +0000 | [diff] [blame] | 11 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 12 | mydir = TestBase.compute_mydir(__file__) |
Jim Ingham | 32fc960 | 2011-10-11 01:43:50 +0000 | [diff] [blame] | 13 | |
Zachary Turner | a259116 | 2015-10-02 22:47:28 +0000 | [diff] [blame] | 14 | @expectedFailureWindows |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 15 | def test(self): |
Jim Ingham | 32fc960 | 2011-10-11 01:43:50 +0000 | [diff] [blame] | 16 | """Test a sequence of breakpoint command add, list, and delete.""" |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 17 | self.build() |
Jim Ingham | 32fc960 | 2011-10-11 01:43:50 +0000 | [diff] [blame] | 18 | exe = os.path.join(os.getcwd(), "a.out") |
| 19 | |
| 20 | # Create a target from the debugger. |
| 21 | |
| 22 | target = self.dbg.CreateTarget (exe) |
| 23 | self.assertTrue(target, VALID_TARGET) |
| 24 | |
| 25 | a_out_module = lldb.SBFileSpecList() |
| 26 | a_out_module.Append(lldb.SBFileSpec(exe)) |
| 27 | |
| 28 | nested_comp_unit = lldb.SBFileSpecList() |
| 29 | nested_comp_unit.Append (lldb.SBFileSpec("nested.cpp")) |
| 30 | |
| 31 | # First provide ONLY the method name. This should get everybody... |
| 32 | auto_break = target.BreakpointCreateByName ("Function", |
| 33 | lldb.eFunctionNameTypeAuto, |
| 34 | a_out_module, |
| 35 | nested_comp_unit) |
| 36 | self.assertTrue (auto_break.GetNumLocations() == 5) |
| 37 | |
| 38 | # Now add the Baz class specifier. This should get the version contained in Bar, |
| 39 | # AND the one contained in :: |
| 40 | auto_break = target.BreakpointCreateByName ("Baz::Function", |
| 41 | lldb.eFunctionNameTypeAuto, |
| 42 | a_out_module, |
| 43 | nested_comp_unit) |
| 44 | self.assertTrue (auto_break.GetNumLocations() == 2) |
| 45 | |
| 46 | # Then add the Bar::Baz specifier. This should get the version contained in Bar only |
| 47 | auto_break = target.BreakpointCreateByName ("Bar::Baz::Function", |
| 48 | lldb.eFunctionNameTypeAuto, |
| 49 | a_out_module, |
| 50 | nested_comp_unit) |
| 51 | self.assertTrue (auto_break.GetNumLocations() == 1) |
| 52 | |
| 53 | plain_method_break = target.BreakpointCreateByName ("Function", |
| 54 | lldb.eFunctionNameTypeMethod, |
| 55 | a_out_module, |
| 56 | nested_comp_unit) |
| 57 | self.assertTrue (plain_method_break.GetNumLocations() == 3) |
| 58 | |
| 59 | plain_method_break = target.BreakpointCreateByName ("Baz::Function", |
| 60 | lldb.eFunctionNameTypeMethod, |
| 61 | a_out_module, |
| 62 | nested_comp_unit) |
| 63 | self.assertTrue (plain_method_break.GetNumLocations() == 2) |
| 64 | |
| 65 | plain_method_break = target.BreakpointCreateByName ("Bar::Baz::Function", |
| 66 | lldb.eFunctionNameTypeMethod, |
| 67 | a_out_module, |
| 68 | nested_comp_unit) |
| 69 | self.assertTrue (plain_method_break.GetNumLocations() == 1) |
| 70 | |
| 71 | plain_method_break = target.BreakpointCreateByName ("Function", |
| 72 | lldb.eFunctionNameTypeBase, |
| 73 | a_out_module, |
| 74 | nested_comp_unit) |
| 75 | self.assertTrue (plain_method_break.GetNumLocations() == 2) |
| 76 | |
| 77 | plain_method_break = target.BreakpointCreateByName ("Bar::Function", |
| 78 | lldb.eFunctionNameTypeBase, |
| 79 | a_out_module, |
| 80 | nested_comp_unit) |
| 81 | self.assertTrue (plain_method_break.GetNumLocations() == 1) |
| 82 | |
| 83 | |
| 84 | |
| 85 | if __name__ == '__main__': |
| 86 | import atexit |
| 87 | lldb.SBDebugger.Initialize() |
| 88 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 89 | unittest2.main() |