[Lldb-commits] [lldb] r116349 - in /lldb/trunk/test/class_types: TestClassTypes.py TestClassTypesDisassembly.py main.cpp

Johnny Chen johnny.chen at apple.com
Tue Oct 12 15:09:54 PDT 2010


Author: johnny
Date: Tue Oct 12 17:09:54 2010
New Revision: 116349

URL: http://llvm.org/viewvc/llvm-project?rev=116349&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 during setUp().

Modified:
    lldb/trunk/test/class_types/TestClassTypes.py
    lldb/trunk/test/class_types/TestClassTypesDisassembly.py
    lldb/trunk/test/class_types/main.cpp

Modified: lldb/trunk/test/class_types/TestClassTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=116349&r1=116348&r2=116349&view=diff
==============================================================================
--- lldb/trunk/test/class_types/TestClassTypes.py (original)
+++ lldb/trunk/test/class_types/TestClassTypes.py Tue Oct 12 17:09:54 2010
@@ -46,14 +46,21 @@
         self.buildDwarf()
         self.class_types_expr_parser()
 
+    def setUp(self):
+        super(ClassTypesTestCase, self).setUp()
+        # Find the line number to break for main.cpp.
+        self.line = line_number('main.cpp', '// Set break point at this line.')
+
     def class_types(self):
         """Test 'frame variable this' when stopped on a class constructor."""
         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.cpp -l 93", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 1: file ='main.cpp', line = 93")
+        self.expect("breakpoint set -f main.cpp -l %d" % self.line,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" %
+                        self.line)
 
         self.runCmd("run", RUN_SUCCEEDED)
 
@@ -96,13 +103,13 @@
 
         bpfilespec = lldb.SBFileSpec("main.cpp")
 
-        breakpoint = target.BreakpointCreateByLocation(bpfilespec, 93)
+        breakpoint = target.BreakpointCreateByLocation(bpfilespec, self.line)
         self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
 
         # Verify the breakpoint just created.
         self.expect(repr(breakpoint), BREAKPOINT_CREATED, exe=False,
             substrs = ['main.cpp',
-                       '93'])
+                       str(self.line)])
 
         # Now launch the process, and do not stop at entry point.
         rc = lldb.SBError()
@@ -127,7 +134,7 @@
         # should be 93.
         self.expect("%s:%d" % (lldbutil.GetFilenames(thread)[0],
                                lldbutil.GetLineNumbers(thread)[0]),
-                    "Break correctly at main.cpp:93", exe=False,
+                    "Break correctly at main.cpp:%d" % self.line, exe=False,
             startstr = "main.cpp:")
             ### clang compiled code reported main.cpp:94?
             ### startstr = "main.cpp:93")

Modified: lldb/trunk/test/class_types/TestClassTypesDisassembly.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypesDisassembly.py?rev=116349&r1=116348&r2=116349&view=diff
==============================================================================
--- lldb/trunk/test/class_types/TestClassTypesDisassembly.py (original)
+++ lldb/trunk/test/class_types/TestClassTypesDisassembly.py Tue Oct 12 17:09:54 2010
@@ -33,14 +33,21 @@
         self.buildDwarf()
         self.disassemble_call_stack_api()
 
+    def setUp(self):
+        super(IterateFrameAndDisassembleTestCase, self).setUp()
+        # Find the line number to break for main.cpp.
+        self.line = line_number('main.cpp', '// Set break point at this line.')
+
     def breakOnCtor(self):
         """Setup/run the program so it stops on C's constructor."""
         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.cpp -l 93", BREAKPOINT_CREATED,
-            startstr = "Breakpoint created: 1: file ='main.cpp', line = 93")
+        self.expect("breakpoint set -f main.cpp -l %d" % self.line,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" %
+                        self.line)
 
         self.runCmd("run", RUN_SUCCEEDED)
 

Modified: lldb/trunk/test/class_types/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/main.cpp?rev=116349&r1=116348&r2=116349&view=diff
==============================================================================
--- lldb/trunk/test/class_types/main.cpp (original)
+++ lldb/trunk/test/class_types/main.cpp Tue Oct 12 17:09:54 2010
@@ -90,7 +90,7 @@
         B(ai, bi),
         m_c_int(ci)
     {
-        printf("Within C::ctor() m_c_int=%d\n", m_c_int);
+        printf("Within C::ctor() m_c_int=%d\n", m_c_int); // Set break point at this line.
     }
 
     //virtual





More information about the lldb-commits mailing list