xref: /llvm-project/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py (revision 0dc9c88aa38ed330ddffe92bae79d4066832c38e)
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    @skipIf(oslist=["linux"], archs=["arm","aarch64"])
18    @skipIfCursesSupportMissing
19    def test_gui(self):
20        self.build()
21
22        self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,500))
23        self.expect('br set -f main.c -p "// Break here"', substrs=["Breakpoint 1", "address ="])
24        self.expect("run", substrs=["stop reason ="])
25
26        escape_key = chr(27).encode()
27
28        # Start the GUI and close the welcome window.
29        self.child.sendline("gui")
30        self.child.expect("Welcome to the LLDB curses GUI.")
31        self.child.send(escape_key)
32
33        # Simulate a simple debugging session.
34        self.child.send("s") # step
35        self.child.expect("return 1; // In function[^\r\n]+<<< Thread 1: step in")
36        self.child.send("u") # up
37        self.child.expect_exact("func(); // Break here")
38        self.child.send("d") # down
39        self.child.expect_exact("return 1; // In function")
40        self.child.send("f") # finish
41        self.child.expect("<<< Thread 1: step out")
42        self.child.send("s") # move onto the second one
43        self.child.expect("<<< Thread 1: step in")
44        self.child.send("n") # step over
45        self.child.expect("<<< Thread 1: step over")
46
47        # Press escape to quit the gui
48        self.child.send(escape_key)
49
50        self.expect_prompt()
51        self.quit()
52