xref: /openbmc/linux/tools/verification/dot2/dot2k (revision e80a48ba)
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#
8# For further information, see:
9#   Documentation/trace/rv/da_monitor_synthesis.rst
10
11if __name__ == '__main__':
12    from dot2.dot2k import dot2k
13    import argparse
14    import ntpath
15    import os
16    import platform
17    import sys
18    import sys
19    import argparse
20
21    parser = argparse.ArgumentParser(description='transform .dot file into kernel rv monitor')
22    parser.add_argument('-d', "--dot", dest="dot_file", required=True)
23    parser.add_argument('-t', "--monitor_type", dest="monitor_type", required=True)
24    parser.add_argument('-n', "--model_name", dest="model_name", required=False)
25    parser.add_argument("-D", "--description", dest="description", required=False)
26    params = parser.parse_args()
27
28    print("Opening and parsing the dot file %s" % params.dot_file)
29    try:
30        monitor=dot2k(params.dot_file, params.monitor_type)
31    except Exception as e:
32        print('Error: '+ str(e))
33        print("Sorry : :-(")
34        sys.exit(1)
35
36    # easier than using argparse action.
37    if params.model_name != None:
38        print(params.model_name)
39
40    print("Writing the monitor into the directory %s" % monitor.name)
41    monitor.print_files()
42    print("Almost done, checklist")
43    print("  - Edit the %s/%s.c to add the instrumentation" % (monitor.name, monitor.name))
44    print("  - Edit include/trace/events/rv.h to add the tracepoint entry")
45    print("  - Move it to the kernel's monitor directory")
46    print("  - Edit kernel/trace/rv/Makefile")
47    print("  - Edit kernel/trace/rv/Kconfig")
48