124bce201SDaniel Bristot de Oliveira#!/usr/bin/env python3 224bce201SDaniel Bristot de Oliveira# SPDX-License-Identifier: GPL-2.0-only 324bce201SDaniel Bristot de Oliveira# 424bce201SDaniel Bristot de Oliveira# Copyright (C) 2019-2022 Red Hat, Inc. Daniel Bristot de Oliveira <bristot@kernel.org> 524bce201SDaniel Bristot de Oliveira# 624bce201SDaniel Bristot de Oliveira# dot2k: transform dot files into a monitor for the Linux kernel. 7*d57aff24SDaniel Bristot de Oliveira# 8*d57aff24SDaniel Bristot de Oliveira# For further information, see: 9*d57aff24SDaniel Bristot de Oliveira# Documentation/trace/rv/da_monitor_synthesis.rst 1024bce201SDaniel Bristot de Oliveira 1124bce201SDaniel Bristot de Oliveiraif __name__ == '__main__': 1224bce201SDaniel Bristot de Oliveira from dot2.dot2k import dot2k 1324bce201SDaniel Bristot de Oliveira import argparse 1424bce201SDaniel Bristot de Oliveira import ntpath 1524bce201SDaniel Bristot de Oliveira import os 1624bce201SDaniel Bristot de Oliveira import platform 1724bce201SDaniel Bristot de Oliveira import sys 1824bce201SDaniel Bristot de Oliveira import sys 1924bce201SDaniel Bristot de Oliveira import argparse 2024bce201SDaniel Bristot de Oliveira 2124bce201SDaniel Bristot de Oliveira parser = argparse.ArgumentParser(description='transform .dot file into kernel rv monitor') 2224bce201SDaniel Bristot de Oliveira parser.add_argument('-d', "--dot", dest="dot_file", required=True) 2324bce201SDaniel Bristot de Oliveira parser.add_argument('-t', "--monitor_type", dest="monitor_type", required=True) 2424bce201SDaniel Bristot de Oliveira parser.add_argument('-n', "--model_name", dest="model_name", required=False) 2524bce201SDaniel Bristot de Oliveira parser.add_argument("-D", "--description", dest="description", required=False) 2624bce201SDaniel Bristot de Oliveira params = parser.parse_args() 2724bce201SDaniel Bristot de Oliveira 2824bce201SDaniel Bristot de Oliveira print("Opening and parsing the dot file %s" % params.dot_file) 2924bce201SDaniel Bristot de Oliveira try: 3024bce201SDaniel Bristot de Oliveira monitor=dot2k(params.dot_file, params.monitor_type) 3124bce201SDaniel Bristot de Oliveira except Exception as e: 3224bce201SDaniel Bristot de Oliveira print('Error: '+ str(e)) 3324bce201SDaniel Bristot de Oliveira print("Sorry : :-(") 3424bce201SDaniel Bristot de Oliveira sys.exit(1) 3524bce201SDaniel Bristot de Oliveira 3624bce201SDaniel Bristot de Oliveira # easier than using argparse action. 3724bce201SDaniel Bristot de Oliveira if params.model_name != None: 3824bce201SDaniel Bristot de Oliveira print(params.model_name) 3924bce201SDaniel Bristot de Oliveira 4024bce201SDaniel Bristot de Oliveira print("Writing the monitor into the directory %s" % monitor.name) 4124bce201SDaniel Bristot de Oliveira monitor.print_files() 4224bce201SDaniel Bristot de Oliveira print("Almost done, checklist") 4324bce201SDaniel Bristot de Oliveira print(" - Edit the %s/%s.c to add the instrumentation" % (monitor.name, monitor.name)) 4424bce201SDaniel Bristot de Oliveira print(" - Edit include/trace/events/rv.h to add the tracepoint entry") 4524bce201SDaniel Bristot de Oliveira print(" - Move it to the kernel's monitor directory") 4624bce201SDaniel Bristot de Oliveira print(" - Edit kernel/trace/rv/Makefile") 4724bce201SDaniel Bristot de Oliveira print(" - Edit kernel/trace/rv/Kconfig") 48