1"""
2Test setting a breakpoint on an overloaded function by name.
3"""
4
5import re
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class TestBreakpointOnOverload(TestBase):
13
14    mydir = TestBase.compute_mydir(__file__)
15
16    def check_breakpoint(self, name):
17        bkpt = self.target.BreakpointCreateByName(name)
18        self.assertEqual(bkpt.num_locations, 1, "Got one location")
19        addr = bkpt.locations[0].GetAddress()
20        self.assertTrue(addr.function.IsValid(), "Got a real function")
21        # On Window, the name of the function includes the return value.
22        # We still succeed in setting the breakpoint, but the resultant
23        # name is not the same.
24        # So just look for the name we used for the breakpoint in the
25        # function name, rather than doing an equality check.
26        self.assertIn(name, addr.function.name, "Got the right name")
27
28    def test_break_on_overload(self):
29        self.build()
30        self.target = lldbutil.run_to_breakpoint_make_target(self)
31        self.check_breakpoint("a_function(int)")
32        self.check_breakpoint("a_function(double)")
33        self.check_breakpoint("a_function(int, double)")
34        self.check_breakpoint("a_function(double, int)")
35
36
37
38