From 91e38285dc27e5dbac3291258342835fc3e90eab Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 11 Jul 2016 14:46:57 -0700 Subject: add a tracing option to the c api, which logs out a runnable program from c api calls --- scripts/clean_c_api_trace.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 scripts/clean_c_api_trace.py (limited to 'scripts/clean_c_api_trace.py') diff --git a/scripts/clean_c_api_trace.py b/scripts/clean_c_api_trace.py new file mode 100755 index 000000000..efe8baa43 --- /dev/null +++ b/scripts/clean_c_api_trace.py @@ -0,0 +1,23 @@ +#! /usr/bin/env python + +''' +Cleans up output from the C api, makes a runnable C file +''' + +import sys + +trace = open(sys.argv[1]).read() + +start = trace.find('// beginning a Binaryen API trace') +if start >= 0: + trace = trace[start:] + + while 1: + start = trace.find('\n(') + if start < 0: + break + end = trace.find('\n)', start + 1) + assert end > 0 + trace = trace[:start] + trace[end + 2:] + + print trace -- cgit v1.2.3