[Lldb-commits] [lldb] r115202 - in /lldb/trunk/test/breakpoint_locations: ./ Makefile TestBreakpointLocations.py main.c

Johnny Chen johnny.chen at apple.com
Thu Sep 30 13:46:47 PDT 2010


Author: johnny
Date: Thu Sep 30 15:46:47 2010
New Revision: 115202

URL: http://llvm.org/viewvc/llvm-project?rev=115202&view=rev
Log:
Add a more complex test scenario for breakpoint locations, with breakpoint enable/disable.

Added:
    lldb/trunk/test/breakpoint_locations/
    lldb/trunk/test/breakpoint_locations/Makefile
    lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py
    lldb/trunk/test/breakpoint_locations/main.c

Added: lldb/trunk/test/breakpoint_locations/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_locations/Makefile?rev=115202&view=auto
==============================================================================
--- lldb/trunk/test/breakpoint_locations/Makefile (added)
+++ lldb/trunk/test/breakpoint_locations/Makefile Thu Sep 30 15:46:47 2010
@@ -0,0 +1,5 @@
+LEVEL = ../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py?rev=115202&view=auto
==============================================================================
--- lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py (added)
+++ lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py Thu Sep 30 15:46:47 2010
@@ -0,0 +1,90 @@
+"""
+Test breakpoint commands for a breakpoint ID with multiple locations.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class BreakpointLocationsTestCase(TestBase):
+
+    mydir = "breakpoint_locations"
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    def test_with_dsym(self):
+        """Test breakpoint enable/disable for a breakpoint ID with multiple locations."""
+        self.buildDsym()
+        self.breakpoint_locations_test()
+
+    def test_with_dwarf(self):
+        """Test breakpoint enable/disable for a breakpoint ID with multiple locations."""
+        self.buildDwarf()
+        self.breakpoint_locations_test()
+
+    def breakpoint_locations_test(self):
+        """Test breakpoint enable/disable for a breakpoint ID with multiple locations."""
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        # This should create a breakpoint with 3 locations.
+        self.expect("breakpoint set -f main.c -l 19", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.c', line = 19, locations = 3")
+
+        # The breakpoint list should show 3 locations.
+        self.expect("breakpoint list", "Breakpoint locations shown correctly",
+            substrs = ["1: file ='main.c', line = 19, locations = 3"],
+            patterns = ["1\.1: where = a.out`func_inlined .+unresolved, hit count = 0",
+                        "1\.2: where = a.out`main .+\[inlined\].+unresolved, hit count = 0",
+                        "1\.3: where = a.out`main .+\[inlined\].+unresolved, hit count = 0"])
+
+        # The 'breakpoint disable 3.*' command should fail gracefully.
+        self.expect("breakpoint disable 3.*",
+                    "Disabling an invalid breakpoint should fail gracefully",
+                    error=True,
+            startstr = "error: '3' is not a valid breakpoint ID.")
+
+        # The 'breakpoint disable 1.*' command should disable all 3 locations.
+        self.expect("breakpoint disable 1.*", "All 3 breakpoint locatons disabled correctly",
+            startstr = "3 breakpoints disabled.")
+
+        # Run the program.
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        # We should not stopped on any breakpoint at all.
+        self.expect("process status", "No stopping on any disabled breakpoint",
+            patterns = ["^Process [0-9]+ exited with status = 0"])
+
+        # The 'breakpoint enable 1.*' command should enable all 3 breakpoints.
+        self.expect("breakpoint enable 1.*", "All 3 breakpoint locatons enabled correctly",
+            startstr = "3 breakpoints enabled.")
+
+        # The 'breakpoint disable 1.1' command should disable 1 location.
+        self.expect("breakpoint disable 1.1", "1 breakpoint locatons disabled correctly",
+            startstr = "1 breakpoints disabled.")
+
+        # Run the program againt.  We should stop on the two breakpoint locations.
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        self.expect("thread backtrace", "Stopped on an inlined location",
+            substrs = ["stop reason = breakpoint 1.2"],
+            patterns = ["frame #0: .+\[inlined\]"])
+
+        self.runCmd("process continue")
+
+        self.expect("thread backtrace", "Stopped on an inlined location",
+            substrs = ["stop reason = breakpoint 1.3"],
+            patterns = ["frame #0: .+\[inlined\]"])
+
+        # At this point, the 3 locations should all have "hit count = 2".
+        self.expect("breakpoint list", "Expect all 3 breakpoints with hit count of 2",
+            patterns = ["1\.1: where = a.out`func_inlined .+ resolved, hit count = 2 +Options: disabled",
+                        "1\.2: where = a.out`main .+\[inlined\].+ resolved, hit count = 2",
+                        "1\.3: where = a.out`main .+\[inlined\].+ resolved, hit count = 2"])
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Added: lldb/trunk/test/breakpoint_locations/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_locations/main.c?rev=115202&view=auto
==============================================================================
--- lldb/trunk/test/breakpoint_locations/main.c (added)
+++ lldb/trunk/test/breakpoint_locations/main.c Thu Sep 30 15:46:47 2010
@@ -0,0 +1,41 @@
+#include <stdio.h>
+
+#define INLINE_ME __inline__ __attribute__((always_inline))
+
+int
+func_not_inlined (void)
+{
+    printf ("Called func_not_inlined.\n");
+    return 0;
+}
+
+INLINE_ME int
+func_inlined (void)
+{
+    static int func_inline_call_count = 0;
+    printf ("Called func_inlined.\n");
+    ++func_inline_call_count;
+    printf ("Returning func_inlined call count: %d.\n", func_inline_call_count);
+    return func_inline_call_count;
+}
+
+int
+main (int argc, char **argv)
+{
+  printf ("Starting...\n");
+
+  int (*func_ptr) (void);
+  func_ptr = func_inlined;
+
+  int a = func_inlined();
+  printf("First call to func_inlined() returns: %d.\n", a);
+
+  func_not_inlined ();
+
+  func_ptr ();
+
+  printf("Last call to func_inlined() returns: %d.\n", func_inlined ());
+  return 0;
+}
+
+





More information about the lldb-commits mailing list