[Lldb-commits] [lldb] r116378 - in /lldb/trunk/test/set_values: TestSetValues.py main.c

Johnny Chen johnny.chen at apple.com
Tue Oct 12 16:53:59 PDT 2010


Author: johnny
Date: Tue Oct 12 18:53:59 2010
New Revision: 116378

URL: http://llvm.org/viewvc/llvm-project?rev=116378&view=rev
Log:
Avoid using hardcoded line number to break on.  Use the line_number() utility
function to get the line numbers for breakpoints 1-5 during setUp().

Use a pattern to match the output from both gcc-compiled and clang-compiled binary.

This finishes the conversion of the test suite to avoid hardcoded line numbers
when setting breakpoints with either the lldb command:

    breakpoint set -f filename -l lineno

or the Python API:

    target.BreakpointCreateByLocation(filename, lineno)

Modified:
    lldb/trunk/test/set_values/TestSetValues.py
    lldb/trunk/test/set_values/main.c

Modified: lldb/trunk/test/set_values/TestSetValues.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/set_values/TestSetValues.py?rev=116378&r1=116377&r2=116378&view=diff
==============================================================================
--- lldb/trunk/test/set_values/TestSetValues.py (original)
+++ lldb/trunk/test/set_values/TestSetValues.py Tue Oct 12 18:53:59 2010
@@ -20,26 +20,45 @@
         self.buildDwarf()
         self.set_values()
 
+    def setUp(self):
+        super(SetValuesTestCase, self).setUp()
+        # Find the line numbers to break inside main().
+        self.line1 = line_number('main.c', '// Set break point #1.')
+        self.line2 = line_number('main.c', '// Set break point #2.')
+        self.line3 = line_number('main.c', '// Set break point #3.')
+        self.line4 = line_number('main.c', '// Set break point #4.')
+        self.line5 = line_number('main.c', '// Set break point #5.')
+
     def set_values(self):
         """Test settings and readings of program variables."""
         exe = os.path.join(os.getcwd(), "a.out")
         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
         # Set breakpoints on several places to set program variables.
-        self.expect("breakpoint set -f main.c -l 15", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 1: file ='main.c', line = 15, locations = 1")
-
-        self.expect("breakpoint set -f main.c -l 36", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 2: file ='main.c', line = 36, locations = 1")
-
-        self.expect("breakpoint set -f main.c -l 57", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 3: file ='main.c', line = 57, locations = 1")
-
-        self.expect("breakpoint set -f main.c -l 78", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 4: file ='main.c', line = 78, locations = 1")
-
-        self.expect("breakpoint set -f main.c -l 85", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 5: file ='main.c', line = 85, locations = 1")
+        self.expect("breakpoint set -f main.c -l %d" % self.line1,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" %
+                        self.line1)
+
+        self.expect("breakpoint set -f main.c -l %d" % self.line2,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 2: file ='main.c', line = %d, locations = 1" %
+                        self.line2)
+
+        self.expect("breakpoint set -f main.c -l %d" % self.line3,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 3: file ='main.c', line = %d, locations = 1" %
+                        self.line3)
+
+        self.expect("breakpoint set -f main.c -l %d" % self.line4,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 4: file ='main.c', line = %d, locations = 1" %
+                        self.line4)
+
+        self.expect("breakpoint set -f main.c -l %d" % self.line5,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 5: file ='main.c', line = %d, locations = 1" %
+                        self.line5)
 
         self.runCmd("run", RUN_SUCCEEDED)
 
@@ -65,7 +84,7 @@
         # main.c:36
         # Check that 'frame variable' displays the correct data type and value.
         self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY,
-            startstr = "(short unsigned int) i = 33")
+            patterns = ["\((short unsigned int|unsigned short)\) i = 33"])
 
         # TODO:
         # Now set variable 'i' and check that it is correctly displayed.

Modified: lldb/trunk/test/set_values/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/set_values/main.c?rev=116378&r1=116377&r2=116378&view=diff
==============================================================================
--- lldb/trunk/test/set_values/main.c (original)
+++ lldb/trunk/test/set_values/main.c Tue Oct 12 18:53:59 2010
@@ -12,7 +12,7 @@
 {
     char i = 'a';
     printf("before (char) i = %c\n", i);
-    printf("after  (char) i = %c\n", i);    //// break $source:$line
+    printf("after  (char) i = %c\n", i);    // Set break point #1. //// break $source:$line
 }
 
 void set_uchar(void)
@@ -33,7 +33,7 @@
 {
     unsigned short i = 33;
     printf("before (unsigned short) i = %i\n", i);
-    printf("after  (unsigned short) i = %i\n", i);  //// break $source:$line
+    printf("after  (unsigned short) i = %i\n", i);  // Set break point #2. //// break $source:$line
 }
 
 void set_int(void)
@@ -54,7 +54,7 @@
 {
     long i = 33;
     printf("before (long) i = %li\n", i);
-    printf("after  (long) i = %li\n", i);   //// break $source:$line
+    printf("after  (long) i = %li\n", i);   // Set break point #3. //// break $source:$line
 }
 
 void set_ulong(void)
@@ -75,14 +75,14 @@
 {
     double i = 3.1415927;
     printf("before (double) i = %g\n", i);
-    printf("after  (double) i = %g\n", i);  //// break $source:$line
+    printf("after  (double) i = %g\n", i);  // Set break point #4. //// break $source:$line
 }
 
 void set_long_double(void)
 {
     long double i = 3.1415927;
     printf("before (long double) i = %Lg\n", i);
-    printf("after  (long double) i = %Lg\n", i);    //// break $source:$line
+    printf("after  (long double) i = %Lg\n", i);    // Set break point #5. //// break $source:$line
 }
 
 void set_point (void)





More information about the lldb-commits mailing list