public void caseIdentityStmt(IdentityStmt stmt) { Value l = stmt.getLeftOp(); Value r = stmt.getRightOp(); if (l instanceof Local) { TypeVariable left = resolver.typeVariable((Local) l); if (!(r instanceof CaughtExceptionRef)) { TypeVariable right = resolver.typeVariable(r.getType()); right.addParent(left); } else { List<RefType> exceptionTypes = TrapManager.getExceptionTypesOf(stmt, stmtBody); Iterator<RefType> typeIt = exceptionTypes.iterator(); while (typeIt.hasNext()) { Type t = typeIt.next(); resolver.typeVariable(t).addParent(left); } if (uses) { left.addParent(resolver.typeVariable(RefType.v("java.lang.Throwable"))); } } } }
@Override public void caseIdentityStmt(IdentityStmt stmt) { Value lhs = stmt.getLeftOp(); Value rhs = stmt.getRightOp(); if (rhs instanceof CaughtExceptionRef) { // save the caught exception with move-exception Register localReg = regAlloc.asLocal(lhs); addInsn(new Insn11x(Opcode.MOVE_EXCEPTION, localReg), stmt); this.insnRegisterMap.put(insns.get(insns.size() - 1), LocalRegisterAssignmentInformation.v(localReg, (Local)lhs)); } else if (rhs instanceof ThisRef || rhs instanceof ParameterRef) { /* * do not save the ThisRef or ParameterRef in a local, because it always has a parameter register already. * at least use the local for further reference in the statements */ Local localForThis = (Local) lhs; regAlloc.asParameter(belongingMethod, localForThis); parameterInstructionsList.add(LocalRegisterAssignmentInformation.v(regAlloc.asLocal(localForThis).clone(), localForThis)); } else { throw new Error("unknown Value as right-hand side of IdentityStmt: " + rhs); } }
/** * Construct an empty DavaBody */ DavaBody(SootMethod m) { super(m); pMap = new HashMap<Integer, Value>(); consumedConditions = new HashSet<Object>(); thisLocals = new HashSet<Object>(); synchronizedBlockFacts = new IterableSet<ExceptionNode>(); exceptionFacts = new IterableSet<ExceptionNode>(); monitorFacts = new IterableSet<AugmentedStmt>(); importList = new IterableSet<String>(); //packagesUsed = new IterableSet(); caughtrefs = new LinkedList<CaughtExceptionRef>(); controlLocal = null; constructorExpr = null; }
private void convertLabel(LabelNode ln) { if (!trapHandlers.containsKey(ln)) return; StackFrame frame = getFrame(ln); Operand[] out = frame.out(); Operand opr; if (out == null) { CaughtExceptionRef ref = Jimple.v().newCaughtExceptionRef(); Local stack = newStackLocal(); DefinitionStmt as = Jimple.v().newIdentityStmt(stack, ref); opr = new Operand(ln, ref); opr.stack = stack; frame.out(opr); setUnit(ln, as); } else { opr = out[0]; } push(opr); }
public final void caseIdentityStmt(IdentityStmt s) { statement = s; Value lhs = s.getLeftOp(); Value rhs = s.getRightOp(); if( !( lhs.getType() instanceof RefType ) && !(lhs.getType() instanceof ArrayType ) ) { caseUninterestingStmt( s ); return; } Local llhs = (Local) lhs; if( rhs instanceof CaughtExceptionRef ) { caseCatchStmt( llhs, (CaughtExceptionRef) rhs ); } else { IdentityRef rrhs = (IdentityRef) rhs; caseIdentityStmt( llhs, rrhs ); } }
@Override public void caseIdentityStmt(IdentityStmt stmt) { AnnotationValueSwitch valueSwitch = new AnnotationValueSwitch(stmt, StmtContext.IDENTITY); logger.fine("\n > > > Identity statement identified < < <"); // for all statements i = parameter[0] if (stmt.getRightOp() instanceof ParameterRef) { if (!body.getMethod().isMain()) { int posInArgList = ((ParameterRef) stmt.getRightOp()) .getIndex(); JimpleInjector.assignArgumentToLocal(posInArgList, (Local) stmt.getLeftOp()); } } else if (stmt.getRightOp() instanceof ThisRef) { // TODO im Grunde nicht nötig... } else if (stmt.getRightOp() instanceof CaughtExceptionRef) { logger.fine("Right operand in IdentityStmt is a CaughtException"); throw new InternalAnalyzerException("Catching exceptions is not supported"); } else { throw new InternalAnalyzerException( "Unexpected type of right value " + stmt.getRightOp().toString() + " in IdentityStmt"); } }
private void handleRefTypeAssignment(DefinitionStmt assignStmt, AnalysisInfo out) { Value left = assignStmt.getLeftOp(); Value right = assignStmt.getRightOp(); //unbox casted value if(right instanceof JCastExpr) { JCastExpr castExpr = (JCastExpr) right; right = castExpr.getOp(); } //if we have a definition (assignment) statement to a ref-like type, handle it, if ( isAlwaysNonNull(right) || right instanceof NewExpr || right instanceof NewArrayExpr || right instanceof NewMultiArrayExpr || right instanceof ThisRef || right instanceof StringConstant || right instanceof ClassConstant || right instanceof CaughtExceptionRef) { //if we assign new... or @this, the result is non-null out.put(left,NON_NULL); } else if(right==NullConstant.v()) { //if we assign null, well, it's null out.put(left, NULL); } else if(left instanceof Local && right instanceof Local) { out.put(left, out.get(right)); } else { out.put(left, TOP); } }
@Override public void caseCaughtExceptionRef(CaughtExceptionRef arg0) { if (arg0.getType() instanceof RefType) { RefType rtype = (RefType) arg0.getType(); // assume that the exception variable now has the type of the caught // exception // assume $heap[$exception,$type] <: arg0.getType() if (this.stmtSwitch != null) { // ensure that $exception is not null. //TODO: actually don't! Because this creates //a dead else branch in some cases. //the non-nullness is ensured by the compiler. // this.stmtSwitch.getErrorModel() // .createNonNullViolationException( // this.procInfo.getExceptionVariable()); Expression typefield = this.getClassTypeFromExpression( this.procInfo.getExceptionVariable(), false); this.stmtSwitch.addStatement(pf.mkAssumeStatement( new Attribute[] {}, GlobalsCache.v().compareTypeExpressions( typefield, GlobalsCache.v().lookupClassVariable( rtype.getSootClass())))); } this.expressionStack.push(this.procInfo.getExceptionVariable()); return; } throw new RuntimeException( "this case of exception handling has not beend implemented"); }
@Override protected boolean isAlwaysNonNull(Value v) { if (v instanceof CaughtExceptionRef) { return true; } return false; }
@Override public void caseIdentityStmt(IdentityStmt stmt) { valueSwitch.callingStmt = stmt; valueSwitch.actualContext = StmtContext.IDENTITY; logger.fine("\n > > > Identity statement identified < < <"); if (stmt.getRightOp() instanceof ParameterRef) { if (!body.getMethod().isMain()) { int posInArgList = ((ParameterRef) stmt.getRightOp()) .getIndex(); JimpleInjector.assignArgumentToLocal(posInArgList, (Local) stmt.getLeftOp(), stmt); } } else if (stmt.getRightOp() instanceof ThisRef) { // TODO im Grunde nicht nötig... } else if (stmt.getRightOp() instanceof CaughtExceptionRef) { logger.fine("Right operand in IdentityStmt is a CaughtException"); } else { throw new InternalAnalyzerException( "Unexpected type of right value " + stmt.getRightOp().toString() + " in IdentityStmt"); } valueSwitch.actualContext = StmtContext.UNDEF; }
@Override public void caseCaughtExceptionRef(CaughtExceptionRef v) { rightElement = RightElement.NOT; if (actualContext == StmtContext.ASSIGNRIGHT) { throw new NotSupportedStmtException("CaughtExceptionRef"); } }
public void caseCaughtExceptionRef(CaughtExceptionRef v) { p.println("Value "+varName+" = Jimple.v().newCaughtExceptionRef();"); }
public List<CaughtExceptionRef> get_CaughtRefs() { return caughtrefs; }
public void caseCaughtExceptionRef(CaughtExceptionRef v) { }
@Override public void visit(Value e) { if (e instanceof CaughtExceptionRef) { add((CaughtExceptionRef) e); } }
/** A catch statement */ protected void caseCatchStmt( Local dest, CaughtExceptionRef cer ) {}
@Override public void caseCaughtExceptionRef(CaughtExceptionRef v) { throwInvalidWriteException(v); }
@Override public void caseCaughtExceptionRef(CaughtExceptionRef v) { throwNotImplementedException(v.getClass(), v.toString()); }
/** * The method should look up the <em>security level</em> of a * {@link CaughtExceptionRef}, but it is not implemented how to look up the * level of a caught exceptions reference. * * @param v * The caught exception reference for which the * <em>security level</em> should be looked up. * @see soot.jimple.RefSwitch#caseCaughtExceptionRef(soot.jimple.CaughtExceptionRef) * @throws UnimplementedSwitchException * Method throws always this exception, because the method is * not implemented. */ @Override public void caseCaughtExceptionRef(CaughtExceptionRef v) { throw new SwitchException(getMsg("exception.analysis.switch.not_implemented", v.toString(), getSourceLine(), v.getClass().getSimpleName(), this.getClass().getSimpleName())); }
/** * The method should update the <em>security level</em> of a * {@link CaughtExceptionRef}, but it is not implemented how to update the * level of a caught exceptions reference. * * @param v * The caught exceptions reference for which the * <em>security level</em> should be updated. * @see soot.jimple.RefSwitch#caseCaughtExceptionRef(soot.jimple.CaughtExceptionRef) * @throws UnimplementedSwitchException * Method throws always this exception, because the method is * not implemented. */ @Override public void caseCaughtExceptionRef(CaughtExceptionRef v) { throw new SwitchException(getMsg("exception.analysis.switch.not_implemented", v.toString(), getSourceLine(), v.getClass().getSimpleName(), this.getClass().getSimpleName())); }
/** * DOC * * @see soot.jimple.RefSwitch#caseCaughtExceptionRef(soot.jimple.CaughtExceptionRef) */ @Override public void caseCaughtExceptionRef(CaughtExceptionRef v) { }