aboutsummaryrefslogtreecommitdiff
path: root/lldb/utils/test
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/utils/test')
-rwxr-xr-xlldb/utils/test/disasm.py92
-rwxr-xr-xlldb/utils/test/lldb-disasm.py135
-rwxr-xr-xlldb/utils/test/llvm-mc-shell.py26
-rw-r--r--lldb/utils/test/main.c19
-rwxr-xr-xlldb/utils/test/ras.py18
-rwxr-xr-xlldb/utils/test/run-dis.py51
-rwxr-xr-xlldb/utils/test/run-until-faulted.py51
7 files changed, 266 insertions, 126 deletions
diff --git a/lldb/utils/test/disasm.py b/lldb/utils/test/disasm.py
index 4666029..e75c070 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()
diff --git a/lldb/utils/test/lldb-disasm.py b/lldb/utils/test/lldb-disasm.py
index 7987c6b..1069bf4 100755
--- a/lldb/utils/test/lldb-disasm.py
+++ b/lldb/utils/test/lldb-disasm.py
@@ -10,6 +10,7 @@ import re
import sys
from optparse import OptionParser
+
def setupSysPath():
"""
Add LLDB.framework/Resources/Python and the test dir to the sys.path.
@@ -24,7 +25,7 @@ def setupSysPath():
base = os.path.abspath(os.path.join(scriptPath, os.pardir, os.pardir))
# This is for the goodies in the test directory under base.
- sys.path.append(os.path.join(base,'test'))
+ sys.path.append(os.path.join(base, 'test'))
# These are for xcode build directories.
xcode3_build_dir = ['build']
@@ -34,12 +35,18 @@ def setupSysPath():
bai = ['BuildAndIntegration']
python_resource_dir = ['LLDB.framework', 'Resources', 'Python']
- dbgPath = os.path.join(base, *(xcode3_build_dir + dbg + python_resource_dir))
- dbgPath2 = os.path.join(base, *(xcode4_build_dir + dbg + python_resource_dir))
- relPath = os.path.join(base, *(xcode3_build_dir + rel + python_resource_dir))
- relPath2 = os.path.join(base, *(xcode4_build_dir + rel + python_resource_dir))
- baiPath = os.path.join(base, *(xcode3_build_dir + bai + python_resource_dir))
- baiPath2 = os.path.join(base, *(xcode4_build_dir + bai + python_resource_dir))
+ dbgPath = os.path.join(
+ base, *(xcode3_build_dir + dbg + python_resource_dir))
+ dbgPath2 = os.path.join(
+ base, *(xcode4_build_dir + dbg + python_resource_dir))
+ relPath = os.path.join(
+ base, *(xcode3_build_dir + rel + python_resource_dir))
+ relPath2 = os.path.join(
+ base, *(xcode4_build_dir + rel + python_resource_dir))
+ baiPath = os.path.join(
+ base, *(xcode3_build_dir + bai + python_resource_dir))
+ baiPath2 = os.path.join(
+ base, *(xcode4_build_dir + bai + python_resource_dir))
lldbPath = None
if os.path.isfile(os.path.join(dbgPath, 'lldb.py')):
@@ -62,7 +69,7 @@ def setupSysPath():
# This is to locate the lldb.py module. Insert it right after sys.path[0].
sys.path[1:1] = [lldbPath]
- #print "sys.path:", sys.path
+ # print "sys.path:", sys.path
def run_command(ci, cmd, res, echo=True):
@@ -77,16 +84,19 @@ def run_command(ci, cmd, res, echo=True):
print "run command failed!"
print "run_command error:", res.GetError()
+
def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols,
symbols_to_disassemble,
re_symbol_pattern,
quiet_disassembly):
- import lldb, atexit, re
+ import lldb
+ import atexit
+ import re
# Create the debugger instance now.
dbg = lldb.SBDebugger.Create()
if not dbg:
- raise Exception('Invalid debugger instance')
+ raise Exception('Invalid debugger instance')
# Register an exit callback.
atexit.register(lambda: lldb.SBDebugger.Terminate())
@@ -102,7 +112,8 @@ def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols,
# And the associated result object.
res = lldb.SBCommandReturnObject()
- # 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 lldb_commands:
run_command(ci, cmd, res, not quiet_disassembly)
@@ -141,7 +152,8 @@ def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols,
return
# If a regexp symbol pattern is supplied, consult it.
if re_symbol_pattern:
- # If the pattern does not match, look for the next symbol.
+ # If the pattern does not match, look for the next
+ # symbol.
if not pattern.match(s.GetName()):
continue
@@ -162,7 +174,12 @@ def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols,
stream.Clear()
# Disassembly time.
- for symbol in symbol_iter(num_symbols, symbols_to_disassemble, re_symbol_pattern, target, not quiet_disassembly):
+ for symbol in symbol_iter(
+ num_symbols,
+ symbols_to_disassemble,
+ re_symbol_pattern,
+ target,
+ not quiet_disassembly):
cmd = "disassemble %s '%s'" % (disassemble_options, symbol)
run_command(ci, cmd, res, not quiet_disassembly)
@@ -171,42 +188,74 @@ 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 lldb to disassemble all the available functions for an executable image.
Usage: %prog [options]
""")
- parser.add_option('-C', '--lldb-command',
- type='string', action='append', metavar='COMMAND',
- default=[], dest='lldb_commands',
- help='Command(s) lldb executes after starting up (can be empty)')
- parser.add_option('-e', '--executable',
- type='string', action='store',
- dest='executable',
- help="""Mandatory: the executable to do disassembly on.""")
- parser.add_option('-o', '--options',
- type='string', action='store',
- dest='disassemble_options',
- help="""Mandatory: the options passed to lldb's 'disassemble' command.""")
- parser.add_option('-q', '--quiet-disassembly',
- action='store_true', default=False,
- dest='quiet_disassembly',
- help="""The symbol(s) to invoke lldb's 'disassemble' command on, if specified.""")
- parser.add_option('-n', '--num-symbols',
- type='int', action='store', default=-1,
- dest='num_symbols',
- help="""The number of symbols to disassemble, if specified.""")
- parser.add_option('-p', '--symbol_pattern',
- type='string', action='store',
- dest='re_symbol_pattern',
- help="""The regular expression of symbols to invoke lldb's 'disassemble' command.""")
- parser.add_option('-s', '--symbol',
- type='string', action='append', metavar='SYMBOL', default=[],
- dest='symbols_to_disassemble',
- help="""The symbol(s) to invoke lldb's 'disassemble' command on, if specified.""")
-
+ parser.add_option(
+ '-C',
+ '--lldb-command',
+ type='string',
+ action='append',
+ metavar='COMMAND',
+ default=[],
+ dest='lldb_commands',
+ help='Command(s) lldb executes after starting up (can be empty)')
+ parser.add_option(
+ '-e',
+ '--executable',
+ type='string',
+ action='store',
+ dest='executable',
+ help="""Mandatory: the executable to do disassembly on.""")
+ parser.add_option(
+ '-o',
+ '--options',
+ type='string',
+ action='store',
+ dest='disassemble_options',
+ help="""Mandatory: the options passed to lldb's 'disassemble' command.""")
+ parser.add_option(
+ '-q',
+ '--quiet-disassembly',
+ action='store_true',
+ default=False,
+ dest='quiet_disassembly',
+ help="""The symbol(s) to invoke lldb's 'disassemble' command on, if specified.""")
+ parser.add_option(
+ '-n',
+ '--num-symbols',
+ type='int',
+ action='store',
+ default=-1,
+ dest='num_symbols',
+ help="""The number of symbols to disassemble, if specified.""")
+ parser.add_option(
+ '-p',
+ '--symbol_pattern',
+ type='string',
+ action='store',
+ dest='re_symbol_pattern',
+ help="""The regular expression of symbols to invoke lldb's 'disassemble' command.""")
+ parser.add_option(
+ '-s',
+ '--symbol',
+ type='string',
+ action='append',
+ metavar='SYMBOL',
+ default=[],
+ dest='symbols_to_disassemble',
+ help="""The symbol(s) to invoke lldb's 'disassemble' command on, if specified.""")
+
opts, args = parser.parse_args()
lldb_commands = opts.lldb_commands
diff --git a/lldb/utils/test/llvm-mc-shell.py b/lldb/utils/test/llvm-mc-shell.py
index 38c1299..4d31195 100755
--- a/lldb/utils/test/llvm-mc-shell.py
+++ b/lldb/utils/test/llvm-mc-shell.py
@@ -9,10 +9,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)
@@ -26,10 +28,12 @@ def which(program):
return exe_file
return None
+
def llvm_mc_loop(mc, mc_options):
contents = []
fname = 'mc-input.txt'
- sys.stdout.write("Enter your input to llvm-mc. A line starting with 'END' terminates the current batch of input.\n")
+ sys.stdout.write(
+ "Enter your input to llvm-mc. A line starting with 'END' terminates the current batch of input.\n")
sys.stdout.write("Enter 'quit' or Ctrl-D to quit the program.\n")
while True:
sys.stdout.write("> ")
@@ -54,11 +58,18 @@ def llvm_mc_loop(mc, mc_options):
# Keep accumulating our input.
contents.append(next)
+
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="""\
Do llvm-mc interactively within a shell-like environment. A batch of input is
@@ -74,10 +85,13 @@ Usage: %prog [options]
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' command if specified.""")
+ parser.add_option(
+ '-o',
+ '--options',
+ type='string',
+ action='store',
+ dest='llvm_mc_options',
+ help="""The options passed to 'llvm-mc' command if specified.""")
opts, args = parser.parse_args()
diff --git a/lldb/utils/test/main.c b/lldb/utils/test/main.c
index c0fe2f2..c0f6009 100644
--- a/lldb/utils/test/main.c
+++ b/lldb/utils/test/main.c
@@ -1,14 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
-int main(int argc, const char* argv[])
-{
- int *null_ptr = 0;
- printf("Hello, fault!\n");
- u_int32_t val = (arc4random() & 0x0f);
- printf("val=%u\n", val);
- if (val == 0x07) // Lucky 7 :-)
- printf("Now segfault %d\n", *null_ptr);
- else
- printf("Better luck next time!\n");
+int main(int argc, const char *argv[]) {
+ int *null_ptr = 0;
+ printf("Hello, fault!\n");
+ u_int32_t val = (arc4random() & 0x0f);
+ printf("val=%u\n", val);
+ if (val == 0x07) // Lucky 7 :-)
+ printf("Now segfault %d\n", *null_ptr);
+ else
+ printf("Better luck next time!\n");
}
diff --git a/lldb/utils/test/ras.py b/lldb/utils/test/ras.py
index a89cbae..25b76bc1 100755
--- a/lldb/utils/test/ras.py
+++ b/lldb/utils/test/ras.py
@@ -24,7 +24,8 @@ from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
-def runTestsuite(testDir, sessDir, envs = None):
+
+def runTestsuite(testDir, sessDir, envs=None):
"""Run the testsuite and return a (summary, output) tuple."""
os.chdir(testDir)
@@ -35,7 +36,8 @@ def runTestsuite(testDir, sessDir, envs = None):
print var + "=" + val
os.environ[var] = val
- import shlex, subprocess
+ import shlex
+ import subprocess
command_line = "./dotest.py -w -s %s" % sessDir
# Apply correct tokenization for subprocess.Popen().
@@ -46,7 +48,7 @@ def runTestsuite(testDir, sessDir, envs = None):
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Wait for subprocess to terminate.
stdout, stderr = process.communicate()
-
+
# This will be used as the subject line of our email about this test.
cmd = "%s %s" % (' '.join(envs) if envs else "", command_line)
@@ -55,6 +57,7 @@ def runTestsuite(testDir, sessDir, envs = None):
COMMASPACE = ', '
+
def main():
parser = OptionParser(usage="""\
Run lldb test suite and send the results as a MIME message.
@@ -103,7 +106,7 @@ SMTP server, which then does the normal delivery process.
sessDir = 'tmp-lldb-session'
if os.path.exists(sessDir):
shutil.rmtree(sessDir)
- #print "environments:", opts.environments
+ # print "environments:", opts.environments
summary, output = runTestsuite(testDir, sessDir, opts.environments)
# Create the enclosing (outer) message
@@ -119,9 +122,10 @@ SMTP server, which then does the normal delivery process.
if not os.path.exists(sessDir):
outer.attach(MIMEText(output, 'plain'))
else:
- outer.attach(MIMEText("%s\n%s\n\n" % (output,
- "Session logs of test failures/errors:"),
- 'plain'))
+ outer.attach(
+ MIMEText(
+ "%s\n%s\n\n" %
+ (output, "Session logs of test failures/errors:"), 'plain'))
for filename in (os.listdir(sessDir) if os.path.exists(sessDir) else []):
path = os.path.join(sessDir, filename)
diff --git a/lldb/utils/test/run-dis.py b/lldb/utils/test/run-dis.py
index a243794..b635e8c 100755
--- a/lldb/utils/test/run-dis.py
+++ b/lldb/utils/test/run-dis.py
@@ -5,7 +5,9 @@ Run lldb disassembler on all the binaries specified by a combination of root dir
and path pattern.
"""
-import os, sys, subprocess
+import os
+import sys
+import subprocess
import re
from optparse import OptionParser
@@ -29,11 +31,14 @@ template = '%s/lldb-disasm.py -C "platform select remote-ios" -o "-n" -q -e %s -
# Regular expression for detecting file output for Mach-o binary.
mach_o = re.compile('\sMach-O.+binary')
+
+
def isbinary(path):
- file_output = subprocess.Popen(["file", path],
+ file_output = subprocess.Popen(["file", path],
stdout=subprocess.PIPE).stdout.read()
return (mach_o.search(file_output) is not None)
+
def walk_and_invoke(sdk_root, path_regexp, suffix, num_symbols):
"""Look for matched file and invoke lldb disassembly on it."""
global scriptPath
@@ -49,7 +54,8 @@ def walk_and_invoke(sdk_root, path_regexp, suffix, num_symbols):
if os.path.islink(path):
continue
- # We'll be pattern matching based on the path relative to the SDK root.
+ # We'll be pattern matching based on the path relative to the SDK
+ # root.
replaced_path = path.replace(root_dir, "", 1)
# Check regular expression match for the replaced path.
if not path_regexp.search(replaced_path):
@@ -60,10 +66,12 @@ def walk_and_invoke(sdk_root, path_regexp, suffix, num_symbols):
if not isbinary(path):
continue
- command = template % (scriptPath, path, num_symbols if num_symbols > 0 else 1000)
+ command = template % (
+ scriptPath, path, num_symbols if num_symbols > 0 else 1000)
print "Running %s" % (command)
os.system(command)
+
def main():
"""Read the root dir and the path spec, invoke lldb-disasm.py on the file."""
global scriptPath
@@ -78,23 +86,32 @@ def main():
Run lldb disassembler on all the binaries specified by a combination of root dir
and path pattern.
""")
- parser.add_option('-r', '--root-dir',
- type='string', action='store',
- dest='root_dir',
- help='Mandatory: the root directory for the SDK symbols.')
- parser.add_option('-p', '--path-pattern',
- type='string', action='store',
- dest='path_pattern',
- help='Mandatory: regular expression pattern for the desired binaries.')
+ parser.add_option(
+ '-r',
+ '--root-dir',
+ type='string',
+ action='store',
+ dest='root_dir',
+ help='Mandatory: the root directory for the SDK symbols.')
+ parser.add_option(
+ '-p',
+ '--path-pattern',
+ type='string',
+ action='store',
+ dest='path_pattern',
+ help='Mandatory: regular expression pattern for the desired binaries.')
parser.add_option('-s', '--suffix',
type='string', action='store', default=None,
dest='suffix',
help='Specify the suffix of the binaries to look for.')
- parser.add_option('-n', '--num-symbols',
- type='int', action='store', default=-1,
- dest='num_symbols',
- help="""The number of symbols to disassemble, if specified.""")
-
+ parser.add_option(
+ '-n',
+ '--num-symbols',
+ type='int',
+ action='store',
+ default=-1,
+ dest='num_symbols',
+ help="""The number of symbols to disassemble, if specified.""")
opts, args = parser.parse_args()
if not opts.root_dir or not opts.path_pattern:
diff --git a/lldb/utils/test/run-until-faulted.py b/lldb/utils/test/run-until-faulted.py
index d895f56..794f4fc 100755
--- a/lldb/utils/test/run-until-faulted.py
+++ b/lldb/utils/test/run-until-faulted.py
@@ -9,10 +9,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)
@@ -26,9 +28,11 @@ def which(program):
return exe_file
return None
+
def do_lldb_launch_loop(lldb_command, exe, exe_options):
- from cStringIO import StringIO
- import pexpect, time
+ from cStringIO import StringIO
+ import pexpect
+ import time
prompt = "\(lldb\) "
lldb = pexpect.spawn(lldb_command)
@@ -37,17 +41,18 @@ def do_lldb_launch_loop(lldb_command, exe, exe_options):
lldb.expect(prompt)
# Now issue the file command.
- #print "sending 'file %s' command..." % exe
+ # print "sending 'file %s' command..." % exe
lldb.sendline('file %s' % exe)
lldb.expect(prompt)
# Loop until it faults....
count = 0
- #while True:
+ # while True:
# count = count + 1
for i in range(100):
count = i
- #print "sending 'process launch -- %s' command... (iteration: %d)" % (exe_options, count)
+ # print "sending 'process launch -- %s' command... (iteration: %d)" %
+ # (exe_options, count)
lldb.sendline('process launch -- %s' % exe_options)
index = lldb.expect(['Process .* exited with status',
'Process .* stopped',
@@ -57,19 +62,26 @@ def do_lldb_launch_loop(lldb_command, exe, exe_options):
time.sleep(3)
elif index == 1:
# Perfect, our process had stopped; break out of the loop.
- break;
+ 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()
+
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="""\
%prog [options]
@@ -80,14 +92,21 @@ The lldb executable is located via your PATH env variable, if not specified.\
type='string', action='store', metavar='LLDB_COMMAND',
default='lldb', dest='lldb_command',
help='Full path to your lldb command')
- parser.add_option('-e', '--executable',
- type='string', action='store',
- dest='exe',
- help="""(Mandatory) The executable to launch via lldb.""")
- parser.add_option('-o', '--options',
- type='string', action='store',
- default = '', dest='exe_options',
- help="""The args/options passed to the launched program, if specified.""")
+ parser.add_option(
+ '-e',
+ '--executable',
+ type='string',
+ action='store',
+ dest='exe',
+ help="""(Mandatory) The executable to launch via lldb.""")
+ parser.add_option(
+ '-o',
+ '--options',
+ type='string',
+ action='store',
+ default='',
+ dest='exe_options',
+ help="""The args/options passed to the launched program, if specified.""")
opts, args = parser.parse_args()