spgen - Man Page
Name
spgen — harden a Coccinelle semantic patch
spgen <SmPL-patch.cocci> [-c | --config <spgen config>] [-i | --interactive] [--default] [-o <output file>] [--no-output] [-help | --help]
Description
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:
- patch: used for + or - rules that transform matching C code.
- 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.
- Description of the patch's functionality.
- 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.
Examples
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.
Options
Here is a summary of the options available on spgen:
Synopsis
spgen <SmPL-patch.cocci> [-c | --config <spgen config>] [-i | --interactive] [--default] [-o <output file>] [--no-output] [-help | --help]
- -help | --help
Print the help menu.
- -c | --config <foo.config>
Harden the <SmPL-patch.cocci> using the configuration specified in <foo.config>.
- -i | --interactive
Harden the <SmPL-patch.cocci> using configuration options specified through the commandline.
- -o <output.cocci>
Output the hardened semantic patch to <output.cocci> instead of stdout.
- --default
Harden the <SmPL-patch.cocci> without a configuration, instead using default values. This option mainly exists to see what the generated script would look like, as the default values are not specific to the input script.
- --no-output
Run the program without outputting anything. This option mainly exists to check that the input script and configuration file are parsable.
Author
spgen and this man page were written by Chi Pham <chidaph@gmail.com>
Reporting Bugs
Send a mail to <cocci@inria.fr>
Copyright
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.