Skip to content
Snippets Groups Projects
Commit f19f2e2c authored by Soumen Ghosh's avatar Soumen Ghosh
Browse files

lrdp-v2: Added configurable timeout for each ramparser option.

Observed some of the ramparser option is getting stuck, added timeout value for each parse
Need to add --timeout <value> to kill the option after the timeout

Change-Id: I0576000095d9f938a523cab1f3e5ec709f6e81e2
parent c8e80d9e
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,8 @@ linux-parser-output.txt is used
--qtf-path <path> : QTF tool executable
--timeout <timeout valye in secs>: each parser will be terminated within given time limit value
The list of features parsed is constantly growing. Please use --help option
to see the full list of features that can be parsed.
......@@ -77,6 +79,8 @@ specify the paths to these tools. This can be done in three ways
- After download the zip file, you will find a folder pyelftools-master.
- Inside this folder you will find another folder named "elftools"
- copy that entire folder and paste it in below directory <installed Python path>\Lib\site-packages
5) for --timeout option please do 'pip install func_timeout'
https://pypi.org/project/func-timeout/
Just having gdb/nm on the path is not supported as there are too many
variations on names to invoke.
......
#!/usr/bin/env python2
# Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
# Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 and
......@@ -33,6 +33,7 @@ VERSION = '2.0'
# quick check of system requirements:
major, minor = sys.version_info[:2]
if major != 2:
print("This script requires python2 to run!\n")
print("You seem to be running: " + sys.version)
......@@ -83,6 +84,7 @@ def parse_ram_file(option, opt_str, value, parser):
a.append((temp[0], int(temp[1], 16), int(temp[2], 16)))
setattr(parser.values, option.dest, a)
if __name__ == '__main__':
usage = 'usage: %prog [options to print]. Run with --help for more details'
parser = OptionParser(usage)
......@@ -155,6 +157,7 @@ if __name__ == '__main__':
parser.add_option('', '--ram-elf', dest='ram_elf_addr',
help='pass ap_minidump.elf generated by crashscope')
parser.add_option('', '--sym_path', dest='sym_path', help='symbol path to all loadable modules')
parser.add_option('', '--timeout', dest='timeout', help='symbol path to all loadable modules')
for p in parser_util.get_parsers():
parser.add_option(p.shortopt or '',
......@@ -394,7 +397,8 @@ if __name__ == '__main__':
parsers_to_run = [p for p in parser_util.get_parsers()
if getattr(options, p.cls.__name__)
or (options.everything and not p.optional)]
if options.timeout:
from func_timeout import func_timeout, FunctionTimedOut
for i,p in enumerate(parsers_to_run):
if i == 0:
sys.stderr.write("\n")
......@@ -410,7 +414,13 @@ if __name__ == '__main__':
before = time.time()
with print_out_section(p.cls.__name__):
try:
p.cls(dump).parse()
if options.timeout:
try:
func_timeout(int(options.timeout), p.cls(dump).parse)
except Exception as e:
print_out_str(e)
else:
p.cls(dump).parse()
except:
print_out_str('!!! Exception while running {0}'.format(p.cls.__name__))
print_out_exception()
......
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