예제 #1
0
파일: DMUL.java 프로젝트: null3/jpf
  public Instruction execute(SystemState ss, KernelState ks, ThreadInfo th) {
    StackFrame sf = th.getTopFrame();

    RealExpression sym_v1 = (RealExpression) sf.getLongOperandAttr();
    double v1 = Types.longToDouble(th.longPop());
    RealExpression sym_v2 = (RealExpression) sf.getLongOperandAttr();
    double v2 = Types.longToDouble(th.longPop());

    double r = v1 * v2;

    if (sym_v1 == null && sym_v2 == null) th.longPush(Types.doubleToLong(r));
    else th.longPush(0);

    RealExpression result = null;
    if (sym_v2 != null) {
      if (sym_v1 != null) result = sym_v2._mul(sym_v1);
      else // v1 is concrete
      result = sym_v2._mul(v1);
    } else if (sym_v1 != null) result = sym_v1._mul(v2);

    sf.setLongOperandAttr(result);

    // System.out.println("Execute DMUL: "+ sf.getLongOperandAttr());

    return getNext(th);
  }
예제 #2
0
파일: F2L.java 프로젝트: null3/jpf
  public Instruction execute(SystemState ss, KernelState ks, ThreadInfo th) {
    RealExpression sym_fval = (RealExpression) th.getTopFrame().getOperandAttr();

    if (sym_fval == null) {
      return super.execute(ss, ks, th);
    } else {

      // System.out.println("Execute symbolic F2L");

      // here we get a hold of the current path condition and
      // add an extra mixed constraint sym_dval==sym_ival

      ChoiceGenerator<?> cg;
      if (!th.isFirstStepInsn()) { // first time around
        cg = new PCChoiceGenerator(1); // only one choice
        ss.setNextChoiceGenerator(cg);
        return this;
      } else { // this is what really returns results
        cg = ss.getChoiceGenerator();
        assert (cg instanceof PCChoiceGenerator) : "expected PCChoiceGenerator, got: " + cg;
      }

      // get the path condition from the
      // previous choice generator of the same type

      PathCondition pc;
      ChoiceGenerator<?> prev_cg = cg.getPreviousChoiceGenerator();
      while (!((prev_cg == null) || (prev_cg instanceof PCChoiceGenerator))) {
        prev_cg = prev_cg.getPreviousChoiceGenerator();
      }

      if (prev_cg == null)
        pc = new PathCondition(); // TODO: handling of preconditions needs to be changed
      else pc = ((PCChoiceGenerator) prev_cg).getCurrentPC();
      assert pc != null;

      th.pop();
      th.longPush(0); // for symbolic expressions, the concrete value does not matter
      SymbolicInteger sym_lval = new SymbolicInteger();
      StackFrame sf = th.getTopFrame();
      sf.setLongOperandAttr(sym_lval);

      pc._addDet(Comparator.EQ, sym_fval, sym_lval);

      if (!pc.simplify()) { // not satisfiable
        ss.setIgnored(true);
      } else {
        // pc.solve();
        ((PCChoiceGenerator) cg).setCurrentPC(pc);
        // System.out.println(((PCChoiceGenerator) cg).getCurrentPC());
      }

      // System.out.println("Execute D2I: " + sf.getLongOperandAttr());
      return getNext(th);
    }
  }
예제 #3
0
파일: LREM.java 프로젝트: evvalvis/jpf
  public Instruction execute(SystemState ss, KernelState ks, ThreadInfo th) {
    long v1 = th.longPop();
    long v2 = th.longPop();

    if (v1 == 0) {
      return th.createAndThrowException("java.lang.ArithmeticException", "division by zero");
    }

    th.longPush(v2 % v1);

    return getNext(th);
  }
예제 #4
0
파일: INVOKECG.java 프로젝트: evvalvis/jpf
  void pushArguments(ThreadInfo ti, Object[] args, Object[] attrs) {
    if (args != null) {
      for (int i = 0; i < args.length; i++) {
        Object a = args[i];
        boolean isLong = false;

        if (a != null) {
          if (a instanceof Ref) {
            ti.push(((Ref) a).getReference(), true);
          } else if (a instanceof Boolean) {
            ti.push((Boolean) a ? 1 : 0, false);
          } else if (a instanceof Integer) {
            ti.push((Integer) a, false);
          } else if (a instanceof Long) {
            ti.longPush((Long) a);
            isLong = true;
          } else if (a instanceof Double) {
            ti.longPush(Types.doubleToLong((Double) a));
            isLong = true;
          } else if (a instanceof Byte) {
            ti.push((Byte) a, false);
          } else if (a instanceof Short) {
            ti.push((Short) a, false);
          } else if (a instanceof Float) {
            ti.push(Types.floatToInt((Float) a), false);
          }
        }

        if (attrs != null && attrs[i] != null) {
          if (isLong) {
            ti.setLongOperandAttr(attrs[i]);
          } else {
            ti.setOperandAttr(attrs[i]);
          }
        }
      }
    }
  }
예제 #5
0
  public Instruction execute(SystemState ss, KernelState ks, ThreadInfo th) {
    th.longPush(value);

    return getNext(th);
  }