diff options
Diffstat (limited to 'lldb/utils')
-rwxr-xr-x | lldb/utils/git-svn/convert.py | 12 | ||||
-rw-r--r-- | lldb/utils/lui/lldbutil.py | 38 | ||||
-rwxr-xr-x | lldb/utils/lui/lui.py | 2 | ||||
-rwxr-xr-x | lldb/utils/misc/grep-svn-log.py | 11 | ||||
-rw-r--r-- | lldb/utils/sync-source/lib/transfer/rsync.py | 2 | ||||
-rw-r--r-- | lldb/utils/sync-source/syncsource.py | 4 | ||||
-rwxr-xr-x | lldb/utils/test/disasm.py | 18 | ||||
-rwxr-xr-x | lldb/utils/test/lldb-disasm.py | 44 | ||||
-rwxr-xr-x | lldb/utils/test/llvm-mc-shell.py | 6 | ||||
-rwxr-xr-x | lldb/utils/test/ras.py | 4 | ||||
-rwxr-xr-x | lldb/utils/test/run-dis.py | 12 | ||||
-rwxr-xr-x | lldb/utils/test/run-until-faulted.py | 10 | ||||
-rw-r--r-- | lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py | 8 | ||||
-rw-r--r-- | lldb/utils/vim-lldb/python-vim-lldb/vim_ui.py | 6 |
14 files changed, 99 insertions, 78 deletions
diff --git a/lldb/utils/git-svn/convert.py b/lldb/utils/git-svn/convert.py index 589522c78b3..7f149ec0978 100755 --- a/lldb/utils/git-svn/convert.py +++ b/lldb/utils/git-svn/convert.py @@ -11,6 +11,8 @@ Usage: 4. git svn dcommit [--commit-url https://id@llvm.org/svn/llvm-project/lldb/trunk] """ +from __future__ import print_function + import os import re import sys @@ -19,8 +21,8 @@ import StringIO def usage(problem_file=None): if problem_file: - print "%s is not a file" % problem_file - print "Usage: convert.py raw-message-source [raw-message-source2 ...]" + print("%s is not a file" % problem_file) + print("Usage: convert.py raw-message-source [raw-message-source2 ...]") sys.exit(0) @@ -29,7 +31,7 @@ def do_convert(file): Then for each line ('From: ' header included), replace the dos style CRLF end-of-line with unix style LF end-of-line. """ - print "converting %s ..." % file + print("converting %s ..." % file) with open(file, 'r') as f_in: content = f_in.read() @@ -50,12 +52,12 @@ def do_convert(file): else: from_header_seen = True - print >> new_content, line + print(line, file=new_content) with open(file, 'w') as f_out: f_out.write(new_content.getvalue()) - print "done" + print("done") def main(): diff --git a/lldb/utils/lui/lldbutil.py b/lldb/utils/lui/lldbutil.py index 80d581c766d..77b8cac8d72 100644 --- a/lldb/utils/lui/lldbutil.py +++ b/lldb/utils/lui/lldbutil.py @@ -12,6 +12,8 @@ Some of the test suite takes advantage of the utility functions defined here. They can also be useful for general purpose lldb scripting. """ +from __future__ import print_function + import lldb import os import sys @@ -53,7 +55,7 @@ def disassemble(target, function_or_symbol): buf = StringIO.StringIO() insts = function_or_symbol.GetInstructions(target) for i in insts: - print >> buf, i + print(i, file=buf) return buf.getvalue() # ========================================================== @@ -790,8 +792,8 @@ def print_stacktrace(thread, string_buffer=False): desc = "stop reason=" + stop_reason_to_str(thread.GetStopReason()) else: desc = "" - print >> output, "Stack trace for thread id={0:#x} name={1} queue={2} ".format( - thread.GetThreadID(), thread.GetName(), thread.GetQueueName()) + desc + print("Stack trace for thread id={0:#x} name={1} queue={2} ".format( + thread.GetThreadID(), thread.GetName(), thread.GetQueueName()) + desc, file=output) for i in range(depth): frame = thread.GetFrameAtIndex(i) @@ -802,13 +804,13 @@ def print_stacktrace(thread, string_buffer=False): file_addr = addrs[i].GetFileAddress() 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) + print(" frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}".format( + num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset), file=output) else: - print >> output, " frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}".format( + print(" 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) if not frame.IsInlined() else '()') + frame, showFuncName=False) if not frame.IsInlined() else '()'), file=output) if string_buffer: return output.getvalue() @@ -819,10 +821,10 @@ def print_stacktraces(process, string_buffer=False): output = StringIO.StringIO() if string_buffer else sys.stdout - print >> output, "Stack traces for " + str(process) + print("Stack traces for " + str(process), file=output) for thread in process: - print >> output, print_stacktrace(thread, string_buffer=True) + print(print_stacktrace(thread, string_buffer=True), file=output) if string_buffer: return output.getvalue() @@ -879,18 +881,18 @@ def print_registers(frame, string_buffer=False): output = StringIO.StringIO() if string_buffer else sys.stdout - print >> output, "Register sets for " + str(frame) + print("Register sets for " + str(frame), file=output) registerSet = frame.GetRegisters() # Return type of SBValueList. - print >> output, "Frame registers (size of register set = %d):" % registerSet.GetSize( - ) + print("Frame registers (size of register set = %d):" % registerSet.GetSize( + ), file=output) for value in registerSet: #print >> output, value - print >> output, "%s (number of children = %d):" % ( - value.GetName(), value.GetNumChildren()) + print("%s (number of children = %d):" % ( + value.GetName(), value.GetNumChildren()), file=output) for child in value: - print >> output, "Name: %s, Value: %s" % ( - child.GetName(), child.GetValue()) + print("Name: %s, Value: %s" % ( + child.GetName(), child.GetValue()), file=output) if string_buffer: return output.getvalue() @@ -970,11 +972,11 @@ class BasicFormatter(object): val = value.GetValue() if val is None and value.GetNumChildren() > 0: val = "%s (location)" % value.GetLocation() - print >> output, "{indentation}({type}) {name} = {value}".format( + print("{indentation}({type}) {name} = {value}".format( indentation=' ' * indent, type=value.GetTypeName(), name=value.GetName(), - value=val) + value=val), file=output) return output.getvalue() diff --git a/lldb/utils/lui/lui.py b/lldb/utils/lui/lui.py index c7c38d7ea09..4f72b43d103 100755 --- a/lldb/utils/lui/lui.py +++ b/lldb/utils/lui/lui.py @@ -54,7 +54,7 @@ def handle_args(driver, argv): pid = int(options.pid) driver.attachProcess(ui, pid) except ValueError: - print "Error: expecting integer PID, got '%s'" % options.pid + print("Error: expecting integer PID, got '%s'" % options.pid) elif options.core is not None: if not os.path.exists(options.core): raise Exception( diff --git a/lldb/utils/misc/grep-svn-log.py b/lldb/utils/misc/grep-svn-log.py index 86cc3ef1742..2a9795e37be 100755 --- a/lldb/utils/misc/grep-svn-log.py +++ b/lldb/utils/misc/grep-svn-log.py @@ -8,6 +8,7 @@ Example: svn log -v | grep-svn-log.py '^ D.+why_are_you_missing.h$' """ +from __future__ import print_function import fileinput import re @@ -32,7 +33,7 @@ class Log(StringIO.StringIO): """Add a line to the content, if there is a previous line, commit it.""" global separator if self.prev_line is not None: - print >> self, self.prev_line + print(self.prev_line, file=self) self.prev_line = a_line self.separator_added = (a_line == separator) @@ -42,13 +43,13 @@ class Log(StringIO.StringIO): def reset(self): """Forget about the previous lines entered.""" - StringIO.StringIO.__init__(self) + io.StringIO.__init__(self) self.prev_line = None def finish(self): """Call this when you're finished with populating content.""" if self.prev_line is not None: - print >> self, self.prev_line + print(self.prev_line, file=self) self.prev_line = None @@ -70,7 +71,7 @@ def grep(regexp): # is encountered. At which point, we can return the log content. if line == separator: log.finish() - print log.getvalue() + print(log.getvalue()) return log.add_line(line) @@ -85,7 +86,7 @@ def grep(regexp): def main(): if len(sys.argv) != 2: - print usage + print(usage) sys.exit(0) regexp = re.compile(sys.argv[1]) diff --git a/lldb/utils/sync-source/lib/transfer/rsync.py b/lldb/utils/sync-source/lib/transfer/rsync.py index 8269fada676..b90d108fca4 100644 --- a/lldb/utils/sync-source/lib/transfer/rsync.py +++ b/lldb/utils/sync-source/lib/transfer/rsync.py @@ -54,7 +54,7 @@ class RsyncOverSsh(transfer.protocol.Protocol): for spec in transfer_specs: cmd = self.build_rsync_command(spec, dry_run) if self.options.verbose: - print "executing the following command:\n{}".format(cmd) + print("executing the following command:\n{}".format(cmd)) result = subprocess.call( cmd, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr) if result != 0: diff --git a/lldb/utils/sync-source/syncsource.py b/lldb/utils/sync-source/syncsource.py index 16b60a40be6..66d7cd95bdf 100644 --- a/lldb/utils/sync-source/syncsource.py +++ b/lldb/utils/sync-source/syncsource.py @@ -148,7 +148,7 @@ def get_configuration(options, rcdata, config_name): def create_transfer_agent(options, configuration): transfer_class_spec = configuration.get_value("transfer_class") if options.verbose: - print "specified transfer class: '{}'".format(transfer_class_spec) + print("specified transfer class: '{}'".format(transfer_class_spec)) # Load the module (possibly package-qualified). components = transfer_class_spec.split(".") @@ -250,7 +250,7 @@ def main(): rc_filename = find_appropriate_rcfile(options) if rc_filename: if options.verbose: - print "reading rc data from file '{}'".format(rc_filename) + print("reading rc data from file '{}'".format(rc_filename)) rcdata = read_rcfile(rc_filename) else: sys.stderr.write("no rcfile specified, cannot guess configuration") diff --git a/lldb/utils/test/disasm.py b/lldb/utils/test/disasm.py index e75c070e011..fc1db1acd73 100755 --- a/lldb/utils/test/disasm.py +++ b/lldb/utils/test/disasm.py @@ -6,6 +6,8 @@ and display the disassembly result. """ +from __future__ import print_function + import os import sys from optparse import OptionParser @@ -107,7 +109,7 @@ def do_llvm_mc_disassembly( os.linesep)[-1].partition('>:')[2].strip() # print "\nbytes:", memory_dump disasm_str = prev_line.partition('>:')[2] - print >> mc_input, '%s # %s' % (memory_dump, disasm_str) + print('%s # %s' % (memory_dump, disasm_str), file=mc_input) # We're done with the processing. Assign the current line to be # prev_line. @@ -123,7 +125,7 @@ def do_llvm_mc_disassembly( f.write(mc_input.getvalue()) mc_cmd = '%s -disassemble %s disasm-input.txt' % (mc, mc_options) - print "\nExecuting command:", mc_cmd + print("\nExecuting command:", mc_cmd) os.system(mc_cmd) # And invoke llvm-mc with the just recorded file. @@ -217,12 +219,12 @@ Usage: %prog [options] llvm_mc_options = opts.llvm_mc_options # We have parsed the options. - print "gdb commands:", gdb_commands - print "gdb options:", gdb_options - print "executable:", executable - print "function:", function - print "llvm-mc:", llvm_mc - print "llvm-mc options:", llvm_mc_options + print("gdb commands:", gdb_commands) + print("gdb options:", gdb_options) + print("executable:", executable) + print("function:", function) + print("llvm-mc:", llvm_mc) + print("llvm-mc options:", llvm_mc_options) do_llvm_mc_disassembly( gdb_commands, diff --git a/lldb/utils/test/lldb-disasm.py b/lldb/utils/test/lldb-disasm.py index 1069bf477af..339e8e7caba 100755 --- a/lldb/utils/test/lldb-disasm.py +++ b/lldb/utils/test/lldb-disasm.py @@ -5,6 +5,8 @@ Run lldb to disassemble all the available functions for an executable image. """ +from __future__ import print_function + import os import re import sys @@ -18,7 +20,7 @@ def setupSysPath(): # Get the directory containing the current script. scriptPath = sys.path[0] if not scriptPath.endswith(os.path.join('utils', 'test')): - print "This script expects to reside in lldb's utils/test directory." + print("This script expects to reside in lldb's utils/test directory.") sys.exit(-1) # This is our base name component. @@ -63,8 +65,8 @@ def setupSysPath(): lldbPath = baiPath2 if not lldbPath: - print 'This script requires lldb.py to be in either ' + dbgPath + ',', - print relPath + ', or ' + baiPath + print('This script requires lldb.py to be in either ' + dbgPath + ',', end=' ') + print(relPath + ', or ' + baiPath) sys.exit(-1) # This is to locate the lldb.py module. Insert it right after sys.path[0]. @@ -74,15 +76,15 @@ def setupSysPath(): def run_command(ci, cmd, res, echo=True): if echo: - print "run command:", cmd + print("run command:", cmd) ci.HandleCommand(cmd, res) if res.Succeeded(): if echo: - print "run_command output:", res.GetOutput() + print("run_command output:", res.GetOutput()) else: if echo: - print "run command failed!" - print "run_command error:", res.GetError() + print("run command failed!") + print("run_command error:", res.GetError()) def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, @@ -135,7 +137,7 @@ def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, if symbols: for i in range(len(symbols)): if verbose: - print "symbol:", symbols[i] + print("symbol:", symbols[i]) yield symbols[i] else: limited = True if num != -1 else False @@ -146,7 +148,7 @@ def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, stream = lldb.SBStream() for m in target.module_iter(): if verbose: - print "module:", m + print("module:", m) for s in m: if limited and count >= num: return @@ -159,18 +161,18 @@ def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, # If we come here, we're ready to disassemble the symbol. if verbose: - print "symbol:", s.GetName() + print("symbol:", s.GetName()) if IsCodeType(s): if limited: count = count + 1 if verbose: - print "returning symbol:", s.GetName() + print("returning symbol:", s.GetName()) yield s.GetName() if verbose: - print "start address:", s.GetStartAddress() - print "end address:", s.GetEndAddress() + print("start address:", s.GetStartAddress()) + print("end address:", s.GetEndAddress()) s.GetDescription(stream) - print "symbol description:", stream.GetData() + print("symbol description:", stream.GetData()) stream.Clear() # Disassembly time. @@ -273,13 +275,13 @@ Usage: %prog [options] # We have parsed the options. if not quiet_disassembly: - print "lldb commands:", lldb_commands - print "executable:", executable - print "disassemble options:", disassemble_options - print "quiet disassembly output:", quiet_disassembly - print "num of symbols to disassemble:", num_symbols - print "symbols to disassemble:", symbols_to_disassemble - print "regular expression of symbols to disassemble:", re_symbol_pattern + print("lldb commands:", lldb_commands) + print("executable:", executable) + print("disassemble options:", disassemble_options) + print("quiet disassembly output:", quiet_disassembly) + print("num of symbols to disassemble:", num_symbols) + print("symbols to disassemble:", symbols_to_disassemble) + print("regular expression of symbols to disassemble:", re_symbol_pattern) setupSysPath() do_lldb_disassembly(lldb_commands, executable, disassemble_options, diff --git a/lldb/utils/test/llvm-mc-shell.py b/lldb/utils/test/llvm-mc-shell.py index 4d311959842..6adaf5dd3c5 100755 --- a/lldb/utils/test/llvm-mc-shell.py +++ b/lldb/utils/test/llvm-mc-shell.py @@ -5,6 +5,8 @@ Run llvm-mc interactively. """ +from __future__ import print_function + import os import sys from optparse import OptionParser @@ -105,8 +107,8 @@ Usage: %prog [options] llvm_mc_options = opts.llvm_mc_options # We have parsed the options. - print "llvm-mc:", llvm_mc - print "llvm-mc options:", llvm_mc_options + print("llvm-mc:", llvm_mc) + print("llvm-mc options:", llvm_mc_options) llvm_mc_loop(llvm_mc, llvm_mc_options) diff --git a/lldb/utils/test/ras.py b/lldb/utils/test/ras.py index 25b76bc1e07..1b7caecdb0f 100755 --- a/lldb/utils/test/ras.py +++ b/lldb/utils/test/ras.py @@ -7,6 +7,8 @@ The code for sending of the directory is copied from http://docs.python.org/library/email-examples.html. """ +from __future__ import print_function + import os import sys import shutil @@ -33,7 +35,7 @@ def runTestsuite(testDir, sessDir, envs=None): list = env.split('=') var = list[0].strip() val = list[1].strip() - print var + "=" + val + print(var + "=" + val) os.environ[var] = val import shlex diff --git a/lldb/utils/test/run-dis.py b/lldb/utils/test/run-dis.py index b635e8c62d8..5df65e85ba1 100755 --- a/lldb/utils/test/run-dis.py +++ b/lldb/utils/test/run-dis.py @@ -5,6 +5,8 @@ Run lldb disassembler on all the binaries specified by a combination of root dir and path pattern. """ +from __future__ import print_function + import os import sys import subprocess @@ -68,7 +70,7 @@ def walk_and_invoke(sdk_root, path_regexp, suffix, num_symbols): command = template % ( scriptPath, path, num_symbols if num_symbols > 0 else 1000) - print "Running %s" % (command) + print("Running %s" % (command)) os.system(command) @@ -130,10 +132,10 @@ and path pattern. suffix = opts.suffix num_symbols = opts.num_symbols - print "Root directory for SDK symbols:", root_dir - print "Regular expression for the binaries:", path_pattern - print "Suffix of the binaries to look for:", suffix - print "num of symbols to disassemble:", num_symbols + print("Root directory for SDK symbols:", root_dir) + print("Regular expression for the binaries:", path_pattern) + print("Suffix of the binaries to look for:", suffix) + print("num of symbols to disassemble:", num_symbols) walk_and_invoke(root_dir, path_regexp, suffix, num_symbols) diff --git a/lldb/utils/test/run-until-faulted.py b/lldb/utils/test/run-until-faulted.py index 794f4fc8478..a51dbb88e1c 100755 --- a/lldb/utils/test/run-until-faulted.py +++ b/lldb/utils/test/run-until-faulted.py @@ -5,6 +5,8 @@ Run a program via lldb until it fails. The lldb executable is located via your PATH env variable, if not specified. """ +from __future__ import print_function + import os import sys from optparse import OptionParser @@ -65,7 +67,7 @@ def do_lldb_launch_loop(lldb_command, exe, exe_options): break elif index == 2: # Something went wrong. - print "TIMEOUT occurred:", str(lldb) + print("TIMEOUT occurred:", str(lldb)) # Give control of lldb shell to the user. lldb.interact() @@ -120,9 +122,9 @@ The lldb executable is located via your PATH env variable, if not specified.\ exe_options = opts.exe_options # We have parsed the options. - print "lldb command:", lldb_command - print "executable:", exe - print "executable options:", exe_options + print("lldb command:", lldb_command) + print("executable:", exe) + print("executable options:", exe_options) do_lldb_launch_loop(lldb_command, exe, exe_options) diff --git a/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py b/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py index b36769f5a57..0e59cc5f4b7 100644 --- a/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py +++ b/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py @@ -3,6 +3,8 @@ # This file defines the layer that talks to lldb # +from __future__ import print_function + import os import re import sys @@ -164,7 +166,7 @@ class LLDBController(object): self.ui.activate() self.pid = self.process.GetProcessID() - print "Attached to %s (pid=%d)" % (process_name, self.pid) + print("Attached to %s (pid=%d)" % (process_name, self.pid)) def doDetach(self): if self.process is not None and self.process.IsValid(): @@ -196,7 +198,7 @@ class LLDBController(object): self.process.GetBroadcaster().AddListener( self.processListener, lldb.SBProcess.eBroadcastBitStateChanged) - print "Launched %s %s (pid=%d)" % (exe, args, self.pid) + print("Launched %s %s (pid=%d)" % (exe, args, self.pid)) if not stop_at_entry: self.doContinue() @@ -323,7 +325,7 @@ class LLDBController(object): if success: self.ui.update(self.target, "", self, goto_file) if len(output) > 0 and print_on_success: - print output + print(output) else: sys.stderr.write(output) diff --git a/lldb/utils/vim-lldb/python-vim-lldb/vim_ui.py b/lldb/utils/vim-lldb/python-vim-lldb/vim_ui.py index 33eb6650466..bc5b6a4f1ca 100644 --- a/lldb/utils/vim-lldb/python-vim-lldb/vim_ui.py +++ b/lldb/utils/vim-lldb/python-vim-lldb/vim_ui.py @@ -1,6 +1,8 @@ # LLDB UI state in the Vim user interface. +from __future__ import print_function + import os import re import sys @@ -143,7 +145,7 @@ class UI: if curname is not None and is_same_file(curname, fname): move_cursor(line, 0) elif move_cursor: - print "FIXME: not sure where to move cursor because %s != %s " % (vim.current.buffer.name, fname) + print("FIXME: not sure where to move cursor because %s != %s " % (vim.current.buffer.name, fname)) def update_breakpoints(self, target, buffers): """ Decorates buffer with signs corresponding to breakpoints in target. """ @@ -219,7 +221,7 @@ class UI: self.update_pc(process, self.get_user_buffers, goto_file) if status is not None and len(status) > 0: - print status + print(status) def haveBreakpoint(self, file, line): """ Returns True if we have a breakpoint at file:line, False otherwise """ |