All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alessandro Carminati <alessandro.carminati@gmail.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: cocci@inria.fr
Subject: Re: [cocci] List global variables with SmPL
Date: Wed, 11 May 2022 09:38:17 +0200	[thread overview]
Message-ID: <CAPp5cGQzYtDVjE-K_Vpt3cbqYW-cwNTLmt_KwdpMdds9L7rXug@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2205101236050.2667@hadrien>

[-- Attachment #1: Type: text/plain, Size: 3032 bytes --]

I'm planning to stop bugging this mailing list, but before that, please
allow me a final question. That is related to what I have done so far.
My current implementation is the following.
```
@excluded@
type T;
identifier i;
position p;
@@

(
 T i@p(...);
|
 extern T i@p;
|
 T i@p(...,......);
)


@r@
type T;
identifier i;
expression E;
position q != excluded.p;
position p : script:python(i) { p[0].current_element == i};
attribute name __randomize_layout;
@@

(
 T i@q@p;
|
 T i@q@p=E;
)

@rr@
type T;
identifier i;
expression E;
attribute name __randomize_layout;
@@

(
 T i;
|
 T i=E;
)

@script:python@
i << excluded.i;
@@
print (i)
```
It is a suboptimal version of Julia's last proposition.
It happens that in a file a statement I expect to be matched is not
detected.
Troubleshooting the issue, I see a behavior that does not fit the model I
have in my mind. This suggests to me that things (coccinelle under the hood
mechanisms) are more complicated than I think.
back to the point:
Running the script and printing only the rule "rr", which is the same as
"r" without positions, the results presents a set of entries containing the
entry I'm interested in.
Running the same script but printing only the rule "excluded", I see that
the result is an empty set.
Finally, running the script using only the "r" rule, the entry I'm
interested in is not there.

Surprisingly (for me), removing the position constraints coming from the
rule "excluded" (position q != excluded.p;) from the rule "r", the entry
appears.
My question then is the following: How can the rule "excluded" that
presents an empty set influence the rule "r"?
Speculating Julia's words on a previous answer I got, I guessed that
somehow an empty set could be treated differently, so I added a line into
the target c file to make at least "excluded" match one line. But it didn't
make any difference.

Alessandro



Il giorno mar 10 mag 2022 alle ore 12:39 Julia Lawall <julia.lawall@inria.fr>
ha scritto:

> Here is a suggested solution for all of the problems reported so far:
>
> @r@
> type T;
> identifier i;
> expression E;
> position p : script:python(i) { p[0].current_element == i };
> attribute name __randomize_layout;
> @@
>
> (
> T i(...);
> |
> T i(...,......);
> |
> extern T i;
> |
> T i@p;
> |
> T i@p=E;
> )
>
> @script:python@
> i << r.i;
> p << r.p;
> @@
> print (i)
>
> ----------------------
>
> The problem with __randomize_layout is that the Coccinelle parser is not
> recognizing it as an attribute.  You can force that by putting a
> declaration in the semantic patch.
>
> It seems that ... in a function parameter list does not match the ... in C
> for a variable list of arguments.  That ... can be matched explicitly by
> ...... so I have added another case with that.
>
> I als combined all of the patterns into one rule.  By inheriting the
> position varaible p into the python rule at the end, that python rule is
> only executed if p is defined, which makes it select the cases of interest
> and ignore the others.
>
> julia
>

[-- Attachment #2: Type: text/html, Size: 4017 bytes --]

  parent reply	other threads:[~2022-05-11  7:38 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09 10:05 [cocci] List global variables Alessandro Carminati
2022-05-09 10:11 ` Julia Lawall
2022-05-09 10:17 ` Julia Lawall
     [not found]   ` <CAPp5cGRMAOanfvuhV1LAV9eZka8ZJHRPy6ncMwO=Q+C=GUA2gA@mail.gmail.com>
2022-05-09 10:49     ` [cocci] Fwd: " Alessandro Carminati
2022-05-09 11:49       ` Julia Lawall
2022-05-09 19:23       ` [cocci] List global variables with SmPL Markus Elfring
2022-05-10  7:52         ` Alessandro Carminati
2022-05-10  8:06           ` Julia Lawall
2022-05-10  9:18             ` Alessandro Carminati
2022-05-10  9:24               ` Julia Lawall
2022-05-10  9:53                 ` Alessandro Carminati
2022-05-10 10:39                   ` Julia Lawall
2022-05-10 17:00                     ` Markus Elfring
2022-05-21 14:05                       ` Markus Elfring
2022-05-11  7:38                     ` Alessandro Carminati [this message]
2022-05-11  7:44                       ` Julia Lawall
2022-05-11  7:57                         ` Alessandro Carminati
2022-05-11  8:14                       ` Julia Lawall
2022-05-11  8:36                         ` Alessandro Carminati
2022-05-11  8:46                           ` Julia Lawall
2022-05-11 19:54                           ` Markus Elfring
2022-05-11 18:11                       ` Markus Elfring
2022-05-12  6:42                         ` Alessandro Carminati
2022-05-12 16:48                           ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPp5cGQzYtDVjE-K_Vpt3cbqYW-cwNTLmt_KwdpMdds9L7rXug@mail.gmail.com \
    --to=alessandro.carminati@gmail.com \
    --cc=cocci@inria.fr \
    --cc=julia.lawall@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.