blob: a8b69ded6d40fe656ae0ff253dc90cbb69052895 [file] [log] [blame]
Jim Ingham32fc9602011-10-11 01:43:50 +00001"""
2Test lldb breakpoint command for CPP methods & functions in a namespace.
3"""
4
5import os, time
6import unittest2
7import lldb
8from lldbtest import *
9
Zachary Turner11321522015-09-09 18:25:13 +000010class CPPBreakpointCommandsTestCase(TestBase):
Jim Ingham32fc9602011-10-11 01:43:50 +000011
Greg Clayton4570d3e2013-12-10 23:19:29 +000012 mydir = TestBase.compute_mydir(__file__)
Jim Ingham32fc9602011-10-11 01:43:50 +000013
Zachary Turnera2591162015-10-02 22:47:28 +000014 @expectedFailureWindows
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000015 def test(self):
Jim Ingham32fc9602011-10-11 01:43:50 +000016 """Test a sequence of breakpoint command add, list, and delete."""
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000017 self.build()
Jim Ingham32fc9602011-10-11 01:43:50 +000018 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
85if __name__ == '__main__':
86 import atexit
87 lldb.SBDebugger.Initialize()
88 atexit.register(lambda: lldb.SBDebugger.Terminate())
89 unittest2.main()