On Fri, 19 Mar 2021, Thomas Adam wrote:

> On Thu, 18 Mar 2021 at 19:24, Julia Lawall <julia.law...@inria.fr> wrote:
>
> > The ... in Coccinelle is based on control flow, so it is a bit hard to
> > find the return at the bottom of the function.  Actually, from
> > Coccinelle's point of view, all returns are at the bottom of the function,
> > because one leaves the function after a return.
>
> Interesting, that helps me understand a little more about Coccinelle.  Thanks.
>
> > You can try the following:
> >
> > @r@
> > position p;
> > identifier f;
> > }
> >
> > f(...) {
> > <...
> > { .. return@p; }
> > ...>
> > }
> >
> > @@
> > position p != r.p;
> > @@
> >
> > - return@p;
>
> So I tried this:
>
> @r@
> position p;
> identifier f;
> @@
>
> f(...) {
> <...
>    { ... return@p; }
> ...>
> }
>
> @@
> position p != r.p;
> @@
>
> - return@p;
>
> Which I ran as:
>
> spatch --in-place --debug --iso-file contrib/coccinelle/empty.iso \
>     --sp-file ./contrib/coccinelle/remove-void-return.cocci --dir fvwm
>
> With "--dir fvwm", I found that my CPU was being chewed at 100%, which I left
> running overnight.  Some 8 hours later, spatch was still running.  Presumably,
> Coccinelle is having an interesting time coordinating the positions?
>
> Instead, I decided to loop over the .c files which "--dir fvwm" would have
> done.  What I found was that for some files, spatch took a few seconds, and
> produced no output, yet for some, spatch was still running without any result
> known (so I killed it).
>
> Indeed, I'm attaching a debug run of spatch to this email (cocci-debug) for
> one file that definitely has functions where I would expect Coccinelle to have
> matched a "return;" statement to be removed, but this wasn't the case.
>
> Would you be able to suggest what I might have done wrong, or if there's any
> additional debugging I can provide?

If Coccinelle gets stuck on one part of a file, it won't move on to the
next part.  So the fact that the something should have been done in the
file is not really helpful.

You can use the argument --show-trying to see what function it is working
on at the moment.

You can use --timeout N to limit the treatment of a given file to N
seconds.

It may help to replace @r@ by @r exists@.

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to