Skip to content
Snippets Groups Projects
Commit c52de5a0 authored by Mitchel Humpherys's avatar Mitchel Humpherys
Browse files

lrdp-v2: add interactive shell

During development, it's quite convenient to load up an interactive
python interpreter with a RamDump instance loaded. Add some command line
switches to launch an interactive shell with the RamDump instance that
gets created as a result of whatever other command line options are
passed.

If IPython is installed, an IPython interpreter will be launched,
otherwise a classic Python interpreter will be launched. The classic
interface can also be forced with --classic-shell.

Change-Id: Id59acb97a830055212de9db3eaf05f18358f757f
parent c48ff153
No related branches found
No related tags found
No related merge requests found
......@@ -74,6 +74,10 @@ if __name__ == '__main__':
dest='qdss', help='Parse QDSS (deprecated)')
parser.add_option('', '--64-bit', action='store_true', dest='arm64',
help='Parse dumps as 64-bit dumps')
parser.add_option('', '--shell', action='store_true',
help='Run an interactive python interpreter with the ramdump loaded')
parser.add_option('', '--classic-shell', action='store_true',
help='Like --shell, but forces the use of the classic python shell, even if ipython is installed')
for p in parser_util.get_parsers():
parser.add_option(p.shortopt or '',
......@@ -197,6 +201,29 @@ if __name__ == '__main__':
options.force_hardware, options.force_hardware_version,
arm64=options.arm64)
if options.shell or options.classic_shell:
print "Entering interactive shell mode."
print "The RamDump instance is available in the `dump' variable\n"
do_fallback = options.classic_shell
if not do_fallback:
try:
from IPython import embed
embed()
except ImportError:
do_fallback = True
if do_fallback:
import code
import readline
import rlcompleter
vars = globals()
vars.update(locals())
readline.set_completer(rlcompleter.Completer(vars).complete)
readline.parse_and_bind("tab: complete")
shell = code.InteractiveConsole(vars)
shell.interact()
sys.exit(0)
if not dump.print_command_line():
print_out_str('!!! Error printing saved command line.')
print_out_str('!!! The vmlinux is probably wrong for the ramdumps')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment