2 .\" Please adjust this date whenever revising the manpage.
3 .TH SPATCH 1 "aug 02, 2012"
5 .\" see http://www.fnal.gov/docs/products/ups/ReferenceManual/html/manpages.html
6 .\" see http://www.linuxjournal.com/article/1158
7 .\" see http://www.schweikhardt.net/man_page_howto.html
8 .\" groff -Tascii -man ./spatch.1 | more
10 .\" Some roff macros, for reference:
11 .\" .nh disable hyphenation
12 .\" .hy enable hyphenation
13 .\" .ad l left justify
14 .\" .ad b justify to both left and right margins
15 .\" .nf disable filling
16 .\" .fi enable filling
17 .\" .br insert line break
18 .\" .sp <n> insert n+1 empty lines
19 .\" for manpage-specific macros, see man(7)
21 .\" TeX users may be more comfortable with the \fB<whatever>\fP and
22 .\" \fI<whatever>\fP escape sequences to invode bold face and italics,
23 .\" respectively. Also \fR for roman.
24 .\" pad: src: deputy man page
26 spatch \- apply a semantic patch file to a set of C files
44 \fBspatch\fP is a program matching and transformation tool for C.
45 The programmer describes the code to match and the transformation to
46 perform as a semantic patch, which looks like a standard patch, but can
47 transform multiple files at any number of code sites.
50 Further information about spatch is available at
51 \fBhttp://coccinelle.lip6.fr/\fP.
54 Here is a summary of the most commonly used options:
57 .B -sp_file \fI<file>\fP
58 the semantic patch file
61 process all files in directory recursively
63 .B -iso_file \fI<file>\fP
64 (default=@SHAREDIR@/standard.iso)
66 .B -macro_file \fI<file>\fP
67 (default=@SHAREDIR@/standard.h)
70 print some information to help debug the matching process
73 causes all available include files to be used
76 causes not even local include files to be used
79 the directory containing the include files
82 process header files independently
85 works with -dir, use information generated by glimpseindex
88 the output file. If none is specified, a patch is generated on the standard
92 do the modification on the file directly
95 store modifications in a .cocci_res file
98 show the version of spatch
101 show the date on which spatch was compiled
104 see short list of options
107 see all the available options in different categories
110 show summary of options.
114 ./spatch -sp_file foo.cocci foo.c
116 Apply the semantic patch foo.cocci to the C file foo.c. The semantic patch
117 is applied modulo a set of isomorphisms contained in standard.iso
118 (standard.iso is by default located in
119 @SHAREDIR@/standard.iso). A patch showing the effect of
120 the application, if any, will be generated on the standard output.
122 ./spatch -sp_file foo.cocci foo.c -o /tmp/newfoo.c
124 The same as the above, except that a modified version of foo.c is stored in
127 It is also possible to apply spatch to all of the C files in
130 ./spatch -cocci_file foo.cocci -dir foodir
132 If the semantic patch is not working as expected, the option -debug
133 shows selection of information about the application of
134 a semantic patch to a file or directory.
140 <file> the semantic patch file
143 <file> the output file
146 do the modification on the file directly
148 \fB\-\-backup\-suffix\fR
149 suffix to use when making a backup for inplace
152 store modifications in a .cocci_res file
155 invert the semantic patch before applying it
158 set number of diff context lines
160 \fB\-\-partial\-match\fR
161 report partial matches of the SP on the C file
164 <file> (default=/usr/local/share/coccinelle/standard.iso)
166 \fB\-\-macro\-file\fR
169 \fB\-\-macro\-file\-builtins\fR
170 <file> (default=/usr/local/share/coccinelle/standard.h)
172 \fB\-\-recursive\-includes\fR
173 causes all available include files, both those included in the C file(s) and those included in header files, to be used
175 \fB\-\-all\-includes\fR
176 causes all available include files included in the C file(s) to be used
178 \fB\-\-no\-includes\fR
179 causes not even local include files to be used
181 \fB\-\-local\-includes\fR
182 causes local include files to be used
184 \fB\-\-ignore\-unknown\-options\fR
185 For integration in a toolchain (must be set before the first unknown option)
187 \fB\-\-include\-headers\fR
188 process header files independently
191 <dir> containing the header files (optional)
194 run the C preprocessor before applying the semantic match
197 gcc/cpp compatibility mode
200 <dir> process all files in directory recursively
202 \fB\-\-use\-glimpse\fR
203 works with \fB\-dir\fR, use info generated by glimpseindex
205 \fB\-\-use\-google\fR
206 find relevant files using google code search
208 \fB\-\-use\-idutils\fR
209 find relevant files using id\-utils
212 <dir> path name with respect to which a patch should be created
214 "" for a file in the current directory
216 \fB\-\-kbuild\-info\fR
217 <file> improve \fB\-dir\fR by grouping related c files
220 Sets output routine: Standard values: <coccilib.output.Gtk|coccilib.output.Console>
229 see short list of options
232 see all the available options in different categories
234 .IP "ALIASES AND OBSOLETE OPTIONS"
237 command line semantic patch
240 short option of \fB\-\-iso\-file\fR
242 \fB\-\-cocci\-file\fR
243 <file> the semantic patch file
245 .IP "MOST USEFUL SHOW OPTIONS"
249 \fB\-\-no\-show\-diff\fR
251 \fB\-\-force\-diffshow\fR
252 diff even if only spacing changes
256 \fB\-\-ctl\-inline\-let\fR
258 \fB\-\-ctl\-show\-mcodekind\fR
260 \fB\-\-show\-bindings\fR
262 \fB\-\-show\-transinfo\fR
266 \fB\-\-show\-trying\fR
267 show the name of each function being processed
269 \fB\-\-show\-dependencies\fR
270 show the dependencies related to each rule
272 .IP "VERBOSE SUBSYSTEMS OPTIONS"
274 \fB\-\-verbose\-ctl\-engine\fR
276 \fB\-\-verbose\-match\fR
278 \fB\-\-verbose\-engine\fR
280 \fB\-\-graphical\-trace\fR
281 generate a pdf file representing the matching process
283 \fB\-\-gt\-without\-label\fR
284 remove graph label (requires option \fB\-graphical\-trace\fR)
286 \fB\-\-parse\-error\-msg\fR
288 \fB\-\-verbose\-parsing\fR
290 \fB\-\-type\-error\-msg\fR
292 .IP "OTHER SHOW OPTIONS"
296 \fB\-\-show\-cocci\fR
298 \fB\-\-show\-before\-fixed\-flow\fR
300 \fB\-\-show\-ctl\-tex\fR
302 \fB\-\-show\-ctl\-text\fR
306 .IP "DEBUG C PARSING/UNPARSING"
310 \fB\-\-debug\-lexer\fR
312 \fB\-\-debug\-etdt\fR
314 \fB\-\-debug\-typedef\fR
316 \fB\-\-filter\-msg\fR
317 filter some cpp message when the macro is a "known" cpp construct
319 \fB\-\-filter\-define\-error\fR
321 \fB\-\-filter\-msg\-define\-error\fR
324 \fB\-\-filter\-passed\-level\fR
326 \fB\-\-debug\-unparsing\fR
328 .IP "SHORTCUT FOR ENABLING/DISABLING A SET OF DEBUGGING OPTIONS AT ONCE"
332 \fB\-\-very\-quiet\fR
341 gather timing information about the main coccinelle functions
344 <level> for profiling the CTL engine
347 <sec> timeout in seconds
350 max number of model checking steps per code unit
353 max depth of iso application
355 \fB\-\-no\-iso\-limit\fR
356 disable limit on max depth of iso application
359 gather information about isomorphism usage
361 \fB\-\-disable\-iso\fR
362 disable a specific isomorphism
364 \fB\-\-profile\-iso\fR
365 gather information about the cost of isomorphism usage
367 .IP "CHANGE OF ALGORITHM OPTIONS"
369 \fB\-\-keep\-comments\fR
370 keep comments around removed code
375 drop all back edges derived from looping constructs \- unsafe
378 drop all jumps derived from gotos \- unsafe
380 \fB\-\-no\-saved\-typedefs\fR
381 drop all inferred typedefs from one parse of some code to the next
383 \fB\-\-ocaml\-regexps\fR
384 use OCaml Str regular expressions for constraints
388 \fB\-\-ifdef\-to\-if\fR
389 convert ifdef to if (experimental)
391 \fB\-\-no\-ifdef\-to\-if\fR
392 convert ifdef to if (experimental)
394 \fB\-\-disable\-multi\-pass\fR
396 \fB\-\-noif0\-passing\fR
402 \fB\-\-noadd\-typedef\-root\fR
404 \fB\-\-disallow\-nested\-exps\fR
405 disallow an expresion pattern from matching a term and its subterm
407 \fB\-\-disable\-worth\-trying\-opt\fR
409 \fB\-\-only\-return\-is\-error\-exitif\fR this flag is not set, then break and continue are also error exits
411 \fB\-\-allow\-inconsistent\-paths\fR
412 if this flag is set don't check for inconsistent paths; dangerous
414 \fB\-\-no\-safe\-expressions\fR
415 make an expression disjunction not prioritise the topmost disjunct
418 the number of bits in an unsigned int
421 the number of bits in an unsigned long
423 \fB\-\-linux\-spacing\fR
424 spacing of + code follows the conventions of Linux
426 \fB\-\-smpl\-spacing\fR
427 spacing of + code follows the semantic patch
430 indicate that a virtual rule should be considered to be matched
433 make a small attempt to parse C++ files
438 option to set if launch spatch in ocamldebug
440 \fB\-\-disable\-once\fR
441 to print more messages
443 \fB\-\-show\-trace\-profile\fR
446 \fB\-\-save\-tmp\-files\fR
451 the processor to use for this run of spatch
454 the number of processors available
456 \fB\-\-mod\-distrib\fR
457 use mod to distribute files among the processors
462 use .ast_raw pre\-parsed cached C file
464 \fB\-\-cache\-prefix\fR
465 directory of cached ASTs, sets \fB\-use\-cache\fR
467 \fB\-\-cache\-limit\fR
468 maximum number of cached ASTs, sets \fB\-use\-cache\fR
470 .IP "TEST MODE AND TEST OPTIONS (WORKS WITH TESTS/ OR .OK FILES)"
471 The test options don't work with the \fB\-\-sp\-file\fR and so on.
474 <file> launch spatch on tests/file.[c,cocci]
477 launch spatch on all files in tests/ having a .res
479 \fB\-\-test\-okfailed\fR
480 generates .{ok,failed,spatch_ok} files using .res files
482 \fB\-\-test\-regression\-okfailed\fR
483 process the .{ok,failed,spatch_ok} files in current dir
485 \fB\-\-compare\-with\-expected\fR
488 \fB\-\-expected\-score\-file\fR
489 which score file to compare with in \fB\-testall\fR
491 \fB\-\-no\-update\-score\-file\fR
492 do not update the score file when \fB\-testall\fR succeeds
494 \fB\-\-relax\-include\-path\fR
497 The action options don't work with the \fB\-\-sp\-file\fR and so on.
498 It's for the other (internal) uses of the spatch program.
519 <file or file:function>
521 \fB\-\-control\-flow\fR
522 <file or file:function>
524 \fB\-\-control\-flow\-to\-file\fR
525 <file or file:function>
527 \fB\-\-test\-cfg\-ifdef\fR
530 \fB\-\-parse\-unparse\fR
539 \fB\-\-comment\-annotater\-c\fR
542 \fB\-\-compare\-c\-hardcoded\fR
544 \fB\-\-test\-attributes\fR
550 \fB\-\-extract\-macros\fR
553 \fB\-\-extract\-macros\-select\fR
559 \fB\-\-parse\-cocci\fR
566 .I @SHAREDIR@/standard.iso
568 This file contains the default set of isomorphisms.
570 .I @SHAREDIR@/standard.h
572 This file contains the default set of macro hints.
576 The path to the Coccinelle share directory. Default is
580 Y. Padioleau, J.L. Lawall, R.R Hansen, G. Muller
581 "Documenting and Automating Collateral Evolutions in Linux Device Driver"
583 Glasgow, Scotland (April 2008) pp. 247-260.
586 \fBspatch\fP was written by Julia Lawall <julia@diku.dk>, Yoann Padioleau
587 <yoann.padioleau@gmail.com>, Rene Rydhof Hansen <rrhansen@diku.dk> and
588 Henrik Stuart <henrik@hstuart.dk>.
590 This manual page was written by Yoann Padioleau <yoann.padioleau@gmail.com>
591 and Julia Lawall <julia@diku.dk>.
594 Send a mail to <cocci@diku.dk>
597 Copyright 2010, 2011, University of Copenhagen DIKU and INRIA.
598 Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen.
599 spatch is free software: you can redistribute it and/or modify
600 it under the terms of the GNU General Public License as published by
601 the Free Software Foundation, according to version 2 of the License.
604 \fIpatch\fP(1), \fIdiff\fP(1)