199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTest lldb breakpoint command for CPP methods & functions in a namespace. 399451b44SJordan Rupprecht""" 499451b44SJordan Rupprecht 599451b44SJordan Rupprecht 699451b44SJordan Rupprechtimport lldb 799451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 899451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 999451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil 1099451b44SJordan Rupprecht 1199451b44SJordan Rupprecht 1299451b44SJordan Rupprechtclass CPPBreakpointCommandsTestCase(TestBase): 1399451b44SJordan Rupprecht def make_breakpoint(self, name, type, expected_num_locations): 14*2238dcc3SJonas Devlieghere bkpt = self.target.BreakpointCreateByName( 15*2238dcc3SJonas Devlieghere name, type, self.a_out_module, self.nested_comp_unit 16*2238dcc3SJonas Devlieghere ) 1799451b44SJordan Rupprecht num_locations = bkpt.GetNumLocations() 180ed758b2SDave Lee self.assertEqual( 19*2238dcc3SJonas Devlieghere num_locations, 2099451b44SJordan Rupprecht expected_num_locations, 21*2238dcc3SJonas Devlieghere "Wrong number of locations for '%s', expected: %d got: %d" 22*2238dcc3SJonas Devlieghere % (name, expected_num_locations, num_locations), 23*2238dcc3SJonas Devlieghere ) 2499451b44SJordan Rupprecht return bkpt 2599451b44SJordan Rupprecht 2699451b44SJordan Rupprecht def test_cpp_breakpoint_cmds(self): 2799451b44SJordan Rupprecht """Test a sequence of breakpoint command add, list, and delete.""" 2899451b44SJordan Rupprecht self.build() 2999451b44SJordan Rupprecht 3099451b44SJordan Rupprecht exe = self.getBuildArtifact("a.out") 3199451b44SJordan Rupprecht 3299451b44SJordan Rupprecht # Create a target from the debugger. 3399451b44SJordan Rupprecht 3499451b44SJordan Rupprecht self.target = self.dbg.CreateTarget(exe) 3599451b44SJordan Rupprecht self.assertTrue(self.target, VALID_TARGET) 3699451b44SJordan Rupprecht 3799451b44SJordan Rupprecht self.a_out_module = lldb.SBFileSpecList() 3899451b44SJordan Rupprecht self.a_out_module.Append(lldb.SBFileSpec(exe)) 3999451b44SJordan Rupprecht 4099451b44SJordan Rupprecht self.nested_comp_unit = lldb.SBFileSpecList() 4199451b44SJordan Rupprecht self.nested_comp_unit.Append(lldb.SBFileSpec("nested.cpp")) 4299451b44SJordan Rupprecht 4399451b44SJordan Rupprecht # First provide ONLY the method name. This should get everybody... 44*2238dcc3SJonas Devlieghere self.make_breakpoint("Function", lldb.eFunctionNameTypeAuto, 5) 4599451b44SJordan Rupprecht 4699451b44SJordan Rupprecht # Now add the Baz class specifier. This should get the version contained in Bar, 4799451b44SJordan Rupprecht # AND the one contained in :: 48*2238dcc3SJonas Devlieghere self.make_breakpoint("Baz::Function", lldb.eFunctionNameTypeAuto, 2) 4999451b44SJordan Rupprecht 5099451b44SJordan Rupprecht # Then add the Bar::Baz specifier. This should get the version 5199451b44SJordan Rupprecht # contained in Bar only 52*2238dcc3SJonas Devlieghere self.make_breakpoint("Bar::Baz::Function", lldb.eFunctionNameTypeAuto, 1) 5399451b44SJordan Rupprecht 54*2238dcc3SJonas Devlieghere self.make_breakpoint("Function", lldb.eFunctionNameTypeMethod, 3) 5599451b44SJordan Rupprecht 56*2238dcc3SJonas Devlieghere self.make_breakpoint("Baz::Function", lldb.eFunctionNameTypeMethod, 2) 5799451b44SJordan Rupprecht 58*2238dcc3SJonas Devlieghere self.make_breakpoint("Bar::Baz::Function", lldb.eFunctionNameTypeMethod, 1) 5999451b44SJordan Rupprecht 60*2238dcc3SJonas Devlieghere self.make_breakpoint("Function", lldb.eFunctionNameTypeBase, 2) 6199451b44SJordan Rupprecht 62*2238dcc3SJonas Devlieghere self.make_breakpoint("Bar::Function", lldb.eFunctionNameTypeBase, 1) 63