Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

netscape.jsdebug
Class ThreadStateBase  view ThreadStateBase download ThreadStateBase.java

java.lang.Object
  extended bynetscape.jsdebug.ThreadStateBase
Direct Known Subclasses:
JSThreadState

public abstract class ThreadStateBase
extends java.lang.Object

When a hook is hit, the debugger records the state of the thread before the hook in a ThreadState object. This object is then passed to any hook methods that are called, and can be used to change the state of the thread when it resumes from the hook.

Since:
1.0
Version:
1.0

Field Summary
protected  int continueState
           
protected  java.lang.Throwable currentException
           
protected  int currentFramePtr
           
static int DEBUG_STATE_DEAD
          if the continueState is DEAD, the thread cannot be restarted.
static int DEBUG_STATE_RETURN
          if the continueState is RETURN, the thread will return from the current method with the value in getReturnValue() when it resumes.
static int DEBUG_STATE_RUN
          if the continueState is RUN, the thread will proceed to the next program counter value when it resumes.
static int DEBUG_STATE_THROW
          if the continueState is THROW, the thread will throw an exception (accessible with getException()) when it resumes.
protected  ThreadStateBase previous
           
protected  boolean resumeWhenDone
           
protected  java.lang.Object returnValue
           
protected  boolean runningHook
           
protected  StackFrameInfo[] stack
           
protected  int status
           
static int THR_STATUS_BREAK
           
static int THR_STATUS_CONDWAIT
           
static int THR_STATUS_MONWAIT
           
static int THR_STATUS_RUNNING
           
static int THR_STATUS_SLEEPING
           
static int THR_STATUS_SUSPENDED
           
static int THR_STATUS_UNKNOWN
          partial list of thread states from sun.debug.ThreadInfo.
static int THR_STATUS_ZOMBIE
           
protected  java.lang.Thread thread
           
protected  boolean valid
           
 
Constructor Summary
ThreadStateBase()
           
 
Method Summary
abstract  int countStackFrames()
          Get the count of the stackframes
 int getContinueState()
          This gets the current continue state of the debug frame, which will be one of the DEBUG_STATE_* values above.
abstract  StackFrameInfo getCurrentFrame()
          Get the 'top' stackframe; i.e.
 java.lang.Throwable getException()
          If the thread was stopped while in the process of throwing an exception, this call returns that exception.
 java.lang.Object getReturnValue()
          If the thread was stopped while in the process of returning a value, this call returns an object representing that value.
 StackFrameInfo[] getStack()
          Get the thread's stack as an array.
 int getStatus()
          Get the state of the thread at the time it entered debug mode.
 java.lang.Thread getThread()
          Get the Thread that this ThreadState came from.
static ThreadStateBase getThreadState(java.lang.Thread t)
          Not Implemented. Always throws InternalError("unimplemented")
 boolean isRunningHook()
          Return true if the thread is currently running a hook for this ThreadState
 boolean isValid()
          Return true if the Thread hasn't been resumed since this ThreadState was made.
 void leaveSuspended()
          Leave the thread in a suspended state when the hook method(s) finish.
 void resume()
          Resume the thread.
protected abstract  void resume0()
           
 int setContinueState(int state)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

thread

protected java.lang.Thread thread

valid

protected boolean valid

runningHook

protected boolean runningHook

resumeWhenDone

protected boolean resumeWhenDone

status

protected int status

continueState

protected int continueState

stack

protected StackFrameInfo[] stack

returnValue

protected java.lang.Object returnValue

currentException

protected java.lang.Throwable currentException

currentFramePtr

protected int currentFramePtr

previous

protected ThreadStateBase previous

THR_STATUS_UNKNOWN

public static final int THR_STATUS_UNKNOWN
partial list of thread states from sun.debug.ThreadInfo. XXX some of these don't apply.

See Also:
Constant Field Values

THR_STATUS_ZOMBIE

public static final int THR_STATUS_ZOMBIE
See Also:
Constant Field Values

THR_STATUS_RUNNING

public static final int THR_STATUS_RUNNING
See Also:
Constant Field Values

THR_STATUS_SLEEPING

public static final int THR_STATUS_SLEEPING
See Also:
Constant Field Values

THR_STATUS_MONWAIT

public static final int THR_STATUS_MONWAIT
See Also:
Constant Field Values

THR_STATUS_CONDWAIT

public static final int THR_STATUS_CONDWAIT
See Also:
Constant Field Values

THR_STATUS_SUSPENDED

public static final int THR_STATUS_SUSPENDED
See Also:
Constant Field Values

THR_STATUS_BREAK

public static final int THR_STATUS_BREAK
See Also:
Constant Field Values

DEBUG_STATE_DEAD

public static final int DEBUG_STATE_DEAD
if the continueState is DEAD, the thread cannot be restarted.

See Also:
Constant Field Values

DEBUG_STATE_RUN

public static final int DEBUG_STATE_RUN
if the continueState is RUN, the thread will proceed to the next program counter value when it resumes.

See Also:
Constant Field Values

DEBUG_STATE_RETURN

public static final int DEBUG_STATE_RETURN
if the continueState is RETURN, the thread will return from the current method with the value in getReturnValue() when it resumes.

See Also:
Constant Field Values

DEBUG_STATE_THROW

public static final int DEBUG_STATE_THROW
if the continueState is THROW, the thread will throw an exception (accessible with getException()) when it resumes.

See Also:
Constant Field Values
Constructor Detail

ThreadStateBase

public ThreadStateBase()
Method Detail

getThreadState

public static ThreadStateBase getThreadState(java.lang.Thread t)
                                      throws InvalidInfoException
Not Implemented. Always throws InternalError("unimplemented")


getThread

public java.lang.Thread getThread()
Get the Thread that this ThreadState came from.


isValid

public boolean isValid()
Return true if the Thread hasn't been resumed since this ThreadState was made.


isRunningHook

public boolean isRunningHook()
Return true if the thread is currently running a hook for this ThreadState


getStatus

public int getStatus()
Get the state of the thread at the time it entered debug mode. This can't be modified directly.


countStackFrames

public abstract int countStackFrames()
                              throws InvalidInfoException
Get the count of the stackframes


getCurrentFrame

public abstract StackFrameInfo getCurrentFrame()
                                        throws InvalidInfoException
Get the 'top' stackframe; i.e. the one with the current instruction


getStack

public StackFrameInfo[] getStack()
                          throws InvalidInfoException
Get the thread's stack as an array. stack[stack.length-1] is the current frame, and stack[0] is the beginning of the stack.


leaveSuspended

public void leaveSuspended()
Leave the thread in a suspended state when the hook method(s) finish. This can be undone by calling resume(). This is the default only if the break was the result of DebugController.sendInterrupt().


resume

public void resume()
Resume the thread. This is the default unless the break was the result of DebugController.sendInterrupt(). This method may be called from a hook method, in which case the thread will resume when the method returns. Alternatively, if there is no active hook method and the thread is suspended around in the DebugFrame, this resumes it immediately.


resume0

protected abstract void resume0()

getContinueState

public int getContinueState()
This gets the current continue state of the debug frame, which will be one of the DEBUG_STATE_* values above.


setContinueState

public int setContinueState(int state)

getReturnValue

public java.lang.Object getReturnValue()
                                throws java.lang.IllegalStateException
If the thread was stopped while in the process of returning a value, this call returns an object representing that value. non-Object values are wrapped as in the java.lang.reflect api. This is only relevant if the continue state is RETURN, and the method throws an IllegalStateException otherwise.


getException

public java.lang.Throwable getException()
                                 throws java.lang.IllegalStateException
If the thread was stopped while in the process of throwing an exception, this call returns that exception. This is only relevant if the continue state is THROW, and it throws an IllegalStateException otherwise.