[Lldb-commits] [lldb] r116369 - in /lldb/trunk/test/struct_types: TestStructTypes.py main.c

Johnny Chen johnny.chen at apple.com
Tue Oct 12 16:20:04 PDT 2010


Author: johnny
Date: Tue Oct 12 18:20:04 2010
New Revision: 116369

URL: http://llvm.org/viewvc/llvm-project?rev=116369&view=rev
Log:
Avoid using hardcoded line number to break on.  Use the line_number() utility
function to get the line number to break on as well as the line number of the
first executable statement during setUp().

Modified:
    lldb/trunk/test/struct_types/TestStructTypes.py
    lldb/trunk/test/struct_types/main.c

Modified: lldb/trunk/test/struct_types/TestStructTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/struct_types/TestStructTypes.py?rev=116369&r1=116368&r2=116369&view=diff
==============================================================================
--- lldb/trunk/test/struct_types/TestStructTypes.py (original)
+++ lldb/trunk/test/struct_types/TestStructTypes.py Tue Oct 12 18:20:04 2010
@@ -24,21 +24,30 @@
         self.buildDwarf()
         self.struct_types()
 
+    def setUp(self):
+        super(StructTypesTestCase, self).setUp()
+        # Find the line number to break for main.c.
+        self.line = line_number('main.c', '// Set break point at this line.')
+        self.first_executable_line = line_number('main.c',
+                                                 '// This is the first executable statement.')
+
     def struct_types(self):
         """Test that break on a struct declaration has no effect."""
         exe = os.path.join(os.getcwd(), "a.out")
         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
-        # Break on the ctor function of class C.
-        self.expect("breakpoint set -f main.c -l 14", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 1: file ='main.c', line = 14, locations = 1")
+        # Break on the struct declration statement in main.c.
+        self.expect("breakpoint set -f main.c -l %d" % self.line,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" %
+                        self.line)
 
         self.runCmd("run", RUN_SUCCEEDED)
 
         # We should be stopped on the first executable statement within the
         # function where the original breakpoint was attempted.
         self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
-            substrs = ['main.c:20',
+            substrs = ['main.c:%d' % self.first_executable_line,
                        'stop reason = breakpoint'])
 
         # The breakpoint should have a hit count of 1.

Modified: lldb/trunk/test/struct_types/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/struct_types/main.c?rev=116369&r1=116368&r2=116369&view=diff
==============================================================================
--- lldb/trunk/test/struct_types/main.c (original)
+++ lldb/trunk/test/struct_types/main.c Tue Oct 12 18:20:04 2010
@@ -11,13 +11,13 @@
     struct point_tag {
         int x;
         int y;
-    };
+    }; // Set break point at this line.
 
     struct rect_tag {
         struct point_tag bottom_left;
         struct point_tag top_right;
     };
-    struct point_tag pt = { 2, 3 };
+    struct point_tag pt = { 2, 3 }; // This is the first executable statement.
     struct rect_tag rect = {{1,2}, {3,4}};
     return 0;
 }





More information about the lldb-commits mailing list