xref: /linux/tools/verification/dot2/dot2k (revision 24bce201d79807b668bf9d9e0aca801c5c0d5f78)
1#!/usr/bin/env python3
2# SPDX-License-Identifier: GPL-2.0-only
3#
4# Copyright (C) 2019-2022 Red Hat, Inc. Daniel Bristot de Oliveira <bristot@kernel.org>
5#
6# dot2k: transform dot files into a monitor for the Linux kernel.
7
8if __name__ == '__main__':
9    from dot2.dot2k import dot2k
10    import argparse
11    import ntpath
12    import os
13    import platform
14    import sys
15    import sys
16    import argparse
17
18    parser = argparse.ArgumentParser(description='transform .dot file into kernel rv monitor')
19    parser.add_argument('-d', "--dot", dest="dot_file", required=True)
20    parser.add_argument('-t', "--monitor_type", dest="monitor_type", required=True)
21    parser.add_argument('-n', "--model_name", dest="model_name", required=False)
22    parser.add_argument("-D", "--description", dest="description", required=False)
23    params = parser.parse_args()
24
25    print("Opening and parsing the dot file %s" % params.dot_file)
26    try:
27        monitor=dot2k(params.dot_file, params.monitor_type)
28    except Exception as e:
29        print('Error: '+ str(e))
30        print("Sorry : :-(")
31        sys.exit(1)
32
33    # easier than using argparse action.
34    if params.model_name != None:
35        print(params.model_name)
36
37    print("Writing the monitor into the directory %s" % monitor.name)
38    monitor.print_files()
39    print("Almost done, checklist")
40    print("  - Edit the %s/%s.c to add the instrumentation" % (monitor.name, monitor.name))
41    print("  - Edit include/trace/events/rv.h to add the tracepoint entry")
42    print("  - Move it to the kernel's monitor directory")
43    print("  - Edit kernel/trace/rv/Makefile")
44    print("  - Edit kernel/trace/rv/Kconfig")
45