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 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 @skipIf(bugnumber="llvm.org/pr51833") 16 @skipIfCursesSupportMissing 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 -f main.c -p "// Break here"', substrs=["Breakpoint 1", "address ="] 23 ) 24 self.expect("run", substrs=["stop reason ="]) 25 26 escape_key = chr(27).encode() 27 28 # Start the GUI. 29 self.child.sendline("gui") 30 31 # Simulate a simple debugging session. 32 self.child.send("s") # step 33 self.child.expect("return 1; // In function[^\r\n]+<<< Thread 1: step in") 34 self.child.send("u") # up 35 self.child.expect_exact("func(); // Break here") 36 self.child.send("d") # down 37 self.child.expect_exact("return 1; // In function") 38 self.child.send("f") # finish 39 self.child.expect("<<< Thread 1: step out") 40 self.child.send("s") # move onto the second one 41 self.child.expect("<<< Thread 1: step in") 42 self.child.send("n") # step over 43 self.child.expect("// Dummy command 1[^\r\n]+<<< Thread 1: step over") 44 self.child.send("n") 45 46 # Test that 'up' + 'step out' steps out of the selected function. 47 self.child.send("s") # move into func_up() 48 self.child.expect("// In func_up") 49 self.child.send("s") # move into func_down() 50 self.child.expect("// In func_down") 51 self.child.send("u") # up 52 self.child.expect("// In func_up") 53 self.child.send("f") # finish 54 self.child.expect("// Dummy command 2[^\r\n]+<<< Thread 1: step out") 55 self.child.send("n") 56 57 # Press escape to quit the gui 58 self.child.send(escape_key) 59 60 self.expect_prompt() 61 self.quit() 62