Coccinelle archive on lore.kernel.org
 help / color / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
Cc: Coccinelle <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] Data exchange over network interfaces by SmPL scripts
Date: Sat, 27 Apr 2019 19:24:40 +0200
Message-ID: <6ec5b70f-39c3-79e5-608f-446a870f02f3@web.de> (raw)
In-Reply-To: <2f138dc8-74cd-3766-cc78-c4bace8579c0@web.de>

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

> connecting
>   File "<string>", line 35, in store_statements
> socket.gaierror: [Errno -2] Name or service not known
> Error in Python script, line 56, file …

It seems that the attached adjusted data processing approach can produce
an usable analysis result.

elfring@Sonne:~/Projekte/Coccinelle/janitor> time /usr/bin/python3 list_duplicate_statement_pairs_from_if_branches-server4.py
statement1|statement2|"function name"|"source file"|incidence
dprintk ( "%s: readreg error (reg == 0x%02x, ret == %i)\n" , __func__ , reg , ret ) ;|return - 1 ;|stv0297_readreg|/home/elfring/Projekte/Linux/next-patched/drivers/media/dvb-frontends/stv0297.c|3
dprintk ( "%s: readreg error (reg == 0x%02x, ret == %i)\n" , __func__ , reg1 , ret ) ;|return - 1 ;|stv0297_readregs|/home/elfring/Projekte/Linux/next-patched/drivers/media/dvb-frontends/stv0297.c|3

real	0m1,044s
user	0m0,389s
sys	0m0,055s


Unfortunately, I observed during a few runs on my test system
that the displayed record sets can vary. Thus I guess that this approach
(which works together with Python multi-threading functionality) will need
further software adjustments.
Would you like to add any advices here?

Regards,
Markus

[-- Attachment #2: list_duplicate_statement_pairs_from_if_branches-server4.py --]
[-- Type: text/x-python, Size: 4454 bytes --]

[-- Attachment #3: list_duplicate_statement_pairs_from_if_branches-client3.cocci --]
[-- Type: text/plain, Size: 1483 bytes --]

@initialize:python@
s_id << virtual.server_id;
s_port << virtual.server_port;
@@
import json, socket, struct, sys

if s_id == False:
   s_id = "localhost"

target = s_id, int(s_port) if s_port else 1234
sys.stderr.write("Using Python version:\n%s\n" % (sys.version))
sys.stderr.write('Connections will be tried with server “%s” on port “%d”.\n'
                 % target)

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(target)
        result = "[\n"
        result += ",\n".join(records)
        result += "\n]"
        b = bytes(result, "utf8")
        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 #4: 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 ` [Cocci] Data exchange over network interfaces by " Markus Elfring
     [not found]   ` <alpine.DEB.2.21.1904251039000.2550@hadrien>
2019-04-25 10:32     ` Markus Elfring
2019-04-27 17:20       ` Markus Elfring
2019-04-27 17:24       ` Markus Elfring [this message]
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=6ec5b70f-39c3-79e5-608f-446a870f02f3@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