From 50ae5ab018c6fef51e863450417e1d3e3f90a13b Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys <mitchelh@codeaurora.org> Date: Thu, 17 Sep 2015 12:04:50 -0700 Subject: [PATCH] lrdp-v2: Add `--eval' option Although the `--shell' option can currently be used for ad-hoc debugging, it's not ideal for scripting since it prints out a bunch of other stuff during initialization. Add a dedicated `--eval' option that executes arbitrary Python code without printing anything else. Change-Id: I9e24e6d140dd49208b850b2a17ac2f599a35657b --- linux-ramdump-parser-v2/ramparse.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linux-ramdump-parser-v2/ramparse.py b/linux-ramdump-parser-v2/ramparse.py index 715c181..318f68b 100755 --- a/linux-ramdump-parser-v2/ramparse.py +++ b/linux-ramdump-parser-v2/ramparse.py @@ -142,6 +142,8 @@ if __name__ == '__main__': default=False) parser.add_option('', '--ipc-debug', dest='ipc_debug', action='store_true', help='Debug Mode for IPC Logging', default=False) + parser.add_option('', '--eval', + help='Evaluate some python code directly, or from stdin if "-" is passed. The "dump" variable will be available, as it is with the --shell option.') # noqa for p in parser_util.get_parsers(): parser.add_option(p.shortopt or '', @@ -294,6 +296,14 @@ if __name__ == '__main__': dump = RamDump(options, nm_path, gdb_path, objdump_path) + if options.eval: + if options.eval == '-': + code = sys.stdin.read() + else: + code = options.eval + exec(code) + sys.exit(0) + if options.shell or options.classic_shell: print("Entering interactive shell mode.") print("The RamDump instance is available in the `dump' variable\n") -- GitLab