use of soot.jimple.spark.pag.Node in project soot by Sable.
the class GeomPointsTo method transformToCIResult.
/**
* For many applications, they only need the context insensitive points-to result.
* We provide a way to transfer our result back to SPARK.
* After the transformation, we discard the context sensitive points-to information.
* Therefore, if context sensitive queries are needed in future, please call ddSolve() for queried pointers first.
*/
public void transformToCIResult() {
for (IVarAbstraction pn : pointers) {
if (pn.getRepresentative() != pn)
continue;
Node node = pn.getWrappedNode();
node.discardP2Set();
PointsToSetInternal ptSet = node.makeP2Set();
for (AllocNode obj : pn.get_all_points_to_objects()) {
ptSet.add(obj);
}
pn.deleteAll();
}
hasTransformed = true;
}
use of soot.jimple.spark.pag.Node in project soot by Sable.
the class OfflineProcessor method addUserDefPts.
/**
* Compute the refined points-to results for specified pointers.
* @param initVars
*/
public void addUserDefPts(Set<Node> initVars) {
for (Node vn : initVars) {
IVarAbstraction pn = geomPTA.findInternalNode(vn);
if (pn == null) {
// I don't know where is this pointer
continue;
}
pn = pn.getRepresentative();
if (pn.reachable()) {
pn.willUpdate = true;
}
}
}
use of soot.jimple.spark.pag.Node in project soot by Sable.
the class OfflineProcessor method buildDependenceGraph.
/**
* The dependence graph reverses the assignment relations. E.g., p = q => p -> q
* Note that, the assignments that are eliminated by local variable merging should be used here.
* Otherwise, the graph would be erroneously disconnected.
*/
protected void buildDependenceGraph() {
for (PlainConstraint cons : geomPTA.constraints) {
// In our constraint representation, lhs -> rhs means rhs = lhs.
final IVarAbstraction lhs = cons.getLHS();
final IVarAbstraction rhs = cons.getRHS();
final SparkField field = cons.f;
IVarAbstraction rep;
// Now we use this constraint for graph construction
switch(cons.type) {
// rhs = lhs
case Constants.ASSIGN_CONS:
add_graph_edge(rhs.id, lhs.id);
break;
// rhs = lhs.f
case Constants.LOAD_CONS:
{
rep = lhs.getRepresentative();
if (rep.hasPTResult() == false) {
lhs.getWrappedNode().getP2Set().forall(new P2SetVisitor() {
@Override
public void visit(Node n) {
IVarAbstraction padf = geomPTA.findInstanceField((AllocNode) n, field);
if (padf == null || padf.reachable() == false)
return;
off_graph_edge e = add_graph_edge(rhs.id, padf.id);
e.base_var = lhs;
}
});
} else {
// Use geom
for (AllocNode o : rep.get_all_points_to_objects()) {
IVarAbstraction padf = geomPTA.findInstanceField((AllocNode) o, field);
if (padf == null || padf.reachable() == false)
continue;
off_graph_edge e = add_graph_edge(rhs.id, padf.id);
e.base_var = lhs;
}
}
}
break;
// rhs.f = lhs
case Constants.STORE_CONS:
{
rep = rhs.getRepresentative();
if (rep.hasPTResult() == false) {
rhs.getWrappedNode().getP2Set().forall(new P2SetVisitor() {
@Override
public void visit(Node n) {
IVarAbstraction padf = geomPTA.findInstanceField((AllocNode) n, field);
if (padf == null || padf.reachable() == false)
return;
off_graph_edge e = add_graph_edge(padf.id, lhs.id);
e.base_var = rhs;
}
});
} else {
// use geom
for (AllocNode o : rep.get_all_points_to_objects()) {
IVarAbstraction padf = geomPTA.findInstanceField((AllocNode) o, field);
if (padf == null || padf.reachable() == false)
continue;
off_graph_edge e = add_graph_edge(padf.id, lhs.id);
e.base_var = rhs;
}
}
}
break;
}
}
}
use of soot.jimple.spark.pag.Node in project soot by Sable.
the class OfflineProcessor method releaseSparkMem.
public void releaseSparkMem() {
for (int i = 0; i < n_var; ++i) {
IVarAbstraction pn = int2var.get(i);
// Keep only the points-to results for representatives
if (pn != pn.getRepresentative()) {
continue;
}
if (pn.willUpdate) {
Node vn = pn.getWrappedNode();
vn.discardP2Set();
}
}
System.gc();
System.gc();
System.gc();
System.gc();
}
use of soot.jimple.spark.pag.Node in project soot by Sable.
the class OfflineProcessor method setAllUserCodeVariablesUseful.
/**
* All the pointers that we need their points-to information are marked.
* @param virtualBaseSet
*/
protected void setAllUserCodeVariablesUseful() {
for (int i = 0; i < n_var; ++i) {
IVarAbstraction pn = int2var.get(i);
if (pn != pn.getRepresentative())
continue;
Node node = pn.getWrappedNode();
int sm_id = geomPTA.getMethodIDFromPtr(pn);
if (!geomPTA.isReachableMethod(sm_id))
continue;
if (node instanceof VarNode) {
// flag == true if node is defined in the Java library
boolean defined_in_lib = false;
if (node instanceof LocalVarNode) {
defined_in_lib = ((LocalVarNode) node).getMethod().isJavaLibraryMethod();
} else if (node instanceof GlobalVarNode) {
SootClass sc = ((GlobalVarNode) node).getDeclaringClass();
if (sc != null)
defined_in_lib = sc.isJavaLibraryClass();
}
if (!defined_in_lib && !geomPTA.isExceptionPointer(node)) {
// Defined in the user code
pn.willUpdate = true;
}
}
}
}
Aggregations