summaryrefslogtreecommitdiffstats
path: root/lldb/examples/python/memory.py
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/examples/python/memory.py')
-rwxr-xr-xlldb/examples/python/memory.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/lldb/examples/python/memory.py b/lldb/examples/python/memory.py
index 5e2f636dc3e..cdc89fc811d 100755
--- a/lldb/examples/python/memory.py
+++ b/lldb/examples/python/memory.py
@@ -10,6 +10,8 @@
#----------------------------------------------------------------------
import commands
+from __future__ import print_function
+
import platform
import os
import re
@@ -44,11 +46,11 @@ except ImportError:
except ImportError:
pass
else:
- print 'imported lldb from: "%s"' % (lldb_python_dir)
+ print('imported lldb from: "%s"' % (lldb_python_dir))
success = True
break
if not success:
- print "error: couldn't locate the 'lldb' module, please set PYTHONPATH correctly"
+ print("error: couldn't locate the 'lldb' module, please set PYTHONPATH correctly")
sys.exit(1)
import commands
@@ -197,9 +199,9 @@ def memfind_command(debugger, command, result, dict):
def print_error(str, show_usage, result):
- print >>result, str
+ print(str, file=result)
if show_usage:
- print >>result, create_memfind_options().format_help()
+ print(create_memfind_options().format_help(), file=result)
def memfind(target, options, args, result):
@@ -233,44 +235,44 @@ def memfind(target, options, args, result):
return
if not options.data:
- print >>result, 'error: no data specified to search for'
+ print('error: no data specified to search for', file=result)
return
if not target:
- print >>result, 'error: invalid target'
+ print('error: invalid target', file=result)
return
process = target.process
if not process:
- print >>result, 'error: invalid process'
+ print('error: invalid process', file=result)
return
error = lldb.SBError()
bytes = process.ReadMemory(start_addr, options.size, error)
if error.Success():
num_matches = 0
- print >>result, "Searching memory range [%#x - %#x) for" % (
- start_addr, end_addr),
+ print("Searching memory range [%#x - %#x) for" % (
+ start_addr, end_addr), end=' ', file=result)
for byte in options.data:
- print >>result, '%2.2x' % ord(byte),
- print >>result
+ print('%2.2x' % ord(byte), end=' ', file=result)
+ print(file=result)
match_index = string.find(bytes, options.data)
while match_index != -1:
num_matches = num_matches + 1
- print >>result, '%#x: %#x + %u' % (start_addr +
- match_index, start_addr, match_index)
+ print('%#x: %#x + %u' % (start_addr +
+ match_index, start_addr, match_index), file=result)
match_index = string.find(bytes, options.data, match_index + 1)
if num_matches == 0:
- print >>result, "error: no matches found"
+ print("error: no matches found", file=result)
else:
- print >>result, 'error: %s' % (error.GetCString())
+ print('error: %s' % (error.GetCString()), file=result)
if __name__ == '__main__':
- print 'error: this script is designed to be used within the embedded script interpreter in LLDB'
+ print('error: this script is designed to be used within the embedded script interpreter in LLDB')
elif getattr(lldb, 'debugger', None):
memfind_command.__doc__ = create_memfind_options().format_help()
lldb.debugger.HandleCommand(
'command script add -f memory.memfind_command memfind')
- print '"memfind" command installed, use the "--help" option for detailed help'
+ print('"memfind" command installed, use the "--help" option for detailed help')
OpenPOWER on IntegriCloud