rohanpadhye / vasco

An inter-procedural data-flow analysis framework using value-based context sensitivity
GNU Lesser General Public License v2.1
87 stars 35 forks source link

Basic Call Flow Functions Implementation #8

Closed oparisy closed 6 years ago

oparisy commented 6 years ago

I tried my hand at Vasco by solving documented variable liveness problems (as provided by the "Data Flow Analysis - Theory and Practice" book).

The intraprocedural implementation was straightforward (the only gotcha being that I forgot to override the equals method of my dataflow values class, which proved crucial for algorithm termination).

I kind of struggled with interprocedural-related methods, though. Considering that those problems only use global variables and calls with no parameters nor return value, I finally got satisfying results by using this implementation:

    @Override
    public FlowValue callEntryFlowFunction(Context<CFG, Node, FlowValue> context, CFG targetMethod, Node node, FlowValue inValue) {
        return inValue; // No parameters
    }

    @Override
    public FlowValue callExitFlowFunction(Context<CFG, Node, FlowValue> context, CFG targetMethod, Node node, FlowValue exitValue) {
        return exitValue; // No return value
    }

    @Override
    public FlowValue callLocalFlowFunction(Context<CFG, Node, FlowValue> context, Node node, FlowValue inValue) {
        return TOP; // We have no local variables
    }

Could you confirm that this is a proper setup for this category of language (no local variables nor calls parameters)? And perhaps detail the general contract of those methods?

Regards, Olivier.

rohanpadhye commented 6 years ago

Hi Olivier,

I'm glad you were able to implement sample analyses in VASCO. Your implementation seems perfect for the case where you have only global variables and no locals. I see that while the API itself is documented, perhaps VASCO lacks a how-to guide to approach writing an analysis. Maybe I can write one some time.

PS: You seem to have a very good understanding of the VASCO internals as well as its use cases. If you would like to add material to the project (e.g. more sample analyses or improving documentation based on your experience), feel free to send a pull request.

oparisy commented 6 years ago

Thanks Rohan! Dully noted.