1#!/usr/bin/env python3
2
3import argparse
4
5parser = argparse.ArgumentParser("generate_rc.py", description="Generates an .rc files that fixes the permissions for all the ftrace events listed in the input atrace_categories.txt file")
6parser.add_argument("filename", help="Path to the atrace_categories.txt file")
7
8args = parser.parse_args()
9
10print("# Sets permission for vendor ftrace events")
11print("on late-init")
12
13with open(args.filename, 'r') as f:
14  for line in f:
15    line = line.rstrip('\n')
16    if line.startswith(' ') or line.startswith('\t'):
17      path = line.lstrip(" \t")
18      print("    chmod 0666 /sys/kernel/debug/tracing/events/{}/enable".format(path))
19      print("    chmod 0666 /sys/kernel/tracing/events/{}/enable".format(path))
20    else:
21      print ("    # {} trace points".format(line))
22