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 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 -o true -f main.c -p "// First break here"', substrs=["Breakpoint 1", "address ="]) 23 self.expect("run", substrs=["stop reason ="]) 24 25 self.child.sendline("breakpoint list") 26 self.child.expect_exact("No breakpoints currently set.") 27 28 escape_key = chr(27).encode() 29 down_key = chr(27)+'OB' # for vt100 terminal (lldbexpect sets TERM=vt100) 30 31 # Start the GUI and close the welcome window. 32 self.child.sendline("gui") 33 self.child.send(escape_key) 34 self.child.expect_exact("Sources") # wait for gui 35 36 # Go to next line, set a breakpoint. 37 self.child.send(down_key) 38 self.child.send('b') 39 self.child.send(escape_key) 40 self.expect_prompt() 41 self.child.sendline("breakpoint list") 42 self.child.expect("2: file = '[^']*main.c', line = 3,.*") 43 self.child.sendline("gui") 44 self.child.expect_exact("Sources") 45 46 # Go two lines down ("gui" resets position), set a breakpoint. 47 self.child.send(down_key) 48 self.child.send(down_key) 49 self.child.send('b') 50 self.child.send(escape_key) 51 self.expect_prompt() 52 self.child.sendline("breakpoint list") 53 self.child.expect("2: file = '[^']*main.c', line = 3,") 54 self.child.expect("3: file = '[^']*main.c', line = 4,") 55 self.child.sendline("gui") 56 self.child.expect_exact("Sources") 57 58 # Toggle both the breakpoints (remove them). 59 self.child.send(down_key) 60 self.child.send('b') 61 self.child.send(down_key) 62 self.child.send('b') 63 self.child.send(escape_key) 64 self.expect_prompt() 65 self.child.sendline("breakpoint list") 66 self.child.expect_exact("No breakpoints currently set.") 67 self.child.sendline("gui") 68 self.child.expect_exact("Sources") 69 70 # Press escape to quit the gui 71 self.child.send(escape_key) 72 73 self.expect_prompt() 74 self.quit() 75