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    def check_breakpoint(self, name):
15        bkpt = self.target.BreakpointCreateByName(name)
16        self.assertEqual(bkpt.num_locations, 1, "Got one location")
17        addr = bkpt.locations[0].GetAddress()
18        self.assertTrue(addr.function.IsValid(), "Got a real function")
19        # On Window, the name of the function includes the return value.
20        # We still succeed in setting the breakpoint, but the resultant
21        # name is not the same.
22        # So just look for the name we used for the breakpoint in the
23        # function name, rather than doing an equality check.
24        self.assertIn(name, addr.function.name, "Got the right name")
25
26    def test_break_on_overload(self):
27        self.build()
28        self.target = lldbutil.run_to_breakpoint_make_target(self)
29        self.check_breakpoint("a_function(int)")
30        self.check_breakpoint("a_function(double)")
31        self.check_breakpoint("a_function(int, double)")
32        self.check_breakpoint("a_function(double, int)")
33
34
35
36