[Lldb-commits] [lldb] r115960 - /lldb/trunk/test/lldbutil.py
Johnny Chen
johnny.chen at apple.com
Thu Oct 7 11:52:48 PDT 2010
Author: johnny
Date: Thu Oct 7 13:52:48 2010
New Revision: 115960
URL: http://llvm.org/viewvc/llvm-project?rev=115960&view=rev
Log:
Add a keyword argument string_buffer (with a default value of False) to the
PrintStackTrace(thread) function. If string_buffer is True, PrintStackTrace()
will return the content of the stack trace as a string, instead.
Modified:
lldb/trunk/test/lldbutil.py
Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=115960&r1=115959&r2=115960&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Thu Oct 7 13:52:48 2010
@@ -3,6 +3,8 @@
"""
import lldb
+import sys
+import StringIO
def GetFunctionNames(thread):
"""
@@ -54,8 +56,9 @@
return map(GetStackFrame, range(thread.GetNumFrames()))
-def PrintStackTrace(thread):
+def PrintStackTrace(thread, string_buffer = False):
"""Prints a simple stack trace of this thread."""
+
depth = thread.GetNumFrames()
mods = GetModuleNames(thread)
@@ -63,11 +66,16 @@
files = GetFilenames(thread)
lines = GetLineNumbers(thread)
- print "Stack trace for thread id={0:#x} name={1} queue={2}:".format(
+ output = StringIO.StringIO() if string_buffer else sys.stdout
+
+ print >> output, "Stack trace for thread id={0:#x} name={1} queue={2}:".format(
thread.GetThreadID(), thread.GetName(), thread.GetQueueName())
for i in range(depth - 1):
- print " frame #{num}: {mod}`{func} at {file}:{line}".format(
+ print >> output, " frame #{num}: {mod}`{func} at {file}:{line}".format(
num=i, mod=mods[i], func=funcs[i], file=files[i], line=lines[i])
- print " frame #{num}: {mod}`start".format(num=depth-1, mod=mods[depth-1])
+ print >> output, " frame #{num}: {mod}`start".format(num=depth-1, mod=mods[depth-1])
+
+ if string_buffer:
+ return output.getvalue()
More information about the lldb-commits
mailing list