Hello, Thanks one more time for your help.
On Fri, 2011-08-12 at 15:41 +0200, Julia Lawall wrote:
> Programming beyond print in python is completely beyond me :)
I've finally fix the issue. spatch was started before the temporary
cocci file was written to the FS. And it was crashing because of an
incomplete file...
>
> It looks like maybe there is something unexpected in the .cocci file.
>
> Perhaps you want what I call command line Coccinelle in the new
> (1.0.0-rc5) release? Now you can say:
>
> spatch -sp "E->Fld" file
>
> to find all of the structure field dereferences in file, or more
> interestingly:
>
> spatch -sp "e:struct foo *:->Fld" file
>
> to find only those where the structure has type struct foo *. By default,
> anything that begins with a capital letter is a metavariable. You can
> also declare a metavariable by concatenating the variable name with ::,
> with the type of the metavariable between the colons.
>
> You can also use ..., and when, but the argument to when has to be a
> single token (eg an identifier name or a metavariable).
Oups, I will need to read more than twice to get everything but this -sp
option seems great: I've managed to do at least one of the thing I was
wanting to do !
BR,
>
> julia
>
>
> On Fri, 12 Aug 2011, Eric Leblond wrote:
>
> > Hello,
> >
> > I'm currently trying to code a semantic grep using coccinelle (By the
> > way, if there is one tell me;). I did not find better than making a
> > python script calling spatch...
> >
> > If the grep code like is easy to build with coccinelle, I've got some
> > difficulty to call coccinelle with python using for example "call"
> > function of the subprocess module:
> >
> > # launch spatch
> > cmd = ["spatch", "-sp_file", tmp_cocci_file.name, file_name]
> > print "running: %s." % " ".join(cmd)
> >
> > output = call(cmd)
> >
> > Running the script does:
> > eric@tiger:~/git/coccigrep (master) $ python ./coccigrep.py
> > running: spatch -sp_file /tmp/tmpoiump0.cocci
> > /home/eric/git/oisf/src/detect-noalert.c.
> > init_defs_builtins: /usr/share/coccinelle/standard.h
> > Fatal error: exception Failure("unexpected code before the first rule
> > ")
> > 2
> >
> >
> > Running the command is ok:
> >
> > eric@tiger:~/git/coccigrep (master) $ spatch
> > -sp_file /tmp/tmpoiump0.cocci /home/eric/git/oisf/src/detect-noalert.c
> > init_defs_builtins: /usr/share/coccinelle/standard.h
> > HANDLING: /home/eric/git/oisf/src/detect-noalert.c
> > /home/eric/git/oisf/src/detect-noalert.c:49:
> > SCLogError(SC_ERR_INVALID_VALUE, "nocase has no value");
> > return -1;
> > }
> >
> > s->flags |= SIG_FLAG_NOALERT;
> > return 0;
> > }
> >
> > If I use Popen without argument, everything is fine.
> >
> > Any idea ?
> >
> > BR,
> > --
> > Eric Leblond
> > Blog: http://home.regit.org/
> >
--
Eric Leblond
Blog: http://home.regit.org/
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
