Coccinelle (software)

Coccinelle
Stable release
1.0.6[1] / September 27, 2016 (2016-09-27)
Repository Edit this at Wikidata
Written in OCaml and Python
Type Static program analysis
License GNU GPL v2
Website coccinelle.lip6.fr

Coccinelle (French for ladybug) is an open-source 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 interfaces (APIs) such as renaming a function, adding a function argument whose value is somehow context-dependent, and reorganizing a data structure.

Support for Coccinelle is provided by IRILL. 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 syntax.[2] The Semantic Patch Language (SmPL) pattern resembles a unified diff with C-like declarations.[3][4]

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

  1. "Coccinelle: A Program Matching and Transformation Tool for Systems Code: Downloads". coccinelle.lip6.fr. Retrieved 2018-07-12.
  2. "Info" (PDF). coccinelle.lip6.fr.
  3. Valerie Henson (2009-01-20). "Semantic patching with Coccinelle". Linux Weekly News. Retrieved 2011-04-25.
  4. Wolfram Sang (2010-03-30). "Evolutionary development of a semantic patch using Coccinelle". Linux Weekly News. Retrieved 2011-04-25.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.