2 Test lldb breakpoint ids.
5 from __future__ import print_function
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class TestCPPBreakpointLocations(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
18 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
21 self.breakpoint_id_tests()
23 def verify_breakpoint_locations(self, target, bp_dict):
25 name = bp_dict['name']
26 names = bp_dict['loc_names']
27 bp = target.BreakpointCreateByName(name)
31 "Make sure we find the right number of breakpoint locations")
35 bp_loc_names.append(bp_loc.GetAddress().GetFunction().GetName())
38 found = name in bp_loc_names
40 print("Didn't find '%s' in: %s" % (name, bp_loc_names))
41 self.assertTrue(found, "Make sure we find all required locations")
43 def breakpoint_id_tests(self):
45 # Create a target by the debugger.
46 exe = self.getBuildArtifact("a.out")
47 target = self.dbg.CreateTarget(exe)
48 self.assertTrue(target, VALID_TARGET)
50 {'name': 'func1', 'loc_names': ['a::c::func1()', 'b::c::func1()']},
51 {'name': 'func2', 'loc_names': ['a::c::func2()', 'c::d::func2()']},
52 {'name': 'func3', 'loc_names': ['a::c::func3()', 'b::c::func3()', 'c::d::func3()']},
53 {'name': 'c::func1', 'loc_names': ['a::c::func1()', 'b::c::func1()']},
54 {'name': 'c::func2', 'loc_names': ['a::c::func2()']},
55 {'name': 'c::func3', 'loc_names': ['a::c::func3()', 'b::c::func3()']},
56 {'name': 'a::c::func1', 'loc_names': ['a::c::func1()']},
57 {'name': 'b::c::func1', 'loc_names': ['b::c::func1()']},
58 {'name': 'c::d::func2', 'loc_names': ['c::d::func2()']},
59 {'name': 'a::c::func1()', 'loc_names': ['a::c::func1()']},
60 {'name': 'b::c::func1()', 'loc_names': ['b::c::func1()']},
61 {'name': 'c::d::func2()', 'loc_names': ['c::d::func2()']},
64 for bp_dict in bp_dicts:
65 self.verify_breakpoint_locations(target, bp_dict)
67 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
68 def test_destructors(self):
70 exe = self.getBuildArtifact("a.out")
71 target = self.dbg.CreateTarget(exe)
73 # Don't skip prologue, so we can check the breakpoint address more
75 self.runCmd("settings set target.skip-prologue false")
77 names = ['~c', 'c::~c', 'c::~c()']
78 loc_names = {'a::c::~c()', 'b::c::~c()'}
79 # TODO: For windows targets we should put windows mangled names
88 bp = target.BreakpointCreateByName(name)
90 bp_loc_names = {bp_loc.GetAddress().GetFunction().GetName()
95 "Breakpoint set on the correct symbol")
97 bp_addresses = {bp_loc.GetLoadAddress() for bp_loc in bp}
98 symbol_addresses = set()
99 for symbol in symbols:
100 sc_list = target.FindSymbols(symbol, lldb.eSymbolTypeCode)
102 sc_list.GetSize(), 1, "Found symbol " + symbol)
103 symbol = sc_list.GetContextAtIndex(0).GetSymbol()
104 symbol_addresses.add(
105 symbol.GetStartAddress().GetLoadAddress(target))
110 "Breakpoint set on correct address")
112 self.runCmd("settings clear target.skip-prologue")