Java Code Examples for soot.jimple.StringConstant#v()
The following examples show how to use
soot.jimple.StringConstant#v() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JimpleExprVisitorImpl.java From FuzzDroid with Apache License 2.0 | 6 votes |
@Override public void caseSpecialInvokeExpr(SpecialInvokeExpr v) { //is the invokeExpr a source method? if(isSourceMethod(v)) { StringConstant newSourceValue = StringConstant.v("loggingPoint"); SMTBinding binding = stmtVisitor.createNewBindingForValue(newSourceValue); stmtVisitor.addValueBindingToVariableDeclaration(newSourceValue, binding); //no smt-statement required, just return the binding this.result = binding; // Additionally check whether the source method need special treatment if(isExpressionThatNeedsToBeConvertedToSMT(v)) { convertSpecialExpressionsToSMT(v, currentStatement); } } else { if(isStringOperationSupportedBySMT(v)) convertStringOperationToSMT(v, v.getBase()); else if(isExpressionThatNeedsToBeConvertedToSMT(v)) convertSpecialExpressionsToSMT(v, currentStatement); else convertAPIMethodToSMT(v); } }
Example 2
Source File: JimpleExprVisitorImpl.java From FuzzDroid with Apache License 2.0 | 6 votes |
@Override public void caseVirtualInvokeExpr(VirtualInvokeExpr virtualInvokeExpr) { //is the invokeExpr a source method? if(isSourceMethod(virtualInvokeExpr)) { StringConstant newSourceValue = StringConstant.v("loggingPoint"); SMTBinding binding = stmtVisitor.createNewBindingForValue(newSourceValue); stmtVisitor.addValueBindingToVariableDeclaration(newSourceValue, binding); //no smt-statement required, just return the binding this.result = binding; // Additionally check whether the source method need special treatment if(isExpressionThatNeedsToBeConvertedToSMT(virtualInvokeExpr)) { convertSpecialExpressionsToSMT(virtualInvokeExpr, currentStatement); } } else { if(isStringOperationSupportedBySMT(virtualInvokeExpr)) convertStringOperationToSMT(virtualInvokeExpr, virtualInvokeExpr.getBase()); else if(isExpressionThatNeedsToBeConvertedToSMT(virtualInvokeExpr)) convertSpecialExpressionsToSMT(virtualInvokeExpr, currentStatement); else convertAPIMethodToSMT(virtualInvokeExpr); } }
Example 3
Source File: BaseEntryPointCreator.java From JAADAS with GNU General Public License v3.0 | 6 votes |
protected Value getSimpleDefaultValue(String t) { if (t.equals("java.lang.String")) return StringConstant.v(""); if (t.equals("char")) return DIntConstant.v(0, CharType.v()); if (t.equals("byte")) return DIntConstant.v(0, ByteType.v()); if (t.equals("short")) return DIntConstant.v(0, ShortType.v()); if (t.equals("int")) return IntConstant.v(0); if (t.equals("float")) return FloatConstant.v(0); if (t.equals("long")) return LongConstant.v(0); if (t.equals("double")) return DoubleConstant.v(0); if (t.equals("boolean")) return DIntConstant.v(0, BooleanType.v()); //also for arrays etc. return G.v().soot_jimple_NullConstant(); }
Example 4
Source File: AsmMethodSource.java From JAADAS with GNU General Public License v3.0 | 6 votes |
private Value toSootValue(Object val) throws AssertionError { Value v; if (val instanceof Integer) v = IntConstant.v((Integer) val); else if (val instanceof Float) v = FloatConstant.v((Float) val); else if (val instanceof Long) v = LongConstant.v((Long) val); else if (val instanceof Double) v = DoubleConstant.v((Double) val); else if (val instanceof String) v = StringConstant.v(val.toString()); else if (val instanceof org.objectweb.asm.Type) v = ClassConstant.v(((org.objectweb.asm.Type) val).getInternalName()); else if (val instanceof Handle) v = MethodHandle.v(toSootMethodRef((Handle) val), ((Handle)val).getTag()); else throw new AssertionError("Unknown constant type: " + val.getClass()); return v; }
Example 5
Source File: JimpleStmtVisitorImpl.java From FuzzDroid with Apache License 2.0 | 5 votes |
public SMTBinding createTemporalBinding(SMTBinding.TYPE type) { String tmpName = null; switch(type) { case String : tmpName = "StringTMP"; break; case Int : tmpName = "IntTMP"; break; case Bool : tmpName = "BoolTMP"; break; case Real: break; default: break; } StringConstant tmpValue = StringConstant.v(tmpName); SMTBinding binding = null; if(hasBindingForValue(tmpValue)) { SMTBinding oldBinding = getLatestBindingForValue(tmpValue); int ssaVersionOldBinding = oldBinding.getVersion(); //increment version ssaVersionOldBinding += 1; binding = new SMTBinding(oldBinding.getVariableName(), oldBinding.getType(), ssaVersionOldBinding); } else { binding = new SMTBinding(tmpName, type, 0); } addValueBindingToVariableDeclaration(tmpValue, binding); return binding; }
Example 6
Source File: JimpleExprVisitorImpl.java From FuzzDroid with Apache License 2.0 | 5 votes |
@Override public void caseInterfaceInvokeExpr(InterfaceInvokeExpr v) { if(isSourceMethod(v)) { StringConstant newSourceValue = StringConstant.v("loggingPoint"); SMTBinding binding = stmtVisitor.createNewBindingForValue(newSourceValue); stmtVisitor.addValueBindingToVariableDeclaration(newSourceValue, binding); //no smt-statement required, just return the binding this.result = binding; // Additionally check whether the source method need special treatment if(isExpressionThatNeedsToBeConvertedToSMT(v)) { convertSpecialExpressionsToSMT(v, currentStatement); } } else if(isExpressionThatNeedsToBeConvertedToSMT(v)){ convertSpecialExpressionsToSMT(v, currentStatement); }else{ //just propagate the taint value of previous statement Stmt prevStmt = stmtVisitor.getPreviousDataFlowPathElement(currentStatement); if(prevStmt == null) throw new RuntimeException("there is no previous statement"); else{ this.result = stmtVisitor.getBindingForTaintedValue(prevStmt); if(this.result == null) throw new RuntimeException("double check this here"); } } }
Example 7
Source File: UnitThrowAnalysisTest.java From JAADAS with GNU General Public License v3.0 | 5 votes |
@Test public void testStringConstant() { Value v = StringConstant.v("test"); assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(v))); assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(v))); }
Example 8
Source File: CONSTANT_String_info.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public Value createJimpleConstantValue(cp_info[] constant_pool) { CONSTANT_Utf8_info ci = (CONSTANT_Utf8_info)(constant_pool[string_index]); return StringConstant.v(ci.convert()); }
Example 9
Source File: CONSTANT_Utf8_info.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public Value createJimpleConstantValue(cp_info[] constant_pool) { return StringConstant.v(convert()); }
Example 10
Source File: MethodCallFinder.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public void inInvokeStmt(InvokeStmt s){ InvokeExpr invokeExpr = s.getInvokeExpr(); SootMethod maybeInline = invokeExpr.getMethod(); //check whether we want to inline ASTMethodNode toInlineASTMethod = cleaner.inline(maybeInline); if(toInlineASTMethod ==null){ //not to inline return; } else{//yes we want to inline // we know that the method to be inlined has no declarations. List<Object> subBodies = toInlineASTMethod.get_SubBodies(); if(subBodies.size() != 1){ throw new RuntimeException ("Found ASTMEthod node with more than one subBodies"); } List body = (List)subBodies.get(0); ASTParentNodeFinder finder = new ASTParentNodeFinder(); underAnalysis.apply(finder); List<ASTStatementSequenceNode> newChangedBodyPart = createChangedBodyPart(s,body,finder); boolean replaced = replaceSubBody(s,newChangedBodyPart,finder); if(replaced){ //so the invoke stmt has been replaced with the body of the method invoked /* * if the inlined method contained an assignment to a static field * we want to replace that with a throw stmt */ StaticDefinitionFinder defFinder = new StaticDefinitionFinder(maybeInline); toInlineASTMethod.apply(defFinder); if(defFinder.anyFinalFieldDefined()){ //create throw stmt to be added to inlined method //create a SootMethodRef SootClass runtime = Scene.v().loadClassAndSupport("java.lang.RuntimeException"); if(runtime.declaresMethod("void <init>(java.lang.String)")){ SootMethod sootMethod = runtime.getMethod("void <init>(java.lang.String)"); SootMethodRef methodRef = sootMethod.makeRef(); RefType myRefType = RefType.v(runtime); StringConstant tempString = StringConstant.v("This method used to have a definition of a final variable. "+ "Dava inlined the definition into the static initializer"); List list = new ArrayList(); list.add(tempString); GNewInvokeExpr newInvokeExpr = new GNewInvokeExpr(myRefType,methodRef,list); GThrowStmt throwStmt = new GThrowStmt(newInvokeExpr); AugmentedStmt augStmt = new AugmentedStmt(throwStmt); List<Object> sequence = new ArrayList<Object>(); sequence.add(augStmt); ASTStatementSequenceNode seqNode = new ASTStatementSequenceNode(sequence); List<Object> subBody = new ArrayList<Object>(); subBody.add(seqNode); toInlineASTMethod.replaceBody(subBody); } } } } }