spgen(1) | General Commands Manual | spgen(1) |
spgen - harden a Coccinelle semantic patch
spgen <SmPL-patch.cocci> [-c | --config <spgen config>] [-i | --interactive] [--default] [-o <output file>] [--no-output] [-help | --help]
spgen is a source-to-source transformation tool for
hardening Coccinelle semantic patch scripts.
It takes a semantic patch and outputs the same patch with added metadata and
more options in the form of virtual rules:
- context: used for * rules that find matching C code.
- org: used for script rules that output matches in emacs org format.
- report: used for script rules that output matches in pretty print format.
A semantic patch hardened with spgen thus preserves the functionality of the original patch, but allows the user to control the output mode.
The user can also specify metadata to be included in the hardened script.
- Confidence level for the patch.
- Authors of the patch.
- URL for gaining more information about the patch.
- Known limitations of the patch.
- Keywords for the patch.
- spatch options with which to run the patch.
- Additional comments regarding the patch.
- Rule messages to be output in script mode for each match.
The metadata can be specified in a configuration file or entered through the commandline in interactive mode. The syntax of the configuration file follows a simple newline-separated <attribute=value> pattern. Use interactive mode to get an automatically generated configuration file.
Generate a hardened version of <foo.cocci> using the configuration in <foo.config>:
./spgen <foo.cocci> --config <foo.config>
Generate a hardened version of <foo.cocci> using interactive mode through the commandline. The user will be able to save their interactively specified configuration to a file:
./spgen <foo.cocci> --interactive
By default, spgen will look for a foo.config file in the same directory and use that as configuration. If not found, it will start in interactive mode:
./spgen <foo.cocci>
Output the hardened version to <newfoo.cocci> instead of stdout:
./spgen <foo.cocci> -o <newfoo.cocci>
Suppose that <foo.cocci> is the original patch and <newfoo.cocci> is the hardened version of <foo.cocci>. Then what could be achieved with
spatch --sp-file <foo.cocci> <foo.c>
can now be achieved with
spatch --sp-file <newfoo.cocci> <foo.c> -D patch
Substitute patch with context, org, or report for any of the other modes.
Here is a summary of the options available on spgen:
spgen <SmPL-patch.cocci> [-c | --config <spgen config>] [-i | --interactive] [--default] [-o <output file>] [--no-output] [-help | --help]
spgen and this man page were written by Chi Pham <chidaph@gmail.com>
Send a mail to <cocci@systeme.lip6.fr>
Copyright 2015, Chi Pham spgen is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, according to version 2 of the License.
October 17, 2015 |