public boolean validFromBothEnds(SparkField field) { if (allNotBothEnds) { return false; } if (field instanceof SootField) { SootField sootField = (SootField) field; String fieldTypeStr = sootField.getDeclaringClass().getType() .toString(); for (String typeName : notBothEndsTypes) { if (fieldTypeStr.equals(typeName)) { return false; } } } return true; }
public boolean validateMatchesForField(SparkField field) { if (field instanceof ArrayElement) { return true; } SootField sootField = (SootField) field; RefType declaringType = sootField.getDeclaringClass().getType(); String declaringTypeStr = declaringType.toString(); String topLevel = Util.topLevelTypeString(declaringTypeStr); RefType refType; if(Scene.v().containsType(topLevel)) { refType = Scene.v().getRefType(topLevel); } else { refType=null; } for (RefType checkedType : typesToCheck) { if (manager.castNeverFails(checkedType, refType)) { // System.err.println("validate " + declaringTypeStr); return true; } } if (newTypeOnQuery == null) { newTypeOnQuery = declaringTypeStr; } return false; }
public boolean validFromBothEnds(SparkField field) { if (allNotBothEnds) { return false; } if (field instanceof ArrayElement) { return true; } SootField sootField = (SootField) field; RefType declaringType = sootField.getDeclaringClass().getType(); if (bothEndsTypes.contains(declaringType)) { return true; } else if (notBothEndsTypes.contains(declaringType)) { return false; } else { if (SootUtil.hasRecursiveField(declaringType.getSootClass())) { notBothEndsTypes.add(declaringType); return false; } else { bothEndsTypes.add(declaringType); return true; } } }
public ValidMatches(PAG pag, FieldToEdgesMap fieldToStores) { for (Iterator iter = pag.loadSources().iterator(); iter.hasNext();) { FieldRefNode loadSource = (FieldRefNode) iter.next(); SparkField field = loadSource.getField(); VarNode loadBase = loadSource.getBase(); ArraySet<Pair<VarNode, VarNode>> storesOnField = fieldToStores.get(field); for (Pair<VarNode, VarNode> store : storesOnField) { VarNode storeBase = store.getO2(); if (loadBase.getP2Set().hasNonEmptyIntersection(storeBase.getP2Set())) { VarNode matchSrc = store.getO1(); Node[] loadTargets = pag.loadLookup(loadSource); for (int i = 0; i < loadTargets.length; i++) { VarNode matchTgt = (VarNode) loadTargets[i]; vMatchEdges.put(matchSrc, matchTgt); vMatchBarEdges.put(matchTgt, matchSrc); } } } } }
public static FieldAccessMap buildStoreMap(PAG pag) { FieldAccessMap ret = new FieldAccessMap(); Iterator frNodeIter = pag.storeInvSourcesIterator(); while (frNodeIter.hasNext()) { FieldRefNode frNode = (FieldRefNode) frNodeIter.next(); SparkField field = frNode.getField(); Node[] targets = pag.storeInvLookup(frNode); for (int i = 0; i < targets.length; i++) { VarNode target = (VarNode) targets[i]; if (target instanceof GlobalVarNode) continue; ret.put(field, new Pair<FieldRefNode, LocalVarNode>(frNode, (LocalVarNode) target)); } } return ret; }
public boolean validateMatchesForField(SparkField field) { // if (true) return true; if (field instanceof ArrayElement) { return true; } SootField sootField = (SootField) field; RefType declaringType = sootField.getDeclaringClass().getType(); if (EXCLUDE_TYPES) { for (String typeName : EXCLUDED_NAMES) { if (Util.stringContains(declaringType.toString(), typeName)) { return false; } } } for (RefType typeToCheck : typesToCheck) { if (manager.castNeverFails(declaringType, typeToCheck)) { return true; } } if (newTypeOnQuery == null) { newTypeOnQuery = declaringType; // System.err.println("adding type " + declaringType); } // System.err.println("false for " + field); return false; }
/** * Obtain or create an internal representation of an object field. */ public IVarAbstraction findAndInsertInstanceField(AllocNode obj, SparkField field) { AllocDotField af = findAllocDotField(obj, field); IVarAbstraction pn = null; if ( af == null ) { // We create a new instance field node w.r.t type compatiblity Type decType = ((SootField) field).getDeclaringClass().getType(); Type baseType = obj.getType(); // baseType must be a sub type of decType if ( typeManager.castNeverFails(baseType, decType) ) { af = makeAllocDotField(obj, field); pn = makeInternalNode(af); pointers.add(pn); } } else { pn = consG.get(af); } return pn; }
public boolean validateMatchesForField(SparkField field) { if (field instanceof ArrayElement) { return true; } SootField sootField = (SootField) field; String fieldTypeStr = sootField.getDeclaringClass().getType() .toString(); for (String typeName : importantTypes) { if (fieldTypeStr.equals(typeName)) { return true; } } return false; }
public boolean validFromBothEnds(SparkField field) { if (field instanceof SootField) { SootField sootField = (SootField) field; RefType declaringType = sootField.getDeclaringClass().getType(); for (RefType type : notBothEndsTypes) { if (manager.castNeverFails(declaringType, type)) { return false; } } } return true; }
/** * Searching the points-to results for field expression such as p.f. * * @param sootEdge * @param l * @param field * @param visitor * @return */ @SuppressWarnings("rawtypes") public boolean contextsByAnyCallEdge(Edge sootEdge, Local l, SparkField field, PtSensVisitor visitor) { Obj_full_extractor pts_l = new Obj_full_extractor(); if ( contexsByAnyCallEdge(sootEdge, l, pts_l) == false ) return false; visitor.prepare(); for ( IntervalContextVar icv : pts_l.outList ) { AllocNode obj = (AllocNode)icv.var; AllocDotField obj_f = geomPts.findAllocDotField(obj, field); if ( obj_f == null ) continue; IVarAbstraction objField = geomPts.findInternalNode(obj_f); if ( objField == null ) continue; long L = icv.L; long R = icv.R; assert L < R; objField.get_all_context_sensitive_objects(L, R, visitor); } pts_l = null; visitor.finish(); return visitor.numOfDiffObjects() != 0; }
/** * Standard K-CFA querying for field expression. * * @param callEdgeChain: callEdgeChain[0] is the farthest call edge in the chain. * @param l * @param field * @param visitor * @return */ @SuppressWarnings("rawtypes") public boolean contextByCallChain(Edge[] callEdgeChain, Local l, SparkField field, PtSensVisitor visitor) { // We first obtain the points-to information for l Obj_full_extractor pts_l = new Obj_full_extractor(); if ( contextsByCallChain(callEdgeChain, l, pts_l) == false ) return false; // We compute the points-to information for l.field visitor.prepare(); for ( IntervalContextVar icv : pts_l.outList ) { AllocNode obj = (AllocNode)icv.var; AllocDotField obj_f = geomPts.findAllocDotField(obj, field); if ( obj_f == null ) continue; IVarAbstraction objField = geomPts.findInternalNode(obj_f); if ( objField == null ) continue; long L = icv.L; long R = icv.R; assert L < R; objField.get_all_context_sensitive_objects(L, R, visitor); } pts_l = null; visitor.finish(); return visitor.numOfDiffObjects() != 0; }
private PointsToSetInternal field_p2set( PointsToSet s, final SparkField f ) { if ( !(s instanceof PointsToSetInternal) ) throw new RuntimeException( "Base pointers must be stored in *PointsToSetInternal*." ); PointsToSetInternal bases = (PointsToSetInternal) s; final PointsToSetInternal ret = getSetFactory().newSet(f.getType(), this); bases.forall(new P2SetVisitor() { public final void visit(Node n) { Node nDotF = ((AllocNode) n).dot(f); if (nDotF != null) { //nDotF.getP2Set() has been discarded in solve() IVarAbstraction pn = consG.get(nDotF); if (pn == null || hasTransformed || nDotF.getP2Set() != EmptyPointsToSet.v()) { ret.addAll(nDotF.getP2Set(), null); return; } pn = pn.getRepresentative(); //PointsToSetInternal ptSet = nDotF.makeP2Set(); for ( AllocNode obj : pn.get_all_points_to_objects() ) { ret.add( obj ); //ptSet.add(obj); } } } }); return ret; }
void Load(Local l, Local b, SparkField f) { if(b == null || l == null) return; if(f instanceof SootField && (((SootField) f).getDeclaringClass().isPhantom())) return; relLoad.add(l, b, f); }
void Store(Local b, SparkField f, Local r) { if(b == null || r == null) return; if(f instanceof SootField && (((SootField) f).getDeclaringClass().isPhantom())) return; relStore.add(b, f, r); }
void LoadPrim(Local l, Local b, SparkField f) { if(b == null || l == null) return; if(f instanceof SootField && (((SootField) f).getDeclaringClass().isPhantom())) return; relLoadPrim.add(l, b, f); }
void StorePrim(Local b, SparkField f, Local r) { if(b == null || r == null) return; if(f instanceof SootField && (((SootField) f).getDeclaringClass().isPhantom())) return; relStorePrim.add(b, f, r); }
public boolean validateMatchesForField(SparkField field) { return false; }
public boolean validFromBothEnds(SparkField field) { return false; }
public abstract void handleMatchSrc(VarNode matchSrc, PointsToSetInternal intersection, VarNode loadBase, VarNode storeBase, VarAndContext origVarAndContext, SparkField field, boolean refine);
public boolean validateMatchesForField(SparkField field) { return manual.validateMatchesForField(field) || inner.validateMatchesForField(field); }
public boolean validFromBothEnds(SparkField field) { return inner.validFromBothEnds(field); }
public boolean validateMatchesForField(SparkField field) { return true; }
/** * Obtain the internal representation of an object field. */ public IVarAbstraction findInstanceField(AllocNode obj, SparkField field) { AllocDotField af = findAllocDotField(obj, field); return consG.get(af); }
public Numberer<SparkField> getFieldNumberer() { return fieldNumberer; }
public boolean validateMatchesForField(SparkField field);
public boolean validFromBothEnds(SparkField field);