From 76c596bc8e054a45d0814097b90e426b63bae549 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 21 Apr 2019 16:48:43 +0800 Subject: Helper script - Extracts the last (or a named) function from the debug log --- scripts/log_get_last_function.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 scripts/log_get_last_function.py (limited to 'scripts/log_get_last_function.py') diff --git a/scripts/log_get_last_function.py b/scripts/log_get_last_function.py new file mode 100644 index 00000000..7a148639 --- /dev/null +++ b/scripts/log_get_last_function.py @@ -0,0 +1,26 @@ +import argparse +import sys + +def main(): + argp = argparse.ArgumentParser() + argp.add_argument("-o", "--output", type=lambda v: open(v, 'w'), default=sys.stdout) + argp.add_argument("logfile", type=open) + argp.add_argument("fcn_name", type=str, nargs='?') + args = argp.parse_args() + + fcn_lines = [] + found_fcn = False + for line in args.logfile: + if 'visit_function: ' in line: + if found_fcn: + break + fcn_lines = [] + if args.fcn_name is not None and args.fcn_name in line: + found_fcn = True + fcn_lines.append(line.strip()) + + for l in fcn_lines: + args.output.write(l) + args.output.write("\n") + +main() -- cgit v1.2.3