Jump to content

Coccinelle (software)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Cibervicho (talk | contribs) at 10:30, 28 December 2023 (grammar). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Coccinelle
Stable release
1.1.0[1] / February 25, 2021; 3 years ago (2021-02-25)
Repository
Written inOCaml and Python
TypeStatic program analysis
LicenseGPLv2
Websitecoccinelle.gitlabpages.inria.fr/website/

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.

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. Therefore coccinelle's role is close to that of static analysis tools. Examples of such use are provided by the applications of the herodotos tool, which keeps track of warnings generated by coccinelle. [2][3]

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.[4] The Semantic Patch Language (SmPL) pattern resembles a unified diff with C-like declarations.[5][6]

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". coccinelle.gitlabpages.inria.fr. Retrieved 2021-03-09.
  2. ^ Palix, Nicolas; Lawall, Julia; Muller, Gilles (2010). "Tracking code patterns over multiple software versions with Herodotos" (PDF). Proceedings of the 9th International Conference on Aspect-Oriented Software Development (PDF). ACM. pp. 169–180. doi:10.1145/1739230.1739250. ISBN 9781605589589. S2CID 1082611.
  3. ^ Nicolas Palix. "Nicolas Palix: Herodotos".
  4. ^ Padioleau, Yoann; Lawall, Julia; Muller, Gilles (2007). "Semantic Patches, Documenting and Automating Collateral Evolutions in Linux Device Drivers" (PDF). coccinelle.gitlabpages.inria.fr. Retrieved 2020-08-29.
  5. ^ Valerie Henson (2009-01-20). "Semantic patching with Coccinelle". Linux Weekly News. Retrieved 2011-04-25.
  6. ^ Wolfram Sang (2010-03-30). "Evolutionary development of a semantic patch using Coccinelle". Linux Weekly News. Retrieved 2011-04-25.