xref: /llvm-project/lldb/test/API/functionalities/breakpoint/breakpoint_ids/TestBreakpointIDs.py (revision 80fcecb13c388ff087a27a4b0e7ca3dd8c98eaa4)
199451b44SJordan Rupprecht"""
299451b44SJordan RupprechtTest lldb breakpoint ids.
399451b44SJordan Rupprecht"""
499451b44SJordan Rupprecht
599451b44SJordan Rupprecht
699451b44SJordan Rupprechtimport lldb
799451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
899451b44SJordan Rupprechtimport lldbsuite.test.lldbutil as lldbutil
999451b44SJordan Rupprecht
1099451b44SJordan Rupprecht
1199451b44SJordan Rupprechtclass BreakpointIDTestCase(TestBase):
1299451b44SJordan Rupprecht    def test(self):
1399451b44SJordan Rupprecht        self.build()
1499451b44SJordan Rupprecht
1599451b44SJordan Rupprecht        exe = self.getBuildArtifact("a.out")
162238dcc3SJonas Devlieghere        self.expect("file " + exe, patterns=["Current executable set to .*a.out"])
1799451b44SJordan Rupprecht
1899451b44SJordan Rupprecht        bpno = lldbutil.run_break_set_by_symbol(
192238dcc3SJonas Devlieghere            self, "product", num_expected_locations=-1, sym_exact=False
202238dcc3SJonas Devlieghere        )
21*80fcecb1SJonas Devlieghere        self.assertEqual(bpno, 1, "First breakpoint number is 1.")
2299451b44SJordan Rupprecht
2399451b44SJordan Rupprecht        bpno = lldbutil.run_break_set_by_symbol(
242238dcc3SJonas Devlieghere            self, "sum", num_expected_locations=-1, sym_exact=False
252238dcc3SJonas Devlieghere        )
26*80fcecb1SJonas Devlieghere        self.assertEqual(bpno, 2, "Second breakpoint number is 2.")
2799451b44SJordan Rupprecht
2899451b44SJordan Rupprecht        bpno = lldbutil.run_break_set_by_symbol(
292238dcc3SJonas Devlieghere            self, "junk", num_expected_locations=0, sym_exact=False
302238dcc3SJonas Devlieghere        )
31*80fcecb1SJonas Devlieghere        self.assertEqual(bpno, 3, "Third breakpoint number is 3.")
3299451b44SJordan Rupprecht
3399451b44SJordan Rupprecht        self.expect(
3499451b44SJordan Rupprecht            "breakpoint disable 1.1 - 2.2 ",
3599451b44SJordan Rupprecht            COMMAND_FAILED_AS_EXPECTED,
3699451b44SJordan Rupprecht            error=True,
372238dcc3SJonas Devlieghere            startstr="error: Invalid range: Ranges that specify particular breakpoint locations must be within the same major breakpoint; you specified two different major breakpoints, 1 and 2.",
382238dcc3SJonas Devlieghere        )
3999451b44SJordan Rupprecht
4099451b44SJordan Rupprecht        self.expect(
4199451b44SJordan Rupprecht            "breakpoint disable 2 - 2.2",
4299451b44SJordan Rupprecht            COMMAND_FAILED_AS_EXPECTED,
4399451b44SJordan Rupprecht            error=True,
442238dcc3SJonas Devlieghere            startstr="error: Invalid breakpoint id range:  Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.",
452238dcc3SJonas Devlieghere        )
4699451b44SJordan Rupprecht
4799451b44SJordan Rupprecht        self.expect(
4899451b44SJordan Rupprecht            "breakpoint disable 2.1 - 2",
4999451b44SJordan Rupprecht            COMMAND_FAILED_AS_EXPECTED,
5099451b44SJordan Rupprecht            error=True,
512238dcc3SJonas Devlieghere            startstr="error: Invalid breakpoint id range:  Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.",
522238dcc3SJonas Devlieghere        )
5399451b44SJordan Rupprecht
542238dcc3SJonas Devlieghere        self.expect("breakpoint disable 2.1 - 2.2", startstr="2 breakpoints disabled.")
5599451b44SJordan Rupprecht
562238dcc3SJonas Devlieghere        self.expect("breakpoint enable 2.*", patterns=[".* breakpoints enabled."])
57