summaryrefslogtreecommitdiff
path: root/scripts/log_get_last_function.py
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-04-21 16:48:43 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-04-21 16:48:43 +0800
commit76c596bc8e054a45d0814097b90e426b63bae549 (patch)
treefb8a42f7bc7f175359026f879e15de7be349d8d3 /scripts/log_get_last_function.py
parent54d0563ccb4f1129aa65f736773066297b3eac17 (diff)
downloadmrust-76c596bc8e054a45d0814097b90e426b63bae549.tar.gz
Helper script - Extracts the last (or a named) function from the debug log
Diffstat (limited to 'scripts/log_get_last_function.py')
-rw-r--r--scripts/log_get_last_function.py26
1 files changed, 26 insertions, 0 deletions
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()