HOME

TheInfoList



OR:

Coccinelle (
French French (french: français(e), link=no) may refer to: * Something of, from, or related to France ** French language, which originated in France, and its various dialects and accents ** French people, a nation and ethnic group identified with Franc ...
for ''ladybug'') is an
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
utility for matching and transforming the source code of programs written in the C programming language.


Utility

Coccinelle was initially used to aid the evolution of the Linux kernel, providing support for changes to library
application programming interface An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how t ...
s (APIs) such as renaming a
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-oriente ...
, adding a function argument whose value is somehow context-dependent, and reorganizing a data structure. It can also be used to find defective programming patterns in code (i.e., pieces of code that are erroneous with high probability such as possible NULL pointer dereference) without transforming them. Then ''coccinelles role is close to that of
static analysis Static analysis, static projection, or static scoring is a simplified analysis wherein the effect of an immediate change to a system is calculated without regard to the longer-term response of the system to that change. If the short-term effect i ...
tools. Examples of such use are provided by the applications of the
herodotos
' tool, which keeps track of warnings generated by ''coccinelle''. Support for Coccinelle is provided by
IRILL The Innovation and research initiative for free software (, IRILL) is a French research center. This centre was created in September 2010 by INRIA with Pierre and Marie Curie University and Paris Diderot University and is located on the Jussieu Cam ...
. Funding for the development has been provided by the Agence Nationale de la Recherche (France), the Danish Research Council for Technology and Production Sciences, and INRIA. The source code of Coccinelle is licensed under the terms of version 2 of the GNU General Public License (GPL).


Semantic Patch Language

The source code to be matched or replaced is specified using a "semantic patch" syntax based on the
patch Patch or Patches may refer to: Arts, entertainment and media * Patch Johnson, a fictional character from ''Days of Our Lives'' * Patch (''My Little Pony''), a toy * "Patches" (Dickey Lee song), 1962 * "Patches" (Chairmen of the Board song ...
syntax. The Semantic Patch Language (SmPL) pattern resembles a
unified diff In computing, the utility diff is a data comparison tool that computes and displays the differences between the contents of files. Unlike edit distance notions used for other purposes, diff is line-oriented rather than character-oriented, but i ...
with C-like declarations.


Example

@@ expression lock, flags; expression urb; @@ spin_lock_irqsave(lock, flags); <... - usb_submit_urb(urb) + usb_submit_urb(urb, GFP_ATOMIC) ...> spin_unlock_irqrestore(lock, flags); @@ expression urb; @@ - usb_submit_urb(urb) + usb_submit_urb(urb, GFP_KERNEL)


References


External links

* {{GitHub, coccinelle/coccinelle, Source code repository
Official latest stable download



Coccinellery: Semantic Patch Gallery
Code refactoring Static program analysis tools Software using the GPL license