xref: /llvm-project/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py (revision 43e45f0ec920b45d6073c0aff47597c44948f52c)
1"""
2Test the 'gui' shortcuts 's','n','f','u','d' (step in, step over, step out, up, down)
3"""
4
5import lldb
6from lldbsuite.test.decorators import *
7from lldbsuite.test.lldbtest import *
8from lldbsuite.test.lldbpexpect import PExpectTest
9
10class TestGuiBasicDebugCommandTest(PExpectTest):
11
12    mydir = TestBase.compute_mydir(__file__)
13
14    # PExpect uses many timeouts internally and doesn't play well
15    # under ASAN on a loaded machine..
16    @skipIfAsan
17    @skipIfCursesSupportMissing
18    def test_gui(self):
19        self.build()
20
21        self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,500))
22        self.expect('br set -f main.c -p "// Break here"', substrs=["Breakpoint 1", "address ="])
23        self.expect("run", substrs=["stop reason ="])
24
25        escape_key = chr(27).encode()
26
27        # Start the GUI and close the welcome window.
28        self.child.sendline("gui")
29        self.child.expect("Welcome to the LLDB curses GUI.")
30        self.child.send(escape_key)
31
32        # Simulate a simple debugging session.
33        self.child.send("s") # step
34        self.child.expect("return 1; // In function[^\r\n]+<<< Thread 1: step in")
35        self.child.send("u") # up
36        self.child.expect_exact("func(); // Break here")
37        self.child.send("d") # down
38        self.child.expect_exact("return 1; // In function")
39        self.child.send("f") # finish
40        self.child.expect("<<< Thread 1: step out")
41        self.child.send("s") # move onto the second one
42        self.child.expect("<<< Thread 1: step in")
43        self.child.send("n") # step over
44        self.child.expect("<<< Thread 1: step over")
45
46        # Press escape to quit the gui
47        self.child.send(escape_key)
48
49        self.expect_prompt()
50        self.quit()
51