0001 #!/usr/bin/env python3
0002 # SPDX-License-Identifier: GPL-2.0-only
0003 #
0004 # Copyright (C) 2019-2022 Red Hat, Inc. Daniel Bristot de Oliveira <bristot@kernel.org>
0005 #
0006 # dot2k: transform dot files into a monitor for the Linux kernel.
0007 #
0008 # For further information, see:
0009 # Documentation/trace/rv/da_monitor_synthesis.rst
0010
0011 if __name__ == '__main__':
0012 from dot2.dot2k import dot2k
0013 import argparse
0014 import ntpath
0015 import os
0016 import platform
0017 import sys
0018 import sys
0019 import argparse
0020
0021 parser = argparse.ArgumentParser(description='transform .dot file into kernel rv monitor')
0022 parser.add_argument('-d', "--dot", dest="dot_file", required=True)
0023 parser.add_argument('-t', "--monitor_type", dest="monitor_type", required=True)
0024 parser.add_argument('-n', "--model_name", dest="model_name", required=False)
0025 parser.add_argument("-D", "--description", dest="description", required=False)
0026 params = parser.parse_args()
0027
0028 print("Opening and parsing the dot file %s" % params.dot_file)
0029 try:
0030 monitor=dot2k(params.dot_file, params.monitor_type)
0031 except Exception as e:
0032 print('Error: '+ str(e))
0033 print("Sorry : :-(")
0034 sys.exit(1)
0035
0036 # easier than using argparse action.
0037 if params.model_name != None:
0038 print(params.model_name)
0039
0040 print("Writing the monitor into the directory %s" % monitor.name)
0041 monitor.print_files()
0042 print("Almost done, checklist")
0043 print(" - Edit the %s/%s.c to add the instrumentation" % (monitor.name, monitor.name))
0044 print(" - Edit include/trace/events/rv.h to add the tracepoint entry")
0045 print(" - Move it to the kernel's monitor directory")
0046 print(" - Edit kernel/trace/rv/Makefile")
0047 print(" - Edit kernel/trace/rv/Kconfig")