protected static FieldReference toFieldReference(SootField f) { FieldReference fieldRef = new ImmutableFieldReference(SootToDexUtils.getDexClassName(f.getDeclaringClass().getName()), f.getName(), SootToDexUtils.getDexTypeDescriptor(f.getType())); return fieldRef; }
public void checkAndSwitch(ValueBox valBox) { Value val = valBox.getValue(); Object finalField = check(val); if (finalField != null) { // System.out.println("Final field with this value exists"+finalField); /* * If the final field belongs to the same class then we should supress declaring class */ SootField field = (SootField) finalField; if (sootClass.declaresField(field.getName(), field.getType())) { // this field is of this class so supress the declaring class if (valBox.canContainValue(new DStaticFieldRef(field.makeRef(), true))) { valBox.setValue(new DStaticFieldRef(field.makeRef(), true)); } } else { if (valBox.canContainValue(new DStaticFieldRef(field.makeRef(), true))) { valBox.setValue(new DStaticFieldRef(field.makeRef(), false)); } } } // else // System.out.println("Final field not found"); }
public String getSignature() { if (sig == null) { synchronized (this) { if (sig == null) { sig = getSignature(getDeclaringClass(), getSubSignature()); } } } return sig; }
public String getSubSignature() { if (subSig == null) { synchronized (this) { if (subSig == null) { subSig = getSubSignature(getName(), getType()); } } } return subSig; }
public static String getSignature(SootClass cl, String name, Type type) { return getSignature(cl,getSubSignature(name,type)); }
private Variable lookupFieldLocal(Variable baseVar, SootField sf) { Map<String, Variable> f2l = getMapForVar(baseVar); if (!f2l.containsKey(sf.getDeclaration())) { int i = 1; for (SootField cfield : SootTranslationHelpers .findNonStaticFieldsRecursively(sf.getDeclaringClass())) { if (cfield.equals(sf)) { Variable outVar = statementSwitch.getMethodInfo().getOutVariable(i); if (!f2l.containsKey(sf.getDeclaration())) { f2l.put(sf.getDeclaration(), outVar); Verify.verify(f2l.containsKey(sf.getDeclaration())); return f2l.get(sf.getDeclaration()); soottocfg.cfg.type.Type tp = this.lookupType(sf.getType()); String name = baseVar.getName() + "_" + sf.getName() + "_" + sf.getNumber(); if (sf.isStatic()) { name = sf.getDeclaringClass().getName() + "_" + sf.getName(); f2l.put(sf.getDeclaration(), l); return f2l.get(sf.getDeclaration());
private void printFieldRef(FieldRef v) { String refTypeName = v.getClass().getSimpleName(); p.openBlock(); String oldName = varName; SootField f = v.getField(); ttp.setVariableName("type"); f.getType().apply(ttp); p.print("SootFieldRef fieldRef = "); p.printNoIndent("Scene.v().makeFieldRef("); String className = f.getDeclaringClass().getName(); p.printNoIndent("Scene.v().getSootClass(\"" + className + "\"),"); p.printNoIndent("\"" + f.getName() + "\","); p.printNoIndent("type,"); p.printNoIndent(f.isStatic() + ");"); p.println("Value " + oldName + " = Jimple.v().new" + refTypeName + "(fieldRef);"); varName = oldName; p.closeBlock(); }
public String getSignature() { return getSignature(declaringClass, getName(), getType()); } public static String getSignature(SootClass cl, String name, Type type)
Type newType = updateType(f.getType()); if (!newType.equals(f.getType())) { changedFieldSignatures.add(f.getSignature()); final String oldSig = f.getSignature(); f.setType(newType); fieldSubstitutionMap.put(oldSig, f); if (fieldSubstitutionMap.containsKey(fr.getField().getSignature())) { fr.setFieldRef(fieldSubstitutionMap.get(fr.getField().getSignature()).makeRef());
private void loadBooleanValue(PatchingChain<Unit> units, SootField f, Unit insert) { units.insertBefore(Baf.v().newStaticGetInst(f.makeRef()), insert); if (f.getType() instanceof RefType) { SootMethod boolInit = ((RefType) f.getType()).getSootClass().getMethod("boolean booleanValue()"); units.insertBefore(Baf.v().newVirtualInvokeInst(boolInit.makeRef()), insert); } }
/** * Removes the given field from this class. */ public void removeField(SootField f) { checkLevel(SIGNATURES); if (!f.isDeclared() || f.getDeclaringClass() != this) { throw new RuntimeException("did not declare: " + f.getName()); } if (fields != null) { fields.remove(f); } f.setDeclared(false); f.setDeclaringClass(null); }
public synchronized SootField getOrAddField(SootField f) { checkLevel(SIGNATURES); if (f.isDeclared()) { throw new RuntimeException("already declared: " + f.getName()); } SootField old = getFieldUnsafe(f.getName(), f.getType()); if (old != null) { return old; } if (fields == null) { fields = new HashChain<>(); } fields.add(f); f.setDeclared(true); f.setDeclaringClass(this); return f; }
public SootClass getDeclaringClass() { if (variable instanceof SootField) { return ((SootField) variable).getDeclaringClass(); } return null; } }
public void caseFieldGetInst(FieldGetInst i) { remove_types = new Type[] { i.getField().getDeclaringClass().getType() }; add_types = new Type[] { i.getField().getType() }; }
public static EquivalentValue getNodeForFieldRef(SootMethod sm, SootField sf, Local realLocal) { if (sf.isStatic()) { return new CachedEquivalentValue(Jimple.v().newStaticFieldRef(sf.makeRef())); } else { // Jimple.v().newThisRef(sf.getDeclaringClass().getType()) if (sm.isConcrete() && !sm.isStatic() && sm.getDeclaringClass() == sf.getDeclaringClass() && realLocal == null) { JimpleLocal fakethis = new FakeJimpleLocal("fakethis", sf.getDeclaringClass().getType(), sm.retrieveActiveBody().getThisLocal()); return new CachedEquivalentValue(Jimple.v().newInstanceFieldRef(fakethis, sf.makeRef())); // fake thisLocal } else { // Pretends to be a this.<somefield> ref for a method without a body, // for a static method, or for an inner field JimpleLocal fakethis = new FakeJimpleLocal("fakethis", sf.getDeclaringClass().getType(), realLocal); return new CachedEquivalentValue(Jimple.v().newInstanceFieldRef(fakethis, sf.makeRef())); // fake thisLocal } } }
public CPVariable(SootField field) { this.field = field; this.local = null; if (!(field.getType() instanceof PrimType)) { throw new DavaFlowAnalysisException("Variables managed for CP should only be primitives"); } }
FieldRWTag(Set<SootField> fields) { StringBuffer sb = new StringBuffer(); boolean first = true; for (SootField field : fields) { if (!first) { sb.append("%"); } first = false; sb.append(field.getDeclaringClass().getName()); sb.append(":"); sb.append(field.getName()); } fieldNames = sb.toString(); }
SootField f = fieldIt.next(); if (f.isPhantom()) { continue; Iterator<Tag> fTagIterator = f.getTags().iterator(); while (fTagIterator.hasNext()) { Tag t = fTagIterator.next(); out.println(" " + f.getDeclaration() + ";"); if (addJimpleLn()) { setJimpleLnNum(addJimpleLnTags(getJimpleLnNum(), f));