spgen(1)
πΈ spgen β the glow-up your semantic patch deserves π
okay bestie, so <spgen> (that's the command, and also the whole manual page we're doing here) is a source-to-source transformation tool for hardening Coccinelle semantic patch scripts. literally what it does is take a semantic patch and hand you back the same patch but with added metadata and more options, in the form of virtual rules. no cap. β¨
β¨ SYNOPSIS β¨
spgen <SmPL-patch.cocci> [-c | --config <spgen config>] [-i |
--interactive] [--default] [-o <output file>] [--no-output] [-help |
--help]
π¦ DESCRIPTION π¦
so. <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. here's the squad of virtual rules it adds, bestie:
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 lets the user control the output mode. main character energy honestly. π
you can also specify metadata to be included in the hardened script. here's everything you can drop in:
- 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. periodt. π
π 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. obsessed. π«Ά
π OPTIONS π
here is a summary of the options available on <spgen>. yes we're doing the synopsis again inside here, the original page does it too, we don't make the rules bestie:
β 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>
ngl if something's broken, tell the cocci folks β they wanna know fr 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.
π§ SEE ALSO π§
spatch(1), pycocci(1), diff(1)
and that's the whole page bestie β this one's from October 17, 2015, filed under the General Commands Manual as spgen(1). go harden something cute πβ¨πΈ
π¦ where this page comes from
- debian trixie: coccinelle 1.3.0.deb-1+b2
- fedora 43: coccinelle 1.3-12.fc43 Β· GPL-2.0-only
- fedora 44: coccinelle 1.3.1-4.fc44 Β· GPL-2.0-only
- nixos 26.05: coccinelle 1.3.1
- opensuse-leap 16.0: coccinelle 1.3.0-160000.2.2 Β· GPL-2.0-only
- opensuse-leap 16.0: coccinelle 1.3.0-160000.2.2 Β· GPL-2.0-only
- opensuse-leap 16.0: coccinelle 1.3.0-160000.2.2 Β· GPL-2.0-only
- opensuse-leap 16.0: coccinelle 1.3.0-160000.2.2 Β· GPL-2.0-only
- ubuntu questing: coccinelle 1.3.0.deb-1build3
- ubuntu resolute: coccinelle 1.3.0.deb-1build6
- ubuntu stonking: coccinelle 1.3.0.deb-1build8
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms