Sable/soot — pull request #137 by richardxx (2013-10-17 13:44:53+00:00)
Title: Adding new querying methods for geom points-to analysis

Hi, Eric:

I just added a new querying interface (GeomQueries.java) for retrieving geom points-to result. This new interface enhances the standard SPARK interface for context sensitive querying. I believe users of soot may like it.

Currently, I have implemented two querying methods. The first is specifying any call edge in the full call chain to the enclosing method of querying pointer as context. For example, there are two chains to D:

A->B->D
A->C->D

We specify that "A" must be on the call chain. Therefore, both of the two call chains are selected. If we specify "B" must be on the chain, only A->B->D is selected.

This querying method is implemented in:

public boolean contexsByAnyCallEdge( Edge sootEdge, Local l, PtSensVisitor visitor )

, where "sootEdge" is the specified context, "l" is the local pointer, and "visitor" is used to hold the querying results. "visitor" can be an instance of "Obj_full_extractor" class. A sample usage code is:

PtSensVisitor objFull = new Obj_full_extractor();
Local l = sm.getActiveBody().getThisLocal();

// Obtain context edges
Iterator it = cg.edgesOutOf(mainMethod);
while ( it.hasNext() ) {
Edge e = it.next();
if ( !e.isVirtual() ) continue;

objFull.prepare();
if ( queries.contexsByAnyCallEdge(e, l, objFull) ) {
objFull.finish();
// do what you like
}
}

Users can read "Obj_full_extractor.java" to learn how to use this class. That class is really simple.

The second querying interface is for querying K-CFA results. Users can specify last K call edges as the contexts, instead of only one in the SPARK interface. The interface is:

public boolean contextsByCallChain(Edge[] callEdgeChain, Local l, PtSensVisitor visitor)

For example, A->B->C is the last three edges in the call chain, call this function with:

callEdgeChain[0] = A
callEdgeChain[1] = B
callEdgeChain[2] = C

This only a start for my improvement work. I will continue to add new stuff.

Cheers,
Xiao