on 21/10/2010 16:23 Julia Lawall said the following:
> You can make the following definition in a file mymacros.h, and then run
> coccinelle with the argument -macro_file mymacros.h
>
> #define LIST_HEAD(x,y) struct unknown
>
> spatch will still complain a little bit, if you have verbose parser error
> messages, but it can cope in the end.
Thank you for the advice!
I tried it and it works.
But now I have a slightly different problem. Not sure if it's related or if it
is
because of some mistake of mine in my cocci script.
The script:
@r@
type S;
identifier x;
typedef cpumask_t;
@@
S { ...
* cpumask_t x;
...
};
The idea is to find all fields of type cpumask_t in all structs/unions (compound
types).
Invocation:
$ spatch -debug -verbose_parsing -macro_file cocci_macros.h -sp_file
~/tmp/cpumask_t.2.cocci /usr/src/sys/sys/_rmlock.h
Output:
init_defs_builtins: /usr/local/share/coccinelle/standard.h
init_defs: cocci_macros.h
-----------------------------------------------------------------------
processing semantic patch file: /home/avg/tmp/cpumask_t.2.cocci
with isos from: /usr/local/share/coccinelle/standard.iso
-----------------------------------------------------------------------
@r@
type S;
identifier x;
typedef cpumask_t;
@@
S { ...
* cpumask_t x;
...
};
HANDLING: /usr/src/sys/sys/_rmlock.h
-----------------------------------------------------------------------
let's go
-----------------------------------------------------------------------
ERROR-RECOV: found sync '}' at line 54
ERROR-RECOV: found sync bis, eating } and ;
parsing pass2: try again
ERROR-RECOV: found sync '}' at line 54
ERROR-RECOV: found sync bis, eating } and ;
parsing pass3: try again
ERROR-RECOV: found sync '}' at line 64
ERROR-RECOV: found sync bis, eating } and ;
parsing pass2: try again
ERROR-RECOV: found sync '}' at line 64
ERROR-RECOV: found sync bis, eating } and ;
parsing pass3: try again
-----------------------------------------------------------------------
r =
-----------------------------------------------------------------------
dependencies for rule r satisfied:
binding in = []
binding relevant in = []
(ONCE) USING optional_qualifier builtin isomorphism
transformation info returned:
transform state: 1
with rule_elem: r:S {...
*cpumask_t *r:x*;
...};
with binding: []
binding out = []
transform one node
parse error
= error in /tmp/cocci_small_output-71873-9af21c.c; set verbose_parsing for
more info
badcount: 10
bad:
bad:
bad: struct rmlock {
bad: struct lock_object lock_object;
bad: volatile
BAD:!!!!! structunknownLIST_HEAD(,rm_priotracker) rm_activeReaders;
bad: union {
bad: struct mtx _rm_lock_mtx;
bad: struct sx _rm_lock_sx;
bad: } _rm_lock;
bad: };
-----------------------------------------------------------------------
Finished
-----------------------------------------------------------------------
parse error
= error in /tmp/cocci-output-71873-c4fbfc-_rmlock.h; set verbose_parsing for
more
info
badcount: 10
bad: LIST_HEAD(rmpriolist,rm_priotracker);
bad:
bad: struct rmlock {
bad: struct lock_object lock_object;
bad: volatile
BAD:!!!!! structunknownLIST_HEAD(,rm_priotracker) rm_activeReaders;
bad: union {
bad: struct mtx _rm_lock_mtx;
bad: struct sx _rm_lock_sx;
bad: } _rm_lock;
bad: };
diff =
--- /usr/src/sys/sys/_rmlock.h 2010-10-21 16:27:29.871751726 +0300
+++ /tmp/cocci-output-71873-c4fbfc-_rmlock.h 2010-10-21 16:33:21.919414848
+0300
@@ -45,8 +45,6 @@ LIST_HEAD(rmpriolist,rm_priotracker);
struct rmlock {
struct lock_object lock_object;
- volatile cpumask_t rm_writecpus;
- LIST_HEAD(,rm_priotracker) rm_activeReaders;
union {
struct mtx _rm_lock_mtx;
struct sx _rm_lock_sx;
Check duplication for 1 files
Hmm, so rm_activeReaders lines looks like a mix of expanded and unexpanded macro
LIST_HEAD and in the end coccinelle marks that line too.
Is it perhaps because of the 'volatile' keyword on rm_writecpus line (the
previous
one)?
Perhaps the script needs to be changed so that 'volatile' is included into the
matching line?
--
Andriy Gapon
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)