[Lldb-commits] [lldb] db828ab - [lldb][gui] add a test for 'b' (toggle breakpoint)

Luboš Luňák via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 5 00:51:48 PDT 2020


Author: Luboš Luňák
Date: 2020-08-05T09:51:13+02:00
New Revision: db828aba55aca0ce977f086dcd449f8fe667f30a

URL: https://github.com/llvm/llvm-project/commit/db828aba55aca0ce977f086dcd449f8fe667f30a
DIFF: https://github.com/llvm/llvm-project/commit/db828aba55aca0ce977f086dcd449f8fe667f30a.diff

LOG: [lldb][gui] add a test for 'b' (toggle breakpoint)

Differential Revision: https://reviews.llvm.org/D85107

Added: 
    lldb/test/API/commands/gui/breakpoints/Makefile
    lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
    lldb/test/API/commands/gui/breakpoints/main.c

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/commands/gui/breakpoints/Makefile b/lldb/test/API/commands/gui/breakpoints/Makefile
new file mode 100644
index 000000000000..c9319d6e6888
--- /dev/null
+++ b/lldb/test/API/commands/gui/breakpoints/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules

diff  --git a/lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py b/lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
new file mode 100644
index 000000000000..13f5e1380a74
--- /dev/null
+++ b/lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py
@@ -0,0 +1,75 @@
+"""
+Test the 'gui' shortcut 'b' (toggle breakpoint).
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class TestGuiBasicDebugCommandTest(PExpectTest):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    # PExpect uses many timeouts internally and doesn't play well
+    # under ASAN on a loaded machine..
+    @skipIfAsan
+    @skipIfCursesSupportMissing
+    @skipIfRemote # "run" command will not work correctly for remote debug
+    def test_gui(self):
+        self.build()
+
+        self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,500))
+        self.expect('br set -o true -f main.c -p "// First break here"', substrs=["Breakpoint 1", "address ="])
+        self.expect("run", substrs=["stop reason ="])
+
+        self.child.sendline("breakpoint list")
+        self.child.expect_exact("No breakpoints currently set.")
+
+        escape_key = chr(27).encode()
+        down_key = chr(27)+'OB' # for vt100 terminal (lldbexpect sets TERM=vt100)
+
+        # Start the GUI and close the welcome window.
+        self.child.sendline("gui")
+        self.child.send(escape_key)
+        self.child.expect_exact("Sources") # wait for gui
+
+        # Go to next line, set a breakpoint.
+        self.child.send(down_key)
+        self.child.send('b')
+        self.child.send(escape_key)
+        self.expect_prompt()
+        self.child.sendline("breakpoint list")
+        self.child.expect("2: file = '[^']*main.c', line = 3,.*")
+        self.child.sendline("gui")
+        self.child.expect_exact("Sources")
+
+        # Go two lines down ("gui" resets position), set a breakpoint.
+        self.child.send(down_key)
+        self.child.send(down_key)
+        self.child.send('b')
+        self.child.send(escape_key)
+        self.expect_prompt()
+        self.child.sendline("breakpoint list")
+        self.child.expect("2: file = '[^']*main.c', line = 3,")
+        self.child.expect("3: file = '[^']*main.c', line = 4,")
+        self.child.sendline("gui")
+        self.child.expect_exact("Sources")
+
+        # Toggle both the breakpoints (remove them).
+        self.child.send(down_key)
+        self.child.send('b')
+        self.child.send(down_key)
+        self.child.send('b')
+        self.child.send(escape_key)
+        self.expect_prompt()
+        self.child.sendline("breakpoint list")
+        self.child.expect_exact("No breakpoints currently set.")
+        self.child.sendline("gui")
+        self.child.expect_exact("Sources")
+
+        # Press escape to quit the gui
+        self.child.send(escape_key)
+
+        self.expect_prompt()
+        self.quit()

diff  --git a/lldb/test/API/commands/gui/breakpoints/main.c b/lldb/test/API/commands/gui/breakpoints/main.c
new file mode 100644
index 000000000000..61a0843482a4
--- /dev/null
+++ b/lldb/test/API/commands/gui/breakpoints/main.c
@@ -0,0 +1,6 @@
+int main(int argc, char **argv) {
+  int var1 = 1; // First break here
+  int var2 = 2;
+  int var3 = 3;
+  return var1 + var2 + var3;
+}


        


More information about the lldb-commits mailing list