blob: 72c01ad344d8cf8a330256661efdfc23c1b48191 [file] [log] [blame]
Jim Ingham32fc9602011-10-11 01:43:50 +00001"""
2Test lldb breakpoint command for CPP methods & functions in a namespace.
3"""
4
Zachary Turner35d017f2015-10-23 17:04:29 +00005from __future__ import print_function
6
Zachary Turner77db4a82015-10-22 20:06:20 +00007import lldb_shared
8
Jim Ingham32fc9602011-10-11 01:43:50 +00009import os, time
Jim Ingham32fc9602011-10-11 01:43:50 +000010import lldb
11from lldbtest import *
12
Zachary Turner11321522015-09-09 18:25:13 +000013class CPPBreakpointCommandsTestCase(TestBase):
Jim Ingham32fc9602011-10-11 01:43:50 +000014
Greg Clayton4570d3e2013-12-10 23:19:29 +000015 mydir = TestBase.compute_mydir(__file__)
Jim Ingham32fc9602011-10-11 01:43:50 +000016
Zachary Turnera2591162015-10-02 22:47:28 +000017 @expectedFailureWindows
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000018 def test(self):
Jim Ingham32fc9602011-10-11 01:43:50 +000019 """Test a sequence of breakpoint command add, list, and delete."""
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000020 self.build()
Jim Ingham32fc9602011-10-11 01:43:50 +000021 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)