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