예제 #1
0
 private void printVar(OutputSink out, LocalVariable var, StackFrame frame) {
   out.print("  " + var.name());
   if (var.isVisible(frame)) {
     Value val = frame.getValue(var);
     out.println(" = " + val.toString());
   } else {
     out.println(" is not in scope");
   }
 }
예제 #2
0
  private void commandLocals() throws NoSessionException {
    ThreadReference current = context.getCurrentThread();
    if (current == null) {
      env.failure("No default thread specified: " + "use the \"thread\" command first.");
      return;
    }
    StackFrame frame;
    try {
      frame = context.getCurrentFrame(current);
      if (frame == null) {
        env.failure("Thread has not yet created any stack frames.");
        return;
      }
    } catch (VMNotInterruptedException e) {
      env.failure("Target VM must be in interrupted state.");
      return;
    }

    List<LocalVariable> vars;
    try {
      vars = frame.visibleVariables();
      if (vars == null || vars.size() == 0) {
        env.failure("No local variables");
        return;
      }
    } catch (AbsentInformationException e) {
      env.failure(
          "Local variable information not available."
              + " Compile with -g to generate variable information");
      return;
    }

    OutputSink out = env.getOutputSink();
    out.println("Method arguments:");
    for (LocalVariable var : vars) {
      if (var.isArgument()) {
        printVar(out, var, frame);
      }
    }
    out.println("Local variables:");
    for (LocalVariable var : vars) {
      if (!var.isArgument()) {
        printVar(out, var, frame);
      }
    }
    out.show();
    return;
  }
예제 #3
0
 /**
  * Initialize from another object. Note that both objects use the same references (shallow copy).
  * Use copy() for a physical copy.
  */
 public LocalVariable(LocalVariable c) {
   this(
       c.getStartPC(),
       c.getLength(),
       c.getNameIndex(),
       c.getSignatureIndex(),
       c.getIndex(),
       c.getConstantPool());
 }