Coccinelle archive on lore.kernel.org
 help / color / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Coccinelle <cocci@systeme.lip6.fr>
Subject: [Cocci] Data exchange over network interfaces by SmPL scripts
Date: Thu, 25 Apr 2019 10:06:02 +0200
Message-ID: <30df39b4-6f45-45c7-1c37-1f8991f3f6e2@web.de> (raw)
In-Reply-To: <bed744fe-5c5c-cf28-f8b2-40a487709010@web.de>

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

> Is there still a need to perform parallelisation for the mentioned software
> components by other approaches?

The multi-processing support by the Coccinelle software triggers some
development challenges.
If data should be shared between started (background) processes,
an external system need to be selected for the desired storage service.
Thus I would like to send these data over network interfaces by the attached
script for the evolving semantic patch language.

I stumble on the following error message.

elfring@Sonne:~/Projekte/Coccinelle/janitor> /usr/local/bin/spatch -D server_id=localhost -D server_port=1234 list_duplicate_statement_pairs_from_if_branches-client2.cocci ~/Projekte/Linux/next-patched/drivers/media/dvb-frontends/stv0297.c
…
Using Python version:
2.7.15 (default, May 21 2018, 17:53:03) [GCC]
…
Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "<string>", line 34, in store_statements
AttributeError: __exit__
Error in Python script, line 55, file …


I would appreciate if the shown data processing approach can work with
version ranges of involved recent software components.
So I am looking for additional solution ideas.

Regards,
Markus

[-- Attachment #2: list_duplicate_statement_pairs_from_if_branches-client2.cocci --]
[-- Type: text/plain, Size: 1406 bytes --]

@initialize:python@
server_id << virtual.server_id;
server_port << virtual.server_port;
@@
import json, socket, struct, sys
sys.stderr.write("Using Python version:\n%s\n" % (sys.version))

if server_id == False:
   server_id = "localhost"

if server_port == False:
   server_port = 1234

def store_statements(fun, source, s1, s2):
    """Send data for the service."""
    records = []

    for place in source:
       records.append('{"name":%s,"file":%s,"line":%s,"column":%s,"s1":%s,"s2":%s}'
                      % (json.dumps(fun),
                         json.dumps(place.file),
                         json.dumps(place.line),
                         json.dumps(int(place.column) + 1),
                         json.dumps(s1),
                         json.dumps(s2)))

    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as so:
         so.connect((server_id, server_port))
         result = "[\n"
         result += ",\n".join(records)
         result += "]"
         b = bytes(result)
         p = struct.pack(">I", len(b))
         p += b
         so.sendall(p)

@searching exists@
identifier work;
statement s1, s2;
position pos;
type T;
@@
 T work(...)
 {
 ... when any
 if (...)
 {
 ... when any
 s1@pos
 s2
 }
 ... when any
 }

@script:python collection@
fun << searching.work;
s1 << searching.s1;
s2 << searching.s2;
place << searching.pos;
@@
store_statements(fun, place, s1, s2)

[-- Attachment #3: Type: text/plain, Size: 136 bytes --]

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

  parent reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-20 18:50 [Cocci] Checking import of code search results into a table by parallel SmPL data processing Markus Elfring
     [not found] ` <alpine.DEB.2.21.1904202112150.2499@hadrien>
2019-04-20 19:31   ` Markus Elfring
2019-04-23  9:48   ` Markus Elfring
2019-04-24  6:25 ` [Cocci] Rejecting parallel execution of SmPL scripts Markus Elfring
2019-04-25  8:06 ` Markus Elfring [this message]
     [not found]   ` <alpine.DEB.2.21.1904251039000.2550@hadrien>
2019-04-25 10:32     ` [Cocci] Data exchange over network interfaces by " Markus Elfring
2019-04-27 17:20       ` Markus Elfring
2019-04-27 17:24       ` Markus Elfring
2019-04-30  8:55         ` Markus Elfring
2019-06-01 11:13         ` Markus Elfring
2019-04-25 18:12 ` [Cocci] Data exchange through message queue " Markus Elfring

Reply instructions:

You may reply publically 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=30df39b4-6f45-45c7-1c37-1f8991f3f6e2@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@systeme.lip6.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

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr cocci@archiver.kernel.org
	public-inbox-index cocci


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/ public-inbox