summaryrefslogtreecommitdiffstats
path: root/lldb/utils/test/disasm.py
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/utils/test/disasm.py
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadbcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/utils/test/disasm.py')
-rwxr-xr-xlldb/utils/test/disasm.py92
1 files changed, 65 insertions, 27 deletions
diff --git a/lldb/utils/test/disasm.py b/lldb/utils/test/disasm.py
index 46660299f18..e75c070e011 100755
--- a/lldb/utils/test/disasm.py
+++ b/lldb/utils/test/disasm.py
@@ -10,10 +10,12 @@ import os
import sys
from optparse import OptionParser
+
def is_exe(fpath):
"""Check whether fpath is an executable."""
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
+
def which(program):
"""Find the full path to a program, or return None."""
fpath, fname = os.path.split(program)
@@ -27,8 +29,15 @@ def which(program):
return exe_file
return None
-def do_llvm_mc_disassembly(gdb_commands, gdb_options, exe, func, mc, mc_options):
- from cStringIO import StringIO
+
+def do_llvm_mc_disassembly(
+ gdb_commands,
+ gdb_options,
+ exe,
+ func,
+ mc,
+ mc_options):
+ from cStringIO import StringIO
import pexpect
gdb_prompt = "\r\n\(gdb\) "
@@ -37,7 +46,8 @@ def do_llvm_mc_disassembly(gdb_commands, gdb_options, exe, func, mc, mc_options)
gdb.logfile_read = sys.stdout
gdb.expect(gdb_prompt)
- # See if there any extra command(s) to execute before we issue the file command.
+ # See if there any extra command(s) to execute before we issue the file
+ # command.
for cmd in gdb_commands:
gdb.sendline(cmd)
gdb.expect(gdb_prompt)
@@ -93,12 +103,14 @@ def do_llvm_mc_disassembly(gdb_commands, gdb_options, exe, func, mc, mc_options)
# Get the last output line from the gdb examine memory command,
# split the string into a 3-tuple with separator '>:' to handle
# objc method names.
- memory_dump = x_output.split(os.linesep)[-1].partition('>:')[2].strip()
- #print "\nbytes:", memory_dump
+ memory_dump = x_output.split(
+ 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)
- # We're done with the processing. Assign the current line to be prev_line.
+ # We're done with the processing. Assign the current line to be
+ # prev_line.
prev_line = line
# Close the gdb session now that we are done with it.
@@ -117,15 +129,21 @@ def do_llvm_mc_disassembly(gdb_commands, gdb_options, exe, func, mc, mc_options)
# And invoke llvm-mc with the just recorded file.
#mc = pexpect.spawn('%s -disassemble %s disasm-input.txt' % (mc, mc_options))
#mc.logfile_read = sys.stdout
- #print "mc:", mc
- #mc.close()
-
+ # print "mc:", mc
+ # mc.close()
+
def main():
# This is to set up the Python path to include the pexpect-2.4 dir.
# Remember to update this when/if things change.
scriptPath = sys.path[0]
- sys.path.append(os.path.join(scriptPath, os.pardir, os.pardir, 'test', 'pexpect-2.4'))
+ sys.path.append(
+ os.path.join(
+ scriptPath,
+ os.pardir,
+ os.pardir,
+ 'test',
+ 'pexpect-2.4'))
parser = OptionParser(usage="""\
Run gdb to disassemble a function, feed the bytes to 'llvm-mc -disassemble' command,
@@ -133,32 +151,46 @@ and display the disassembly result.
Usage: %prog [options]
""")
- parser.add_option('-C', '--gdb-command',
- type='string', action='append', metavar='COMMAND',
- default=[], dest='gdb_commands',
- help='Command(s) gdb executes after starting up (can be empty)')
- parser.add_option('-O', '--gdb-options',
- type='string', action='store',
- dest='gdb_options',
- help="""The options passed to 'gdb' command if specified.""")
+ parser.add_option(
+ '-C',
+ '--gdb-command',
+ type='string',
+ action='append',
+ metavar='COMMAND',
+ default=[],
+ dest='gdb_commands',
+ help='Command(s) gdb executes after starting up (can be empty)')
+ parser.add_option(
+ '-O',
+ '--gdb-options',
+ type='string',
+ action='store',
+ dest='gdb_options',
+ help="""The options passed to 'gdb' command if specified.""")
parser.add_option('-e', '--executable',
type='string', action='store',
dest='executable',
help="""The executable to do disassembly on.""")
- parser.add_option('-f', '--function',
- type='string', action='store',
- dest='function',
- help="""The function name (could be an address to gdb) for disassembly.""")
+ parser.add_option(
+ '-f',
+ '--function',
+ type='string',
+ action='store',
+ dest='function',
+ help="""The function name (could be an address to gdb) for disassembly.""")
parser.add_option('-m', '--llvm-mc',
type='string', action='store',
dest='llvm_mc',
help="""The llvm-mc executable full path, if specified.
Otherwise, it must be present in your PATH environment.""")
- parser.add_option('-o', '--options',
- type='string', action='store',
- dest='llvm_mc_options',
- help="""The options passed to 'llvm-mc -disassemble' command if specified.""")
+ parser.add_option(
+ '-o',
+ '--options',
+ type='string',
+ action='store',
+ dest='llvm_mc_options',
+ help="""The options passed to 'llvm-mc -disassemble' command if specified.""")
opts, args = parser.parse_args()
@@ -192,7 +224,13 @@ Usage: %prog [options]
print "llvm-mc:", llvm_mc
print "llvm-mc options:", llvm_mc_options
- do_llvm_mc_disassembly(gdb_commands, gdb_options, executable, function, llvm_mc, llvm_mc_options)
+ do_llvm_mc_disassembly(
+ gdb_commands,
+ gdb_options,
+ executable,
+ function,
+ llvm_mc,
+ llvm_mc_options)
if __name__ == '__main__':
main()
OpenPOWER on IntegriCloud