python - Finding the input dependencies of a functions outputs -


i've been working on python program pycparser supposed generate json-file dependencies of given function , outputs. example function:

int test(int testinput) {     int b = testinput;     return b; } 

here expect b dependent on testinput. ofcourse can lot more complicated structs , if-statements etc. files i'm testing have functions in specific form considered inputs , outputs in:

int test(int testinput) {     int anotherinput = databaseread(variableindatabase);     int b = testinput;     int c;      c = anotherinput + 1;     databasewrite(c);     return b; } 

here c dependent on variableindatabase, , b same before. i've run wall analysis in pycparser structs , pointers hard me handle, , seems there'd better way. i've read asts , cfgs, , other analysis tools frama-c can't seem find clear answer if thing.

is there known way kind of analysis, , if so, should looking into? it's supposed thousands of files , able output these dependencies json, plugins editors doesn't seem i'm looking for.

you need data flow analysis of code, , want follow data flow backwards result sources, stopping point (in case, stopped @ function parameter want stop @ global variable).

this called program slicing in literature.

computing data flows pretty hard, if have complex language (c fun: can have data flows through indirectly called functions read values; need indirect points-to analysis support data flow, , vice versa).

here's fun example:

 // ocean of functions:  ...  int a(){ return b; }  ...  int p(){ return q; }  ...   void foo( int()* x )  {  return (*x)(); } 

does foo depend on b? on q? can't know unless know foo calls or b. foo handed function pointer... , might point to?

using asts , cfgs necessary not sufficient; data flow analysis algorithms hard, if have scale (as suggest do); need lot of machinery not easy build [we've done on c programs of 16 million lines]. see essay on life after parsing.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -