xref: /linux/tools/verification/dot2/dot2k (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
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
1924bce201SDaniel Bristot de Oliveira    parser = argparse.ArgumentParser(description='transform .dot file into kernel rv monitor')
2024bce201SDaniel Bristot de Oliveira    parser.add_argument('-d', "--dot", dest="dot_file", required=True)
2124bce201SDaniel Bristot de Oliveira    parser.add_argument('-t', "--monitor_type", dest="monitor_type", required=True)
2224bce201SDaniel Bristot de Oliveira    parser.add_argument('-n', "--model_name", dest="model_name", required=False)
2324bce201SDaniel Bristot de Oliveira    parser.add_argument("-D", "--description", dest="description", required=False)
2424bce201SDaniel Bristot de Oliveira    params = parser.parse_args()
2524bce201SDaniel Bristot de Oliveira
2624bce201SDaniel Bristot de Oliveira    print("Opening and parsing the dot file %s" % params.dot_file)
2724bce201SDaniel Bristot de Oliveira    try:
2824bce201SDaniel Bristot de Oliveira        monitor=dot2k(params.dot_file, params.monitor_type)
2924bce201SDaniel Bristot de Oliveira    except Exception as e:
3024bce201SDaniel Bristot de Oliveira        print('Error: '+ str(e))
3124bce201SDaniel Bristot de Oliveira        print("Sorry : :-(")
3224bce201SDaniel Bristot de Oliveira        sys.exit(1)
3324bce201SDaniel Bristot de Oliveira
3424bce201SDaniel Bristot de Oliveira    # easier than using argparse action.
3524bce201SDaniel Bristot de Oliveira    if params.model_name != None:
3624bce201SDaniel Bristot de Oliveira        print(params.model_name)
3724bce201SDaniel Bristot de Oliveira
3824bce201SDaniel Bristot de Oliveira    print("Writing the monitor into the directory %s" % monitor.name)
3924bce201SDaniel Bristot de Oliveira    monitor.print_files()
4024bce201SDaniel Bristot de Oliveira    print("Almost done, checklist")
4124bce201SDaniel Bristot de Oliveira    print("  - Edit the %s/%s.c to add the instrumentation" % (monitor.name, monitor.name))
4224bce201SDaniel Bristot de Oliveira    print("  - Edit include/trace/events/rv.h to add the tracepoint entry")
4324bce201SDaniel Bristot de Oliveira    print("  - Move it to the kernel's monitor directory")
4424bce201SDaniel Bristot de Oliveira    print("  - Edit kernel/trace/rv/Makefile")
4524bce201SDaniel Bristot de Oliveira    print("  - Edit kernel/trace/rv/Kconfig")
46