Package com.sun.jdi

Examples of com.sun.jdi.Value


        LocalVariable var = (LocalVariable) method.variables().get( 0 );//frame

        ClassType frameType = (ClassType) var.type();

        StackFrame frame = getUnderlyingStackFrame();
        Value value = frame.getValue( var );
        //getThread().getTopStackFrame().get

        //IValue value = jdivar.getValue();
        ObjectReferenceImpl o = (ObjectReferenceImpl) value;

        //if ( value instanceof JDINullValue ) {
        // return null;
        // }

        //ObjectReference o = (ObjectReference) ((JDIObjectValue) value).getUnderlyingObject();
        if ( o == null ) {
            return null;
        }

        Field field = frameType.fieldByName( methodName );
        Value val = o.getValue( field );
        return val;
    }
View Full Code Here


      public boolean value_(ThreadReference arg1) {
        return arg1.isSuspended();
         
      }
    });
    Value result = receiver.invokeMethod(bootThread(), method,
        Arrays.asList(arguments), 0);
    System.out.println(" -> " + result);
    List<ThreadReference> allThreads = receiver.virtualMachine().allThreads();
    for (ThreadReference threadReference : allThreads) {
      if (suspendedThreads.contains(threadReference)) {
View Full Code Here

      if (mayResume) eventSet.resume();
    }
  }

  public int add(int x, int y) throws Throwable {
    Value resultMirror = invokeMethod("add", vm.mirrorOf(x), vm.mirrorOf(y));
    return ((IntegerValue) resultMirror).intValue();
  }
View Full Code Here

  @Test
  public void testEvaluate() throws Throwable {
    ObjectReference promise = remote.evaluateForked("3+4");
    ThreadReference thread = ((ThreadReference) remote.invokeMethod(
        promise, "thread"));
    Value result1 = remote.invokeMethod(promise, "result");
    Value ex = remote.invokeMethod(promise, "throwable");
    printThreadState();
    VMTargetStarter.sleep(100);
    printThreadState();

    boolean isFinished = ((BooleanValue) remote.invokeMethod(promise,
View Full Code Here

        LocalVariable var = (LocalVariable) method.variables().get( 0 );//frame

        ClassType frameType = (ClassType) var.type();

        StackFrame frame = getUnderlyingStackFrame();
        Value value = frame.getValue( var );
        //getThread().getTopStackFrame().get

        //IValue value = jdivar.getValue();
        ObjectReferenceImpl o = (ObjectReferenceImpl) value;

        //if ( value instanceof JDINullValue ) {
        // return null;
        // }

        //ObjectReference o = (ObjectReference) ((JDIObjectValue) value).getUnderlyingObject();
        if ( o == null ) {
            return null;
        }

        Field field = frameType.fieldByName( methodName );
        Value val = o.getValue( field );
        return val;
    }
View Full Code Here

      for (LocalVariable var : threadRef.frame(curFrame).visibleVariables()) {
        varNames.add(var.name());
      }
      int maxLen = getMaxLength(varNames)+2;
      for (LocalVariable var : threadRef.frame(curFrame).visibleVariables()) {
        Value value = threadRef.frame(curFrame).getValue(var);
        sb.append(padStr(maxLen,var.name())).append(":");
        sb.append(getPrettyPrintStr(value));
        sb.append("\n");
      }
    } catch (AbsentInformationException e) {
View Full Code Here

  }
 
  public static String reftype(String expXmlStr) {
    List<Expression> exps = Expression.parseExpXmlStr(expXmlStr);
    if (exps ==null || exps.size() == 0) return "";
    Value value = getJdiValue(exps.get(0));
    return value.type().name();
  }
View Full Code Here

  public static String inspect(String expXmlStr) {
    List<Expression> exps = Expression.parseExpXmlStr(expXmlStr);
    if (exps ==null || exps.size() == 0) return "";
    Expression exp = exps.get(0);
    Value value = getJdiValue(exp);
   
    StringBuilder sb = new StringBuilder();
    if (value instanceof ObjectReference) {
      sb.append(exp.getOriExp()).append(" = ");
      sb.append(value.type().name()).append("\n");
     
      ObjectReference objRef = (ObjectReference) value;
      Map<Field, Value> values = objRef.getValues(objRef.referenceType().visibleFields());
      List<String> fieldNames = new ArrayList<String>();
      for (Field field : values.keySet()) {
View Full Code Here

    ThreadReference threadRef = checkAndGetCurrentThread();
    try {
      SuspendThreadStack threadStack = SuspendThreadStack.getInstance();
      StackFrame stackFrame = threadRef.frame(threadStack.getCurFrame());
      ObjectReference thisObj = stackFrame.thisObject();
      Value value = eval(threadRef, exp, thisObj,false);
      return value;
    } catch (IncompatibleThreadStateException e) {
      throw new ExpressionEvalException("eval expression error, caused by : " + e.getMessage());
    }
  }
View Full Code Here

      } else {
        return vm.mirrorOf(Integer.parseInt(expName));
      }
    }

    Value basicExpValue = null;
    if (!exp.isMethod()) {
      basicExpValue = findValueInFrame(threadRef, expName,thisObj,hasParents);
    } else {
      List<Expression> params = exp.getParams();
      List<Value> arguments = new ArrayList<Value>();
      if (params.size() != 0) {
        for (Expression param : params) {
          Value paramValue = eval(threadRef, param, thisObj,false);
          arguments.add(paramValue);
        }
      }
      basicExpValue = invoke((ObjectReference) thisObj, expName, arguments);
    }
     
    if (exp.isArrayExp()) {
      if (basicExpValue instanceof ArrayReference) {
        ArrayReference array = (ArrayReference)basicExpValue;
        Value arrayIdxValue = eval(threadRef, exp.getArrayIdxExp(), thisObj,false);
        if (arrayIdxValue instanceof IntegerValue ) {
          int idx = ((IntegerValue)arrayIdxValue).value();
          basicExpValue = array.getValue(idx);
        else {
          throw new ExpressionEvalException("eval expression error, array index is not int type.");
        }
      }
    }

    List<Expression> members = exp.getMembers();
    if (members.size() == 0)
      return basicExpValue;
    if (exp.isStaticMember()) {
      Expression memberExp = members.get(0);
      List<Expression> params = memberExp.getParams();
      List<Value> arguments = new ArrayList<Value>();
      if (params.size() != 0) {
        for (Expression param : params) {
          Value paramValue = eval(threadRef, param, thisObj,false);
          arguments.add(paramValue);
        }
      }
      List<ReferenceType> refTypes = vm.classesByName(exp.getName());
      if (refTypes == null || refTypes.size() == 0) {
View Full Code Here

TOP

Related Classes of com.sun.jdi.Value

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.