1spgen(1) General Commands Manual spgen(1)
2
3
4
6 spgen - harden a Coccinelle semantic patch
7
8 spgen <SmPL-patch.cocci> [-c | --config <spgen config>] [-i | --inter‐
9 active] [--default] [-o <output file>] [--no-output] [-help | --help]
10
11
13 spgen is a source-to-source transformation tool for hardening Coc‐
14 cinelle semantic patch scripts.
15 It takes a semantic patch and outputs the same patch with added meta‐
16 data and more options in the form of virtual rules:
17
18 - patch: used for + or - rules that transform matching C code.
19
20 - context: used for * rules that find matching C code.
21
22 - org: used for script rules that output matches in emacs org
23 format.
24
25 - report: used for script rules that output matches in pretty
26 print format.
27
28 A semantic patch hardened with spgen thus preserves the functionality
29 of the original patch, but allows the user to control the output mode.
30
31 The user can also specify metadata to be included in the hardened
32 script.
33
34 - Description of the patch's functionality.
35
36 - Confidence level for the patch.
37
38 - Authors of the patch.
39
40 - URL for gaining more information about the patch.
41
42 - Known limitations of the patch.
43
44 - Keywords for the patch.
45
46 - spatch options with which to run the patch.
47
48 - Additional comments regarding the patch.
49
50 - Rule messages to be output in script mode for each match.
51
52 The metadata can be specified in a configuration file or entered
53 through the commandline in interactive mode. The syntax of the configu‐
54 ration file follows a simple newline-separated <attribute=value> pat‐
55 tern. Use interactive mode to get an automatically generated configu‐
56 ration file.
57
58
60 Generate a hardened version of <foo.cocci> using the configuration in
61 <foo.config>:
62
63 ./spgen <foo.cocci> --config <foo.config>
64
65 Generate a hardened version of <foo.cocci> using interactive mode
66 through the commandline. The user will be able to save their interac‐
67 tively specified configuration to a file:
68
69 ./spgen <foo.cocci> --interactive
70
71 By default, spgen will look for a foo.config file in the same directory
72 and use that as configuration. If not found, it will start in interac‐
73 tive mode:
74
75 ./spgen <foo.cocci>
76
77 Output the hardened version to <newfoo.cocci> instead of stdout:
78
79 ./spgen <foo.cocci> -o <newfoo.cocci>
80
81 Suppose that <foo.cocci> is the original patch and <newfoo.cocci> is
82 the hardened version of <foo.cocci>. Then what could be achieved with
83
84 spatch --sp-file <foo.cocci> <foo.c>
85
86 can now be achieved with
87
88 spatch --sp-file <newfoo.cocci> <foo.c> -D patch
89
90 Substitute patch with context, org, or report for any of the other
91 modes.
92
93
95 Here is a summary of the options available on spgen:
96
97
99 spgen <SmPL-patch.cocci> [-c | --config <spgen config>] [-i | --inter‐
100 active] [--default] [-o <output file>] [--no-output] [-help | --help]
101
102
103 -help | --help
104 Print the help menu.
105
106 -c | --config <foo.config>
107 Harden the <SmPL-patch.cocci> using the configuration specified
108 in <foo.config>.
109
110 -i | --interactive
111 Harden the <SmPL-patch.cocci> using configuration options speci‐
112 fied through the commandline.
113
114 -o <output.cocci>
115 Output the hardened semantic patch to <output.cocci> instead of
116 stdout.
117
118 --default
119 Harden the <SmPL-patch.cocci> without a configuration, instead
120 using default values. This option mainly exists to see what the
121 generated script would look like, as the default values are not
122 specific to the input script.
123
124 --no-output
125 Run the program without outputting anything. This option mainly
126 exists to check that the input script and configuration file are
127 parsable.
128
129
131 spgen and this man page were written by Chi Pham <chidaph@gmail.com>
132
133
135 Send a mail to <cocci@systeme.lip6.fr>
136
137
139 Copyright 2015, Chi Pham spgen is free software: you can redistribute
140 it and/or modify it under the terms of the GNU General Public License
141 as published by the Free Software Foundation, according to version 2 of
142 the License.
143
144
146 spatch(1), pycocci(1), diff(1)
147
148
149
150 October 17, 2015 spgen(1)