All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] Embedding Meta-variables in added Comments using semantic patchesز
@ 2018-08-28  7:36 Moustafa Mahmoud
  2018-08-28 10:53 ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Moustafa Mahmoud @ 2018-08-28  7:36 UTC (permalink / raw)
  To: cocci

this semantic patch doesn't produce the required behavioir

@annotate_if_conditions@
expression ex;
@@

<+...
+ /* ex */
if(ex){...}
...+>


it produces the following

     int x =5;
     int y =6;
     int m =funct();
+    /* ex */   // the required behavoir I need is  /* x */
     if(x)
     {
+       /* ex */
        if(y)
        {
            return 1;

Regards,
Moustafa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20180828/47bf471a/attachment.html>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Cocci] Embedding Meta-variables in added Comments using semantic patchesز
  2018-08-28  7:36 [Cocci] Embedding Meta-variables in added Comments using semantic patchesز Moustafa Mahmoud
@ 2018-08-28 10:53 ` Julia Lawall
  2018-08-29  1:52   ` Moustafa Mahmoud
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2018-08-28 10:53 UTC (permalink / raw)
  To: cocci



On Tue, 28 Aug 2018, Moustafa Mahmoud wrote:

> this semantic patch doesn't produce the required behavioir
>
> @annotate_if_conditions@
> expression ex;
> @@
>
> <+...
> + /* ex */
> if(ex){...}
> ...+>
>
>
> it produces the following?
>
> ? ? ?int x =5;
> ? ? ?int y =6;
> ? ? ?int m =funct();
> +? ? /* ex */? ?// the required behavoir I need is? /* x */
> ? ? ?if(x)
> ? ? ?{
> +? ? ? ?/* ex */
> ? ? ? ? if(y)
> ? ? ? ? {
> ? ? ? ? ? ? return 1;

Sorry, it doesn't work.  Currently the only tihng you can do is use python
to make an identifier metavariable that actually contains a comment, and
then add that metavariable where you want your comments.  By your comments
will have to have a ; after them, and are thus better made with // than
with /* */, because an identifier is not a valid statement by itself.
Instead you need an identifier followed by a semicolon.

For using python to make an identifier metavariable please see
demos/pythontococci.{c,cocci,res}.  Please write back if it is not clear.

julia

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Cocci] Embedding Meta-variables in added Comments using semantic patchesز
  2018-08-28 10:53 ` Julia Lawall
@ 2018-08-29  1:52   ` Moustafa Mahmoud
  2018-08-29  2:52     ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Moustafa Mahmoud @ 2018-08-29  1:52 UTC (permalink / raw)
  To: cocci

Thanks alot for your reply. I will look into this option .
I was hoping to use coccinelle to annotate some c code so that I would
later parse it to determine the program flow.

Is there a way to get more information from -show-ctrl-flow switch in
coccinelle ? It only shows "if" nodes without the expression s inside them
in dot graph ?

Thanks alot


On Tue, Aug 28, 2018, 12:53 PM Julia Lawall <julia.lawall@lip6.fr> wrote:

>
>
> On Tue, 28 Aug 2018, Moustafa Mahmoud wrote:
>
> > this semantic patch doesn't produce the required behavioir
> >
> > @annotate_if_conditions@
> > expression ex;
> > @@
> >
> > <+...
> > + /* ex */
> > if(ex){...}
> > ...+>
> >
> >
> > it produces the following
> >
> >      int x =5;
> >      int y =6;
> >      int m =funct();
> > +    /* ex */   // the required behavoir I need is  /* x */
> >      if(x)
> >      {
> > +       /* ex */
> >         if(y)
> >         {
> >             return 1;
>
> Sorry, it doesn't work.  Currently the only tihng you can do is use python
> to make an identifier metavariable that actually contains a comment, and
> then add that metavariable where you want your comments.  By your comments
> will have to have a ; after them, and are thus better made with // than
> with /* */, because an identifier is not a valid statement by itself.
> Instead you need an identifier followed by a semicolon.
>
> For using python to make an identifier metavariable please see
> demos/pythontococci.{c,cocci,res}.  Please write back if it is not clear.
>
> julia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20180829/e576f045/attachment.html>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Cocci] Embedding Meta-variables in added Comments using semantic patchesز
  2018-08-29  1:52   ` Moustafa Mahmoud
@ 2018-08-29  2:52     ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2018-08-29  2:52 UTC (permalink / raw)
  To: cocci



On Wed, 29 Aug 2018, Moustafa Mahmoud wrote:

> Thanks alot for your reply. I will look into this option .I was hoping to
> use coccinelle to annotate some c code so that I would later parse it to
> determine the program flow.
>
> Is there a way to get more information from -show-ctrl-flow switch in
> coccinelle ? It only shows "if" nodes without the expression s inside them
> in dot graph ?

No, nothing is provided for that.  I think that the feeling was that the
expressions could be quite big, and the graph would become unreadable.  Of
course, if you want to do some other processing of the graph, you don't
care about that.

If you are willing to write OCaml code, maybe you would be better off to
just run the parser and the construction of the control-flow graph, and
then do what you want with the resulting data structure.  It is possible
to make the implementation of Coccinelle into a library that you can link
your own OCaml code with and then call the functions from the Coccinelle
infrastructure that you want.

julia

>
> Thanks alot
>
>
> On Tue, Aug 28, 2018, 12:53 PM Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
>       On Tue, 28 Aug 2018, Moustafa Mahmoud wrote:
>
>       > this semantic patch doesn't produce the required behavioir
>       >
>       > @annotate_if_conditions@
>       > expression ex;
>       > @@
>       >
>       > <+...
>       > + /* ex */
>       > if(ex){...}
>       > ...+>
>       >
>       >
>       > it produces the following?
>       >
>       > ? ? ?int x =5;
>       > ? ? ?int y =6;
>       > ? ? ?int m =funct();
>       > +? ? /* ex */? ?// the required behavoir I need is? /* x */
>       > ? ? ?if(x)
>       > ? ? ?{
>       > +? ? ? ?/* ex */
>       > ? ? ? ? if(y)
>       > ? ? ? ? {
>       > ? ? ? ? ? ? return 1;
>
>       Sorry, it doesn't work.? Currently the only tihng you can do is
>       use python
>       to make an identifier metavariable that actually contains a
>       comment, and
>       then add that metavariable where you want your comments.? By
>       your comments
>       will have to have a ; after them, and are thus better made with
>       // than
>       with /* */, because an identifier is not a valid statement by
>       itself.
>       Instead you need an identifier followed by a semicolon.
>
>       For using python to make an identifier metavariable please see
>       demos/pythontococci.{c,cocci,res}.? Please write back if it is
>       not clear.
>
>       julia
>
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-29  2:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-28  7:36 [Cocci] Embedding Meta-variables in added Comments using semantic patchesز Moustafa Mahmoud
2018-08-28 10:53 ` Julia Lawall
2018-08-29  1:52   ` Moustafa Mahmoud
2018-08-29  2:52     ` Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.