[Lldb-commits] [lldb] r135100 - in /lldb/trunk/test: lldbutil.py python_api/frame/inlines/TestInlinedFrame.py python_api/frame/inlines/inlines.c

Johnny Chen johnny.chen at apple.com
Wed Jul 13 15:34:29 PDT 2011


Author: johnny
Date: Wed Jul 13 17:34:29 2011
New Revision: 135100

URL: http://llvm.org/viewvc/llvm-project?rev=135100&view=rev
Log:
Modify the test script to better handle the different inlining behaviors of
clang/gcc/llvm-gcc.  If the first breakpoint is due to stop at an inlined
frame, test that the call site corresponds to where it should be.  Also add
an expecr for a second break stop, if the first break stop corresponds to an
inlined call frame #0.

rdar://problem/9741470

Modified:
    lldb/trunk/test/lldbutil.py
    lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py
    lldb/trunk/test/python_api/frame/inlines/inlines.c

Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=135100&r1=135099&r2=135100&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Wed Jul 13 17:34:29 2011
@@ -395,7 +395,8 @@
             print >> output, "  frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}".format(
                 num=i, addr=load_addr, mod=mods[i],
                 func='%s [inlined]' % funcs[i] if frame.IsInlined() else funcs[i],
-                file=files[i], line=lines[i], args=get_args_as_string(frame, showFuncName=False))
+                file=files[i], line=lines[i],
+                args=get_args_as_string(frame, showFuncName=False) if not frame.IsInlined() else '()')
 
     if string_buffer:
         return output.getvalue()

Modified: lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py?rev=135100&r1=135099&r2=135100&view=diff
==============================================================================
--- lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py (original)
+++ lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py Wed Jul 13 17:34:29 2011
@@ -25,6 +25,15 @@
         self.buildDwarf()
         self.do_stop_at_outer_inline()
 
+    def setUp(self):
+        
+        # Call super's setUp().
+        TestBase.setUp(self)
+        # Find the line number to of function 'c'.
+        self.source = 'inlines.c'
+        self.first_stop = line_number(self.source, '// This should correspond to the first break stop.')
+        self.second_stop = line_number(self.source, '// This should correspond to the second break stop.')
+
     def do_stop_at_outer_inline(self):
         """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName()."""
         exe = os.path.join(os.getcwd(), "a.out")
@@ -33,8 +42,8 @@
         target = self.dbg.CreateTarget(exe)
         self.assertTrue(target, VALID_TARGET)
 
-        # Now create a breakpoint on main.c by name 'c'.
-        breakpoint = target.BreakpointCreateByName('outer_inline', 'a.out')
+        # Now create a breakpoint on main.c by the name of 'inner_inline'.
+        breakpoint = target.BreakpointCreateByName('inner_inline', 'a.out')
         #print "breakpoint:", breakpoint
         self.assertTrue(breakpoint and
                         breakpoint.GetNumLocations() > 1,
@@ -47,17 +56,35 @@
         self.assertTrue(process.GetState() == lldb.eStateStopped,
                         PROCESS_STOPPED)
 
-        self.runCmd("bt")
+        import lldbutil
+        stack_traces1 = lldbutil.print_stacktraces(process, string_buffer=True)
         if self.TraceOn():
-            print "Full stack traces when first stopped on the breakpoint 'outer_inline':"
-            import lldbutil
-            print lldbutil.print_stacktraces(process, string_buffer=True)
+            print "Full stack traces when first stopped on the breakpoint 'inner_inline':"
+            print stack_traces1
 
         # The first breakpoint should correspond to an inlined call frame.
+        # If it's an inlined call frame, expect to find, in the stack trace,
+        # that there is a frame which corresponds to the following call site:
+        #
+        #     outer_inline (argc);
+        #
         frame0 = process.GetThreadAtIndex(0).GetFrameAtIndex(0)
-        self.assertTrue(frame0.IsInlined() and
-                        frame0.GetFunctionName() == 'outer_inline')
-
+        if frame0.IsInlined():
+            filename = frame0.GetLineEntry().GetFileSpec().GetFilename()
+            self.assertTrue(filename == self.source)
+            self.expect(stack_traces1, "First stop at %s:%d" % (self.source, self.first_stop), exe=False,
+                        substrs = ['%s:%d' % (self.source, self.first_stop)])
+
+            # Expect to break again for the second time.
+            process.Continue()
+            self.assertTrue(process.GetState() == lldb.eStateStopped,
+                            PROCESS_STOPPED)
+            stack_traces2 = lldbutil.print_stacktraces(process, string_buffer=True)
+            if self.TraceOn():
+                print "Full stack traces when stopped on the breakpoint 'inner_inline' for the second time:"
+                print stack_traces2
+                self.expect(stack_traces2, "Second stop at %s:%d" % (self.source, self.second_stop), exe=False,
+                            substrs = ['%s:%d' % (self.source, self.second_stop)])
 
 if __name__ == '__main__':
     import atexit

Modified: lldb/trunk/test/python_api/frame/inlines/inlines.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/inlines/inlines.c?rev=135100&r1=135099&r2=135100&view=diff
==============================================================================
--- lldb/trunk/test/python_api/frame/inlines/inlines.c (original)
+++ lldb/trunk/test/python_api/frame/inlines/inlines.c Wed Jul 13 17:34:29 2011
@@ -43,9 +43,9 @@
   int (*func_ptr) (int);
   func_ptr = outer_inline;
 
-  outer_inline (argc);
+  outer_inline (argc); // This should correspond to the first break stop.
 
-  func_ptr (argc);
+  func_ptr (argc); // This should correspond to the second break stop.
 
   return 0;
 }





More information about the lldb-commits mailing list