home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / sun / tools / debug / RemoteThread.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-08  |  4.0 KB  |  184 lines

  1. package sun.tools.debug;
  2.  
  3. public class RemoteThread extends RemoteObject {
  4.    private int currentFrame;
  5.    private RemoteStackFrame[] stack;
  6.    private boolean suspended = false;
  7.  
  8.    RemoteThread(RemoteAgent var1, int var2, RemoteClass var3) {
  9.       super(var1, 19, var2, var3);
  10.    }
  11.  
  12.    public String getName() throws Exception {
  13.       return super.agent.getThreadName(super.id);
  14.    }
  15.  
  16.    public int getCurrentFrameIndex() {
  17.       return this.currentFrame;
  18.    }
  19.  
  20.    public void setCurrentFrameIndex(int var1) {
  21.       this.currentFrame = var1;
  22.    }
  23.  
  24.    public void resetCurrentFrameIndex() {
  25.       this.currentFrame = 0;
  26.    }
  27.  
  28.    // $FF: renamed from: up (int) void
  29.    public void method_0(int var1) throws Exception {
  30.       int var2 = super.agent.getThreadStatus(super.id);
  31.       if (var2 != 5 && var2 != 6) {
  32.          throw new IllegalAccessError();
  33.       } else {
  34.          if (this.stack == null) {
  35.             this.stack = super.agent.dumpStack(this);
  36.          }
  37.  
  38.          if (this.currentFrame + var1 >= this.stack.length) {
  39.             throw new ArrayIndexOutOfBoundsException();
  40.          } else {
  41.             this.currentFrame += var1;
  42.          }
  43.       }
  44.    }
  45.  
  46.    public void down(int var1) throws Exception {
  47.       int var2 = super.agent.getThreadStatus(super.id);
  48.       if (var2 != 5 && var2 != 6) {
  49.          throw new IllegalAccessError();
  50.       } else {
  51.          if (this.stack == null) {
  52.             this.stack = super.agent.dumpStack(this);
  53.          }
  54.  
  55.          if (this.currentFrame - var1 < 0) {
  56.             throw new ArrayIndexOutOfBoundsException();
  57.          } else {
  58.             this.currentFrame -= var1;
  59.          }
  60.       }
  61.    }
  62.  
  63.    public String getStatus() throws Exception {
  64.       int var1 = super.agent.getThreadStatus(super.id);
  65.       switch (var1) {
  66.          case -1:
  67.             return "";
  68.          case 0:
  69.             return "zombie";
  70.          case 1:
  71.             return "running";
  72.          case 2:
  73.             return "sleeping";
  74.          case 3:
  75.             return "waiting in a monitor";
  76.          case 4:
  77.             return "cond. waiting";
  78.          case 5:
  79.             return "suspended";
  80.          case 6:
  81.             return "at breakpoint";
  82.          default:
  83.             return "invalid status returned";
  84.       }
  85.    }
  86.  
  87.    public RemoteStackFrame[] dumpStack() throws Exception {
  88.       this.stack = super.agent.dumpStack(this);
  89.       return this.stack;
  90.    }
  91.  
  92.    public RemoteStackFrame getCurrentFrame() throws Exception {
  93.       int var1 = super.agent.getThreadStatus(super.id);
  94.       if (var1 != 5 && var1 != 6) {
  95.          throw new IllegalAccessError();
  96.       } else {
  97.          if (this.stack == null) {
  98.             this.stack = super.agent.dumpStack(this);
  99.          }
  100.  
  101.          return this.stack[this.currentFrame];
  102.       }
  103.    }
  104.  
  105.    public void suspend() throws Exception {
  106.       if (!this.suspended) {
  107.          super.agent.suspendThread(super.id);
  108.          this.suspended = true;
  109.       }
  110.  
  111.    }
  112.  
  113.    public void resume() throws Exception {
  114.       if (this.suspended) {
  115.          super.agent.resumeThread(super.id);
  116.          this.suspended = false;
  117.       }
  118.  
  119.    }
  120.  
  121.    public void step(boolean var1) throws Exception {
  122.       int var2 = super.agent.getThreadStatus(super.id);
  123.       if (var2 != 5 && var2 != 6) {
  124.          throw new IllegalAccessError();
  125.       } else {
  126.          super.agent.stepThread(super.id, var1);
  127.       }
  128.    }
  129.  
  130.    public void next() throws Exception {
  131.       int var1 = super.agent.getThreadStatus(super.id);
  132.       if (var1 != 5 && var1 != 6) {
  133.          throw new IllegalAccessError();
  134.       } else {
  135.          super.agent.stepNextThread(super.id);
  136.       }
  137.    }
  138.  
  139.    public boolean isSuspended() {
  140.       return this.suspended;
  141.    }
  142.  
  143.    public void cont() throws Exception {
  144.       if (!this.suspended) {
  145.          super.agent.resumeThread(super.id);
  146.       }
  147.  
  148.    }
  149.  
  150.    public void stop() throws Exception {
  151.       super.agent.stopThread(super.id);
  152.    }
  153.  
  154.    public RemoteStackVariable getStackVariable(String var1) throws Exception {
  155.       super.agent.message("getStackVariable: thread=" + this.getName() + ", currentFrame=" + this.currentFrame);
  156.       int var2 = super.agent.getThreadStatus(super.id);
  157.       if (var2 != 5 && var2 != 6) {
  158.          super.agent.message("getStackVariable: bogus thread status=" + var2);
  159.          return null;
  160.       } else {
  161.          if (this.stack == null) {
  162.             this.stack = super.agent.dumpStack(this);
  163.          }
  164.  
  165.          return this.stack[this.currentFrame].getLocalVariable(var1);
  166.       }
  167.    }
  168.  
  169.    public RemoteStackVariable[] getStackVariables() throws Exception {
  170.       super.agent.message("getStackVariables: thread=" + this.getName() + ", currentFrame=" + this.currentFrame);
  171.       int var1 = super.agent.getThreadStatus(super.id);
  172.       if (var1 != 5 && var1 != 6) {
  173.          super.agent.message("getStackVariables: bogus thread status=" + var1);
  174.          return null;
  175.       } else {
  176.          if (this.stack == null) {
  177.             this.stack = super.agent.dumpStack(this);
  178.          }
  179.  
  180.          return this.stack[this.currentFrame].getLocalVariables();
  181.       }
  182.    }
  183. }
  184.