diff --git a/linux-ramdump-parser-v2/ramparse.py b/linux-ramdump-parser-v2/ramparse.py index 81adf2c4d31024bbceb1db2caf7920ce69bf37c0..2708ac7abc76a53055cd122dad04a7b026ca8ba4 100755 --- a/linux-ramdump-parser-v2/ramparse.py +++ b/linux-ramdump-parser-v2/ramparse.py @@ -105,10 +105,6 @@ if __name__ == '__main__': set_outfile(options.outdir + '/' + options.outfile) print_out_str('Linux Ram Dump Parser Version %s' % VERSION) - if options.vmlinux is None: - print_out_str("No vmlinux given. I can't proceed!") - parser.print_usage() - sys.exit(1) args = '' for arg in sys.argv: @@ -118,6 +114,24 @@ if __name__ == '__main__': system_type = parser_util.get_system_type() + if options.autodump is not None: + if os.path.exists(options.autodump): + print_out_str( + 'Looking for Ram dumps in {0}'.format(options.autodump)) + else: + print_out_str( + 'Path {0} does not exist for Ram dumps. Exiting...'.format(options.autodump)) + sys.exit(1) + + if options.vmlinux is None: + autovm = os.path.join(options.autodump, 'vmlinux') + if os.path.isfile(autovm): + options.vmlinux = autovm + else: + print_out_str("No vmlinux given or found in autodump dir. I can't proceed!") + parser.print_usage() + sys.exit(1) + if not os.path.exists(options.vmlinux): print_out_str( '{0} does not exist. Cannot proceed without vmlinux. Exiting...'.format(options.vmlinux)) @@ -126,8 +140,8 @@ if __name__ == '__main__': print_out_str( '{0} is not a file. Did you pass the ram file directory instead of the vmlinux?'.format(options.vmlinux)) sys.exit(1) - else: - print_out_str('using vmlinx file {0}'.format(options.vmlinux)) + + print_out_str('using vmlinux file {0}'.format(options.vmlinux)) if options.ram_addr is None and options.autodump is None: print_out_str('Need one of --auto-dump or at least one --ram-file') @@ -143,15 +157,6 @@ if __name__ == '__main__': 'Ram file {0} does not exist. Exiting...'.format(a[0])) sys.exit(1) - if options.autodump is not None: - if os.path.exists(options.autodump): - print_out_str( - 'Looking for Ram dumps in {0}'.format(options.autodump)) - else: - print_out_str( - 'Path {0} does not exist for Ram dumps. Exiting...'.format(options.autodump)) - sys.exit(1) - gdb_path = options.gdb nm_path = options.nm