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 @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) 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 -o true -f main.c -p "// First break here"', substrs=["Breakpoint 1", "address ="]) 24 self.expect("run", substrs=["stop reason ="]) 25 26 self.child.sendline("breakpoint list") 27 self.child.expect_exact("No breakpoints currently set.") 28 29 escape_key = chr(27).encode() 30 down_key = chr(27)+'OB' # for vt100 terminal (lldbexpect sets TERM=vt100) 31 32 # Start the GUI and close the welcome window. 33 self.child.sendline("gui") 34 self.child.send(escape_key) 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