32c974810f7f99eef58f3778372aaa1f2700172f
[openbsd] /
1 """
2 Test lldb breakpoint command for CPP methods & functions in a namespace.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class CPPBreakpointCommandsTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     def make_breakpoint(self, name, type, expected_num_locations):
18         bkpt = self.target.BreakpointCreateByName(name,
19                                                   type,
20                                                   self.a_out_module,
21                                                   self.nested_comp_unit)
22         num_locations = bkpt.GetNumLocations()
23         self.assertTrue(
24             num_locations == expected_num_locations,
25             "Wrong number of locations for '%s', expected: %d got: %d" %
26             (name,
27              expected_num_locations,
28              num_locations))
29         return bkpt
30
31     def test_cpp_breakpoint_cmds(self):
32         """Test a sequence of breakpoint command add, list, and delete."""
33         self.build()
34
35         exe = self.getBuildArtifact("a.out")
36
37         # Create a target from the debugger.
38
39         self.target = self.dbg.CreateTarget(exe)
40         self.assertTrue(self.target, VALID_TARGET)
41
42         self.a_out_module = lldb.SBFileSpecList()
43         self.a_out_module.Append(lldb.SBFileSpec(exe))
44
45         self.nested_comp_unit = lldb.SBFileSpecList()
46         self.nested_comp_unit.Append(lldb.SBFileSpec("nested.cpp"))
47
48         # First provide ONLY the method name.  This should get everybody...
49         self.make_breakpoint("Function",
50                              lldb.eFunctionNameTypeAuto,
51                              5)
52
53         # Now add the Baz class specifier.  This should get the version contained in Bar,
54         # AND the one contained in ::
55         self.make_breakpoint("Baz::Function",
56                              lldb.eFunctionNameTypeAuto,
57                              2)
58
59         # Then add the Bar::Baz specifier.  This should get the version
60         # contained in Bar only
61         self.make_breakpoint("Bar::Baz::Function",
62                              lldb.eFunctionNameTypeAuto,
63                              1)
64
65         self.make_breakpoint("Function",
66                              lldb.eFunctionNameTypeMethod,
67                              3)
68
69         self.make_breakpoint("Baz::Function",
70                              lldb.eFunctionNameTypeMethod,
71                              2)
72
73         self.make_breakpoint("Bar::Baz::Function",
74                              lldb.eFunctionNameTypeMethod,
75                              1)
76
77         self.make_breakpoint("Function",
78                              lldb.eFunctionNameTypeBase,
79                              2)
80
81         self.make_breakpoint("Bar::Function",
82                              lldb.eFunctionNameTypeBase,
83                              1)