Coccigrep improved func operation

Coccigrep 1.11 is now available and mainly features some improvements related to the func search. The func operation can be used to search when a structure is used as argument of a function. For example, to search where the Packet structures are freed inside Suricata project, one can run: $ coccigrep -t Packet -a "SCFree" -o func src/ src/alert-unified2-alert.c:1156 (Packet *p): SCFree(p); src/alert-unified2-alert.c:1161 (Packet *p): SCFree(p); ... src/alert-unified2-alert.c:1368 (Packet *pkt): SCFree(pkt); ...

10 septembre 2012 · 1 min · Regit

Set or unset define variables in Coccigrep

Following a discussion with the great Julia Lawall, she added a new feature in coccinelle: it is now possible to define as set or unset some variables. This option has been added in coccigrep 1.9 and requires coccinelle 1.0-rc14. For example, let’s have a code like Suricata where a lot of unit tests are implemented. The structure of the code is the following: REGULAR CODE #ifdef UNITTESTS TEST CODE #endif When doing search in the regular code, you don’t want to be bothered by results found in the test code. To obtain this result, you can pass the -U UNITTESTS option to coccigrep to tell him to consider UNITTESTS variable as undefined. If you want to define a variable, you can use the -D flag. ...

31 juillet 2012 · 1 min · Regit

What’s new in coccigrep 1.6?

I did not write any article on coccigrep since the 1.0 release. Here is an update on what has been added to the software since that release. C++ support Coccinelle has a basic C++ support which can be activated by using the –cpp flag in coccigrep. Patches information The -L -v options on command line will display a description of the match available on the system. $ coccigrep -L -v set: Search where a given attribute of structure 'type' is set * Confidence: 80% * Author: Eric Leblond <eric@regit.org> * Arguments: type, attribute * Revision: 2 For the developer, this is obtained from structured comments put at the start of the cocci file: ...

7 novembre 2011 · 2 min · Regit

Eric Leblond: Introduction to coccinelle

The Netfilter workshop being a developer conference, I’ve decided to presente an introduction to the coccinelle tool. Coccinelle is a program matching and transformation engine for the C language which is used in many place and among them in the Linux kernel. It is able to perform C clever modification in the code. If you ever had to modify multiple code files following an API change, I invite you to have a look at the slides or my Coccinelle for the newbie page. I’ve also presented my coccigrep tool which is a easy to use semantic grep. ...

24 août 2011 · 1 min · Regit

Coccigrep, a semantic grep for the C language

Introduction When diving in some code with a relative important size, I’ve often ask myself: where is this attribute used for this structure ? Where it is set ? Using grep is not a good answer to theses questions: you can’t guess the name of the variable of a given type and even an attribute name can be shared between multiple structures. I was in need of a semantic grep! ...

15 août 2011 · 2 min · Regit