Skip to content

Commit 91f3407

Browse files
glemcorostedt
authored andcommitted
verification/dot2k: More robust template variables
The dot2k templates currently have variables that are automatically filled by the script marked as an uppercase VARIABLE. This requires some care while adding new variables to avoid using valid keywords and get them unexpectedly substituted. This patch switches the variables to the %%VARIABLE%% notation to make the pattern substitution more robust. Cc: Juri Lelli <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: John Kacur <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Gabriele Monaco <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent ca08e07 commit 91f3407

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

tools/verification/dot2/dot2k.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ def fill_main_c(self):
107107
tracepoint_attach = self.fill_tracepoint_attach_probe()
108108
tracepoint_detach = self.fill_tracepoint_detach_helper()
109109

110-
main_c = main_c.replace("MONITOR_TYPE", monitor_type)
111-
main_c = main_c.replace("MIN_TYPE", min_type)
112-
main_c = main_c.replace("MODEL_NAME", self.name)
113-
main_c = main_c.replace("NR_EVENTS", str(nr_events))
114-
main_c = main_c.replace("TRACEPOINT_HANDLERS_SKEL", tracepoint_handlers)
115-
main_c = main_c.replace("TRACEPOINT_ATTACH", tracepoint_attach)
116-
main_c = main_c.replace("TRACEPOINT_DETACH", tracepoint_detach)
110+
main_c = main_c.replace("%%MONITOR_TYPE%%", monitor_type)
111+
main_c = main_c.replace("%%MIN_TYPE%%", min_type)
112+
main_c = main_c.replace("%%MODEL_NAME%%", self.name)
113+
main_c = main_c.replace("%%NR_EVENTS%%", str(nr_events))
114+
main_c = main_c.replace("%%TRACEPOINT_HANDLERS_SKEL%%", tracepoint_handlers)
115+
main_c = main_c.replace("%%TRACEPOINT_ATTACH%%", tracepoint_attach)
116+
main_c = main_c.replace("%%TRACEPOINT_DETACH%%", tracepoint_detach)
117117

118118
return main_c
119119

tools/verification/dot2/dot2k_templates/main.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <rv/instrumentation.h>
99
#include <rv/da_monitor.h>
1010

11-
#define MODULE_NAME "MODEL_NAME"
11+
#define MODULE_NAME "%%MODEL_NAME%%"
1212

1313
/*
1414
* XXX: include required tracepoint headers, e.g.,
@@ -20,15 +20,15 @@
2020
* This is the self-generated part of the monitor. Generally, there is no need
2121
* to touch this section.
2222
*/
23-
#include "MODEL_NAME.h"
23+
#include "%%MODEL_NAME%%.h"
2424

2525
/*
2626
* Declare the deterministic automata monitor.
2727
*
2828
* The rv monitor reference is needed for the monitor declaration.
2929
*/
30-
static struct rv_monitor rv_MODEL_NAME;
31-
DECLARE_DA_MON_MONITOR_TYPE(MODEL_NAME, MIN_TYPE);
30+
static struct rv_monitor rv_%%MODEL_NAME%%;
31+
DECLARE_DA_MON_%%MONITOR_TYPE%%(%%MODEL_NAME%%, %%MIN_TYPE%%);
3232

3333
/*
3434
* This is the instrumentation part of the monitor.
@@ -37,55 +37,55 @@ DECLARE_DA_MON_MONITOR_TYPE(MODEL_NAME, MIN_TYPE);
3737
* are translated into model's event.
3838
*
3939
*/
40-
TRACEPOINT_HANDLERS_SKEL
41-
static int enable_MODEL_NAME(void)
40+
%%TRACEPOINT_HANDLERS_SKEL%%
41+
static int enable_%%MODEL_NAME%%(void)
4242
{
4343
int retval;
4444

45-
retval = da_monitor_init_MODEL_NAME();
45+
retval = da_monitor_init_%%MODEL_NAME%%();
4646
if (retval)
4747
return retval;
4848

49-
TRACEPOINT_ATTACH
49+
%%TRACEPOINT_ATTACH%%
5050

5151
return 0;
5252
}
5353

54-
static void disable_MODEL_NAME(void)
54+
static void disable_%%MODEL_NAME%%(void)
5555
{
56-
rv_MODEL_NAME.enabled = 0;
56+
rv_%%MODEL_NAME%%.enabled = 0;
5757

58-
TRACEPOINT_DETACH
58+
%%TRACEPOINT_DETACH%%
5959

60-
da_monitor_destroy_MODEL_NAME();
60+
da_monitor_destroy_%%MODEL_NAME%%();
6161
}
6262

6363
/*
6464
* This is the monitor register section.
6565
*/
66-
static struct rv_monitor rv_MODEL_NAME = {
67-
.name = "MODEL_NAME",
68-
.description = "auto-generated MODEL_NAME",
69-
.enable = enable_MODEL_NAME,
70-
.disable = disable_MODEL_NAME,
71-
.reset = da_monitor_reset_all_MODEL_NAME,
66+
static struct rv_monitor rv_%%MODEL_NAME%% = {
67+
.name = "%%MODEL_NAME%%",
68+
.description = "auto-generated %%MODEL_NAME%%",
69+
.enable = enable_%%MODEL_NAME%%,
70+
.disable = disable_%%MODEL_NAME%%,
71+
.reset = da_monitor_reset_all_%%MODEL_NAME%%,
7272
.enabled = 0,
7373
};
7474

75-
static int __init register_MODEL_NAME(void)
75+
static int __init register_%%MODEL_NAME%%(void)
7676
{
77-
rv_register_monitor(&rv_MODEL_NAME);
77+
rv_register_monitor(&rv_%%MODEL_NAME%%);
7878
return 0;
7979
}
8080

81-
static void __exit unregister_MODEL_NAME(void)
81+
static void __exit unregister_%%MODEL_NAME%%(void)
8282
{
83-
rv_unregister_monitor(&rv_MODEL_NAME);
83+
rv_unregister_monitor(&rv_%%MODEL_NAME%%);
8484
}
8585

86-
module_init(register_MODEL_NAME);
87-
module_exit(unregister_MODEL_NAME);
86+
module_init(register_%%MODEL_NAME%%);
87+
module_exit(unregister_%%MODEL_NAME%%);
8888

8989
MODULE_LICENSE("GPL");
9090
MODULE_AUTHOR("dot2k: auto-generated");
91-
MODULE_DESCRIPTION("MODEL_NAME");
91+
MODULE_DESCRIPTION("%%MODEL_NAME%%");

0 commit comments

Comments
 (0)