xref: /llvm-project/lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test the 'gui' shortcut 'b' (toggle breakpoint).
3"""
4
5import lldb
6from lldbsuite.test.decorators import *
7from lldbsuite.test.lldbtest import *
8from lldbsuite.test.lldbpexpect import PExpectTest
9
10
11class TestGuiBasicDebugCommandTest(PExpectTest):
12    # PExpect uses many timeouts internally and doesn't play well
13    # under ASAN on a loaded machine..
14    @skipIfAsan
15    @skipIfCursesSupportMissing
16    @skipIf(oslist=["linux"], archs=["arm", "aarch64"])
17    def test_gui(self):
18        self.build()
19
20        self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100, 500))
21        self.expect(
22            'br set -o true -f main.c -p "// First break here"',
23            substrs=["Breakpoint 1", "address ="],
24        )
25        self.expect("run", substrs=["stop reason ="])
26
27        self.child.sendline("breakpoint list")
28        self.child.expect_exact("No breakpoints currently set.")
29
30        escape_key = chr(27).encode()
31        down_key = chr(27) + "OB"  # for vt100 terminal (lldbexpect sets TERM=vt100)
32
33        # Start the GUI.
34        self.child.sendline("gui")
35        self.child.expect_exact("Sources")  # wait for gui
36
37        # Go to next line, set a breakpoint.
38        self.child.send(down_key)
39        self.child.send("b")
40        self.child.send(escape_key)
41        self.expect_prompt()
42        self.child.sendline("breakpoint list")
43        self.child.expect("2: file = '[^']*main.c', line = 3,.*")
44        self.child.sendline("gui")
45        self.child.expect_exact("Sources")
46
47        # Go two lines down ("gui" resets position), set a breakpoint.
48        self.child.send(down_key)
49        self.child.send(down_key)
50        self.child.send("b")
51        self.child.send(escape_key)
52        self.expect_prompt()
53        self.child.sendline("breakpoint list")
54        self.child.expect("2: file = '[^']*main.c', line = 3,")
55        self.child.expect("3: file = '[^']*main.c', line = 4,")
56        self.child.sendline("gui")
57        self.child.expect_exact("Sources")
58
59        # Toggle both the breakpoints (remove them).
60        self.child.send(down_key)
61        self.child.send("b")
62        self.child.send(down_key)
63        self.child.send("b")
64        self.child.send(escape_key)
65        self.expect_prompt()
66        self.child.sendline("breakpoint list")
67        self.child.expect_exact("No breakpoints currently set.")
68        self.child.sendline("gui")
69        self.child.expect_exact("Sources")
70
71        # Press escape to quit the gui
72        self.child.send(escape_key)
73
74        self.expect_prompt()
75        self.quit()
76