[Lldb-commits] [lldb] r186122 - Tweaks to the Python reference and example command to use the preferred print style and the (finally available :-) SetError API
Enrico Granata
egranata at apple.com
Thu Jul 11 14:49:38 PDT 2013
Author: enrico
Date: Thu Jul 11 16:49:38 2013
New Revision: 186122
URL: http://llvm.org/viewvc/llvm-project?rev=186122&view=rev
Log:
Tweaks to the Python reference and example command to use the preferred print style and the (finally available :-) SetError API
Modified:
lldb/trunk/examples/python/cmdtemplate.py
lldb/trunk/www/python-reference.html
Modified: lldb/trunk/examples/python/cmdtemplate.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/cmdtemplate.py?rev=186122&r1=186121&r2=186122&view=diff
==============================================================================
--- lldb/trunk/examples/python/cmdtemplate.py (original)
+++ lldb/trunk/examples/python/cmdtemplate.py Thu Jul 11 16:49:38 2013
@@ -38,8 +38,8 @@ def the_framestats_command(debugger, com
except:
# if you don't handle exceptions, passing an incorrect argument to the OptionParser will cause LLDB to exit
# (courtesy of OptParse dealing with argument errors by throwing SystemExit)
- result.SetStatus (lldb.eReturnStatusFailed)
- return "option parsing failed" # returning a string is the same as returning an error whose description is the string
+ result.SetError ("option parsing failed")
+ return
# in a command - the lldb.* convenience variables are not to be used
# and their values (if any) are undefined
@@ -54,7 +54,7 @@ def the_framestats_command(debugger, com
variables_list = frame.GetVariables(options.arguments, options.locals, options.statics, options.inscope)
variables_count = variables_list.GetSize()
if variables_count == 0:
- result.PutCString("no variables here")
+ print >> result, "no variables here"
return
total_size = 0
for i in range(0,variables_count):
@@ -62,8 +62,8 @@ def the_framestats_command(debugger, com
variable_type = variable.GetType()
total_size = total_size + variable_type.GetByteSize()
average_size = float(total_size) / variables_count
- result.PutCString("Your frame has %d variables. Their total size is %d bytes. The average size is %f bytes" % (variables_count,total_size,average_size))
- # not returning anything is askin to returning success
+ print >>result, "Your frame has %d variables. Their total size is %d bytes. The average size is %f bytes" % (variables_count,total_size,average_size)
+ # not returning anything is akin to returning success
def __lldb_init_module (debugger, dict):
# This initializer is being run from LLDB in the embedded command interpreter
Modified: lldb/trunk/www/python-reference.html
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/python-reference.html?rev=186122&r1=186121&r2=186122&view=diff
==============================================================================
--- lldb/trunk/www/python-reference.html (original)
+++ lldb/trunk/www/python-reference.html Thu Jul 11 16:49:38 2013
@@ -437,7 +437,7 @@ import optparse
import shlex
def ls(debugger, command, result, internal_dict):
- result.PutCString(commands.getoutput('/bin/ls %s' % command))
+ print >>result, (commands.getoutput('/bin/ls %s' % command))
<font color=green># And the initialization code to add your commands </font>
def __lldb_init_module(debugger, internal_dict):
More information about the lldb-commits
mailing list