Introduction to Semantic Patching of C and C++ Programs with Coccinelle

This is an on-site course at LRZ in Garching near Munich. There will be no possibility to join online remotely via video conference. Participants are expected to bring their own laptops. There are no PCs installed in the course room! 

Contents

"Coccinelle is a program matching and transformation engine which provides the language SmPL (Semantic Patch Language) for specifying desired matches and transformations in C code, and increasingly C++. Coccinelle was initially targeted towards performing collateral evolutions in Linux. Such evolutions comprise the changes that are needed in client code in response to evolutions in library APIs, and may include modifications such as renaming a function, adding a function argument whose value is somehow context-dependent, and reorganizing a data structure. Beyond collateral evolutions, Coccinelle is successfully used (by us and others) for finding and fixing bugs in systems code, and restructuring large codebases.'' (https://coccinelle.gitlabpages.inria.fr/website/)

 

The maintenance of a large software project can be very demanding. External factors like evolving third-party software library APIs, or constantly changing hardware platforms might require significant code adaptions for the code to run efficiently, or to run at all. Failure in coping with this can lead to obsolescence, loss of performance, incompatibility, vendor lock-in, bugs.

Have you ever wondered how to detect and manipulate specified C/C++ code constructs, be it for code analysis, or better, to restructure an arbitrarily large codebase according to a specified, non-trivial `pattern', without writing a source-to-source translator yourself, but using an existing programmable one?

In this training we introduce you to a tool to do exactly this: match and restructure code in a programmatic, formal way.

After this training, you shall be able to write your own code transformations, be it for a refactoring, performance improvement, paving the way to an experimental fork, or for debug/analysis reasons.

The training will also show how to analyse code looking for interesting patterns (e.g. bugs), integrate your Python scripts to achieve the custom transformations you need, and leverage Coccinelle's increasing C++ support.
 
Special mention will go to performance-oriented transformations, of interest of HPC practitioners.

Tentative program:

  • Invoking Coccinelle. Important command line options.
  • Semantic matching. Matching C language constructs.
  • Semantic patching. Modifying C language constructs.
  • Elements of the SmPL language. SmPL patch structure, rules.
  • Simple SmPL rules. Overview of matchable items.
  • Rules with inheritance. Reusing rules: multiple patches for complex transformations.
  • Scripting. Extensions and customisation.
  • Review of common transformations and use cases in HPC. Examples of what to do and what NOT to do.
  • Hands-on exercises.

Contents are subject to modifications.

Prerequisites

Good C/C++ knowledge required. HPC experience recommended.

Hands-On

tbd

Language

English

Lecturers

Dr. Michele Martone (LRZ)

Prices and Eligibility

The course is open and free of charge for people from academia and industry from the Member States of the European Union and Associated/Other Countries to the Horizon 2020 programme.

Registration

Please register with your official e-mail address to prove your affiliation. 

Withdrawal Policy

See Withdrawal

Legal Notices

For registration for LRZ courses and workshops we use the service edoobox from Etzensperger Informatik AG (www.edoobox.com). Etzensperger Informatik AG acts as processor and we have concluded a Data Processing Agreement with them.

See Legal Notices

Online Course Introduction to Semantic Patching of C and C++ Programs with Coccinelle
Number hspc1w24
Available places 29
Date 22.01.2025 – 22.01.2025
Price EUR 0.00
Location Leibniz Rechenzentrum
Boltzmannstr. 1
85748 Garching b. München
Room Kursraum 2
Registration deadline 15.01.2025 22:59
E-mail [email protected]
No. Date Time Teacher Location Room Description
1 22.01.2025 09:30 – 17:30 Michele Martone Leibniz Rechenzentrum Kursraum 2 Lecture