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