[Lldb-commits] [lldb] r133204 - in /lldb/trunk/test: lldbutil.py python_api/lldbutil/frame/TestFrameUtils.py python_api/lldbutil/process/TestPrintStackTraces.py

Johnny Chen johnny.chen at apple.com
Thu Jun 16 15:07:48 PDT 2011


Author: johnny
Date: Thu Jun 16 17:07:48 2011
New Revision: 133204

URL: http://llvm.org/viewvc/llvm-project?rev=133204&view=rev
Log:
o lldbutil.py:

  For the print_stacktrace(thread, string_buffer = False) function, if we have debug info
  for a frame function, let's also emit the args for the current function.

o TestFrameUtils.py:

  Add stronger assertTrue for frame0's args.

o TestPrintStackTraces.py:

  Launch the inferior with ["abc", "xyz"] and expect '(int)argc=3' in the stack traces, since
  by design the inferior is built with debug info.

Modified:
    lldb/trunk/test/lldbutil.py
    lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py
    lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py

Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=133204&r1=133203&r2=133204&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Thu Jun 16 17:07:48 2011
@@ -387,11 +387,14 @@
         load_addr = addrs[i].GetLoadAddress(target)
         if not function:
             file_addr = addrs[i].GetFileAddress()
-            print >> output, "  frame #{num}: {addr:#016x} {mod}`{symbol} + ????".format(
-                num=i, addr=load_addr, mod=mods[i], symbol=symbols[i])
+            start_addr = frame.GetSymbol().GetStartAddress().GetFileAddress()
+            symbol_offset = file_addr - start_addr
+            print >> output, "  frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}".format(
+                num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset)
         else:
-            print >> output, "  frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line}".format(
-                num=i, addr=load_addr, mod=mods[i], func=funcs[i], file=files[i], line=lines[i])
+            print >> output, "  frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}".format(
+                num=i, addr=load_addr, mod=mods[i], func=funcs[i], file=files[i], line=lines[i],
+                args=get_args_as_string(frame, showFuncName=False))
 
     if string_buffer:
         return output.getvalue()
@@ -429,7 +432,7 @@
     # If we reach here, no parent has been found, return None.
     return None
 
-def get_args_as_string(frame):
+def get_args_as_string(frame, showFuncName=True):
     """
     Returns the args of the input frame object as a string.
     """
@@ -449,8 +452,11 @@
         name = frame.GetSymbol().GetName()
     else:
         name = ""
-    return "%s(%s)" % (name, ", ".join(args))
-
+    if showFuncName:
+        return "%s(%s)" % (name, ", ".join(args))
+    else:
+        return "(%s)" % (", ".join(args))
+        
 def print_registers(frame, string_buffer = False):
     """Prints all the register sets of the frame."""
 

Modified: lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py?rev=133204&r1=133203&r2=133204&view=diff
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py (original)
+++ lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py Thu Jun 16 17:07:48 2011
@@ -48,7 +48,7 @@
         self.assertTrue(parent and parent.GetFrameID() == frame1.GetFrameID())
         frame0_args = lldbutil.get_args_as_string(frame0)
         parent_args = lldbutil.get_args_as_string(parent)
-        self.assertTrue(frame0_args and parent_args)
+        self.assertTrue(frame0_args and parent_args and "(int)val=1" in frame0_args)
         if self.TraceOn():
             lldbutil.print_stacktrace(thread)
             print "Current frame: %s" % frame0_args

Modified: lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py?rev=133204&r1=133203&r2=133204&view=diff
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py (original)
+++ lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py Thu Jun 16 17:07:48 2011
@@ -35,7 +35,7 @@
 
         # Now launch the process, and do not stop at entry point.
         rc = lldb.SBError()
-        process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc)
+        process = target.Launch (self.dbg.GetListener(), ["abc", "xyz"], None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc)
 
         if not rc.Success() or not process:
             self.fail("SBTarget.LaunchProcess() failed")
@@ -46,8 +46,9 @@
                       "instead the actual state is: '%s'" %
                       lldbutil.state_type_to_str(process.GetState()))
 
-        if self.TraceOn():
-            lldbutil.print_stacktraces(process)
+        stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
+        self.expect(stacktraces, exe=False,
+            substrs = ['(int)argc=3'])
 
 
 if __name__ == '__main__':





More information about the lldb-commits mailing list