| 1 |
\subsection{What is \texttt{spgen}?} |
| 2 |
\texttt{spgen} is a \texttt{Coccinelle}\footnote{\url{http://coccinelle.lip6.fr/}} metaprogramming tool that can generate hardened semantic patches for use in e.g. the Linux kernel. |
| 3 |
|
| 4 |
Or, in less fancy words, \texttt{spgen} can take your simple \texttt{Coccinelle} script containing one or more rules with \texttt{*}, \texttt{+}, or \texttt{-}, and then output the same script with more options. |
| 5 |
|
| 6 |
In particular, \texttt{spgen} generates the \texttt{patch}, \texttt{context}, \texttt{org}, and \texttt{report} virtual rules. These options are prevalent in the \texttt{Coccinelle} scripts included in the Linux kernel and are used in the following cases: |
| 7 |
|
| 8 |
\begin{itemize} |
| 9 |
\item \texttt{patch}: Used for +/- rules that transform the matched \texttt{C} code and output the changes in Unix \texttt{diff} format. |
| 10 |
\item \texttt{context}: Used for * rules that find the matched \texttt{C} code and output it in \texttt{diff}-like format. |
| 11 |
\item \texttt{org}: Used for script rules that output matches in |
| 12 |
\texttt{emacs} org mode |
| 13 |
format\footnote{\url{http://orgmode.org/}} with |
| 14 |
an error message and line numbers. |
| 15 |
\item \texttt{report}: Used for script rules that output matches with an error message and line numbers. |
| 16 |
\end{itemize} |
| 17 |
\bigskip |
| 18 |
|
| 19 |
\subsection{Features} |
| 20 |
\texttt{spgen} includes (but is not limited to) support for |
| 21 |
\begin{itemize} |
| 22 |
\item Generating a \texttt{context} (aka *) version of a \texttt{patch} (aka +/-) rule. |
| 23 |
\item Generating \texttt{org} and \texttt{report} (aka script) versions of both \texttt{patch} and \texttt{context} rules. |
| 24 |
\item Adding \texttt{patch}, \texttt{context}, \texttt{org}, and \texttt{report} dependencies to rule headers. |
| 25 |
\item Allowing the user to specify preface information for the generated rule, such as keywords, options, etc. as well as error messages for rules and names for nameless rules. |
| 26 |
\item Automatic rulename and error message generation when none specified by the user. |
| 27 |
\item Rule splitting to ensure correct \texttt{context} mode output for rules containing pattern matching disjunctions. |
| 28 |
\item And more ... |
| 29 |
\end{itemize} |