36 logger = logging.getLogger(
"acl_tracing")
41 for root, dirnames, filenames,
in os.walk(path):
42 for filename
in fnmatch.filter(filenames, pattern):
43 matches.append(os.path.join(root,filename))
48 decl =
" ".
join(function_signature)
49 m = re.match(
"void ([^:]+)::configure\(([^)]*)\)", decl)
51 assert m,
"Can't parse '%s'" % line
52 class_name = m.group(1)
55 args = re.sub(
"\/\*.*?\*\/",
"",args)
57 args = re.sub(
"<.*?>",
"",args)
60 for arg
in args.split(
","):
61 m = re.match(
".*?([^ &*]+)$", arg.strip())
62 arg_names.append(m.group(1))
63 logger.debug(
" %s" % m.group(1))
64 return (class_name, arg_names)
70 logger.debug(
"Full signature = %s" %
" ".
join(function_signature))
73 assert len(arg_names),
"No argument to configure for %s ?" % class_name
74 spaces = re.match(
"([ ]*)void", function[0]).group(1)
75 fd.write(
"%s ARM_COMPUTE_CREATE_TRACEPOINT(%s, \"%s\", this, TracePoint::Args()" % (spaces, source, class_name))
77 fd.write(
"<<%s" % arg)
80 print(
'Failed to get class name in %s ' %
" ".
join(function_signature))
83 if __name__ ==
"__main__":
84 parser = argparse.ArgumentParser(
85 formatter_class=argparse.RawDescriptionHelpFormatter,
86 description=
"Post process JSON benchmark files",
89 parser.add_argument(
"-D",
"--debug", action=
'store_true', help=
"Enable script debugging output")
90 args = parser.parse_args()
91 logging_level = logging.INFO
93 logging_level = logging.DEBUG
94 logging.basicConfig(level=logging_level)
95 logger.debug(
"Arguments passed: %s" %
str(args.__dict__))
96 for f
in find(
"src",
"*.cpp"):
99 lines = fd.readlines()
100 contains_configure =
False 102 if re.search(
r"void.*::configure\(",line):
103 contains_configure =
True 105 if not contains_configure:
109 function_signature =
None 110 insert_tracing =
False 115 if not (line.startswith(
"/*")
or line.startswith(
" *")
or line.startswith(
"#")
or len(line.strip()) == 0):
117 fd.write(
"#include \"arm_compute/core/TracePoint.h\"\n")
118 elif not function_signature:
119 if re.search(
r"void.*::configure\(",line):
120 function_signature = [ line.rstrip() ]
122 if re.search(
"[ ]*{$", line):
123 insert_tracing =
True 125 function_signature.append(line.rstrip())
130 source =
"TracePoint::Layer::CORE" 131 elif "/runtime/" in f:
132 source =
"TracePoint::Layer::RUNTIME" 134 assert "Can't find layer for file %s" %f
136 insert_tracing =
False 137 function_signature =
None std::string join(T first, T last, const std::string &separator)
Helper function to concatenate multiple strings.
def get_class_and_args(function)
def do_insert_tracing(source, function, fd)