xref: /llvm-project/lldb/test/API/functionalities/breakpoint/breakpoint_on_overload/TestBreakOnOverload.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1dd8490d2SJim Ingham"""
2dd8490d2SJim InghamTest setting a breakpoint on an overloaded function by name.
3dd8490d2SJim Ingham"""
4dd8490d2SJim Ingham
5dd8490d2SJim Inghamimport re
6dd8490d2SJim Inghamimport lldb
7dd8490d2SJim Inghamfrom lldbsuite.test.decorators import *
8dd8490d2SJim Inghamfrom lldbsuite.test.lldbtest import *
9dd8490d2SJim Inghamfrom lldbsuite.test import lldbutil
10dd8490d2SJim Ingham
11dd8490d2SJim Ingham
12dd8490d2SJim Inghamclass TestBreakpointOnOverload(TestBase):
13dd8490d2SJim Ingham    def check_breakpoint(self, name):
14dd8490d2SJim Ingham        bkpt = self.target.BreakpointCreateByName(name)
15dd8490d2SJim Ingham        self.assertEqual(bkpt.num_locations, 1, "Got one location")
16dd8490d2SJim Ingham        addr = bkpt.locations[0].GetAddress()
17dd8490d2SJim Ingham        self.assertTrue(addr.function.IsValid(), "Got a real function")
18*05f10ae0SJim Ingham        # On Window, the name of the function includes the return value.
19*05f10ae0SJim Ingham        # We still succeed in setting the breakpoint, but the resultant
20*05f10ae0SJim Ingham        # name is not the same.
21*05f10ae0SJim Ingham        # So just look for the name we used for the breakpoint in the
22*05f10ae0SJim Ingham        # function name, rather than doing an equality check.
23*05f10ae0SJim Ingham        self.assertIn(name, addr.function.name, "Got the right name")
24dd8490d2SJim Ingham
25dd8490d2SJim Ingham    def test_break_on_overload(self):
26dd8490d2SJim Ingham        self.build()
27dd8490d2SJim Ingham        self.target = lldbutil.run_to_breakpoint_make_target(self)
28dd8490d2SJim Ingham        self.check_breakpoint("a_function(int)")
29dd8490d2SJim Ingham        self.check_breakpoint("a_function(double)")
30dd8490d2SJim Ingham        self.check_breakpoint("a_function(int, double)")
31dd8490d2SJim Ingham        self.check_breakpoint("a_function(double, int)")
32