The Semantics of “Semantic Patches” in Coccinelle: Program Transformation for the Working Programmer

  • Neil D. Jones
  • René Rydhof Hansen
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4807)


We rationally reconstruct the core of the Coccinelle system, used for automating and documenting collateral evolutions in Linux device drivers. A denotational semantics of the system’s underlying semantic patch language (SmPL) is developed, and extended to include variables. The semantics is in essence a higher-order functional program and so executable; but is inefficient and limited to straight-line source programs. A richer and more efficient SmPL version is defined, implemented by compiling to the temporal logic CTL-V (CTL with existentially quantified variables ranging over source code parameters and program points; defined using the staging concept from partial evaluation). The compilation is formally proven correct and a model check algorithm is outlined.


Model Check Temporal Logic Regular Expression Atomic Proposition Source Program 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Bravenboer, M., Kalleberg, K.T., Vermaas, R., Visser, E.: Stratego/XT 0.16. Components for transformation systems. In: PEPM 2006, Charleston, South Carolina (January 2006)Google Scholar
  2. 2.
    Buckley, J., Mens, T., Zenger, M., Rashid, A., Kniesel, G.: Towards a taxonomy of software change. Journal of Software Maintenance and Evolution: Research and Practice 309–332 (2005)Google Scholar
  3. 3.
    Chapin, N., Hale, J.E., Khan, K.M., Ramil, J.F., Than, W.-G.: Types of software evolution and software maintenance. Journal of software maintenance and evolution: Research and Practice 13, 3–30 (2001)zbMATHCrossRefGoogle Scholar
  4. 4.
    De Moor, O., Lacey, D., van Wyk, E.: Universal regular path queries. Higher-order and Symbolic Computation 16(1-2), 15–35 (2003)zbMATHCrossRefGoogle Scholar
  5. 5.
    Dig, D., Johnson, R.: How do APIs evolve? a story of refactoring. Journal of Software Maintenance and Evolution: Research and Practice 18(2), 83–107 (2006)CrossRefGoogle Scholar
  6. 6.
    Fiuczynski, M., Grimm, R., Coady, Y., Walker, D.: Patch (1) considered harmful. In: Workshop on Hot Topics in Operating Systems (2005)Google Scholar
  7. 7.
    Fiuczynski, M.E.: Better tools for kernel evolution, please! LOGIN 30(5), 8–10 (2006)Google Scholar
  8. 8.
    Godfrey, M.W., Tu, Q.: Evolution in open source software: A case study. In: ICSM, pp. 131–142 (2000)Google Scholar
  9. 9.
    Hansen, R.R., Jones, N.D.: The semantics of semantic patches in Coccinelle: Program transformation for the working programmer (full paper). Project home page:
  10. 10.
    Huth, M.R.A., Ryan, M.D.: Logic in Computer Science: Modelling and Reasoning about Systems. Cambridge University Press, Cambridge (2004)zbMATHGoogle Scholar
  11. 11.
    Lacey, D., Jones, N.D., Van Wyk, E., Frederiksen, C.C.: Compiler optimization correctness by temporal logic. Higher Order and Symbolic Computation 17(3), 173–206 (2004)zbMATHCrossRefGoogle Scholar
  12. 12.
    Lacey, D.: Program Transformation using Temporal Logic Specifications. PhD thesis, Oxford University Computing Laboratory (2003)Google Scholar
  13. 13.
    Lacey, D., de Moor, O.: Imperative Program Transformation by Rewriting. In: Wilhelm, R. (ed.) CC 2001 and ETAPS 2001. LNCS, vol. 2027, pp. 52–68. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  14. 14.
    Lacey, D., Jones, N.D., van Wyk, E., Frederiksen, C.C.: Proving correctness of compiler optimizations by temporal logic. In: POPL 2002, vol. 29, pp. 283–294 (2002)Google Scholar
  15. 15.
    Lerner, S., Millstein, T., Chambers, C.: Automatically proving the correctness of compiler optimizations. In: PLDI 2003, pp. 220–231. ACM Press, New York (2003)CrossRefGoogle Scholar
  16. 16.
    Liu, Y.A., Rothamel, T., Yu, F., Stoller, S.D., Hu, N.: Parametric regular path queries. In: PLDI 2004, pp. 219–230 (2004)Google Scholar
  17. 17.
    Padioleau, Y., Hansen, R.R., Lawall, J.L., Muller, G.: Semantic patches for documenting and automating collateral evolutions in Linux device drivers. In: PLOS 2006. Proc. of Workshop on Programming Languages and Operating Systems, p. 10 (2006)Google Scholar
  18. 18.
    Padioleau, Y., Lawall, J.L., Muller, G.: Understanding collateral evolution in Linux device drivers. In: EuroSys 2006, pp. 59–71 (2006)Google Scholar
  19. 19.
    Steffen, B.: Optimal run time optimization proved by a new look at abstract interpretation. In: Ehrig, H., Levi, G., Montanari, U. (eds.) CAAP 1987 and TAPSOFT 1987. LNCS, vol. 249, Springer, Heidelberg (1987)Google Scholar
  20. 20.
    Stuart, H., Hansen, R., Lawall, J.L., Andersen, J., Padioleau, Y., Muller, G.: Towards easing the diagnosis of bugs in OS code. In: PLOS 2007 (to appear, 2007)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2007

Authors and Affiliations

  • Neil D. Jones
    • 1
  • René Rydhof Hansen
    • 2
  1. 1.DIKU, Computer Science Dept., University of CopenhagenDenmark
  2. 2.Dept. of Computer Science, Aalborg UniversityDenmark

Personalised recommendations