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:

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.

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>

See Also

spatch(1), pycocci(1), diff(1)

Info

October 17, 2015