"

2013 FRC Java API

"

com.sun.squawk
Class DebuggerSupport

java.lang.Object
  extended by com.sun.squawk.DebuggerSupport

public class DebuggerSupport
extends Object

Provides support for the Squawk Debugger Agent SDA Some of this is to fit in to package encapsulation.


Nested Class Summary
static class DebuggerSupport.SlotSetter
          A SlotSetter is a kind of StackInspector that can set the value of a slot
static class DebuggerSupport.StackInspector
          A StackInspector instance is used in conjunction with inspectStack(com.sun.squawk.DebuggerSupport.StackInspector, com.sun.squawk.ExecutionPoint, int) to traverse one or more stack frames in a suspended thread.
 
Method Summary
static int countStackFrames(VMThread vmThread, ExecutionPoint from)
          Count the number of frames on the stack, while thread is temporarily suspended.
static Klass getDefiningClass(Object methodBody)
          Gets the class in which a given method was defined.s
static DataType.MethodID getIDForMethodBody(Klass definingClass, Object methodBody)
          Gets the JDWP identifier for a method given the method's body.
static int getIDForROMObject(Object object)
          Determines if a given object is in a read-only memory and returns a non-zero identifier for the object if it is.
static String getJNISignature(Field field)
          Gets the JNI signature of a field's type.
static String getJNISignature(Klass klass)
          Gets the JNI signature of a klass.
static String getJNISignature(Method method)
          Gets the JNI signature of a method's parameters and return type.
static Object getMethodBody(Klass klass, int offset, boolean isStatic)
          Gets the body of the method given a class and method table index.
static int getMethodBodyLength(Object methodBody)
          Return the length of methodBody (the byte code array) in bytes.
static Object getROMObjectForID(int id)
          Gets the object in read-only memory corresponding to an identifier that was returned from a call to getIDForROMObject(java.lang.Object).
static int getStaticInt(Isolate isolate, Klass klass, int offset)
          Reads a static int variable.
static long getStaticLong(Isolate isolate, Klass klass, int offset)
          Reads a static long variable.
static Object getStaticOop(Isolate isolate, Klass klass, int offset)
          Reads a static reference variable.
static ExecutionPoint getThreadCurrentExecutionPoint(VMThread thread)
          Get execution state of non-running thread.
static int getThreadJDWPState(VMThread vmThread)
          Return the JDWP.ThreadStatus value for the given thread's internal state.
static int inspectStack(DebuggerSupport.StackInspector inspector, ExecutionPoint from, int frameNo)
          Traverses one or more stack frames in a thread (that must be suspended).
static boolean isAtExceptionBreakpoint(VMThread vmThread)
          Determines if the current hit breakpoint (if any) is an exception breakpoint.
static boolean isInitialized(Klass klass, Isolate isolate)
          Determines if a given class is initialized in a given isolate.
static void setDebugger(Isolate isolate, Debugger debugger, boolean attach)
          Attaches or detaches a debugger to an isolate.
static void setStaticInt(Isolate isolate, Klass klass, int offset, int value)
          Writes a static int variable.
static void setStaticLong(Isolate isolate, Klass klass, int offset, long value)
          Writes a static long variable.
static void setStaticOop(Isolate isolate, Klass klass, int offset, Object value)
          Writes a static reference variable.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getThreadJDWPState

public static int getThreadJDWPState(VMThread vmThread)
Return the JDWP.ThreadStatus value for the given thread's internal state.

Parameters:
vmThread - VMThread
Returns:
the JDWP.ThreadStatus value

getJNISignature

public static String getJNISignature(Klass klass)
Gets the JNI signature of a klass. This conversion substitutes the appropriate primitive type for the Squawk primitives.

Parameters:
klass - a class
Returns:
the JNI signature for klass
See Also:
JNI Signatures

getJNISignature

public static String getJNISignature(Field field)
Gets the JNI signature of a field's type.

Parameters:
field - a field
Returns:
the JNI signature for field
See Also:
JNI Signatures

getJNISignature

public static String getJNISignature(Method method)
Gets the JNI signature of a method's parameters and return type.

Parameters:
method - a method
Returns:
the JNI signature for method
See Also:
JNI Signatures

getIDForROMObject

public static int getIDForROMObject(Object object)
Determines if a given object is in a read-only memory and returns a non-zero identifier for the object if it is. The identifier can be decoded by calling getROMObjectForID(int)

Parameters:
object - the object to test
Returns:
a non-zero positive identifier for object if it's in a read-only memory otherwise 0

getROMObjectForID

public static Object getROMObjectForID(int id)
Gets the object in read-only memory corresponding to an identifier that was returned from a call to getIDForROMObject(java.lang.Object).

Parameters:
id - an identifier for an object in read-only memory (must be positive)
Returns:
the object corresponding to id

isInitialized

public static boolean isInitialized(Klass klass,
                                    Isolate isolate)
Determines if a given class is initialized in a given isolate.

Parameters:
klass - the class to test
isolate - the isolate context
Returns:
true if klass is intialized in isolate

getStaticOop

public static Object getStaticOop(Isolate isolate,
                                  Klass klass,
                                  int offset)
Reads a static reference variable.

Parameters:
isolate - the isolate context to use for variable lookup
klass - the class of the variable
offset - the offset (in words) to the variable
Returns:
the value

getStaticInt

public static int getStaticInt(Isolate isolate,
                               Klass klass,
                               int offset)
Reads a static int variable.

Parameters:
isolate - the isolate context to use for variable lookup
klass - the class of the variable
offset - the offset (in words) to the variable
Returns:
the value

getStaticLong

public static long getStaticLong(Isolate isolate,
                                 Klass klass,
                                 int offset)
Reads a static long variable.

Parameters:
isolate - the isolate context to use for variable lookup
klass - the class of the variable
offset - the offset (in words) to the variable
Returns:
the value

setStaticOop

public static void setStaticOop(Isolate isolate,
                                Klass klass,
                                int offset,
                                Object value)
Writes a static reference variable.

Parameters:
isolate - the isolate context to use for variable lookup
klass - the class of the variable
offset - the offset (in words) to the variable
value -

setStaticInt

public static void setStaticInt(Isolate isolate,
                                Klass klass,
                                int offset,
                                int value)
Writes a static int variable.

Parameters:
isolate - the isolate context to use for variable lookup
klass - the class of the variable
offset - the offset (in words) to the variable
value -

setStaticLong

public static void setStaticLong(Isolate isolate,
                                 Klass klass,
                                 int offset,
                                 long value)
Writes a static long variable.

Parameters:
isolate - the isolate context to use for variable lookup
klass - the class of the variable
offset - the offset (in words) to the variable
value -

getDefiningClass

public static Klass getDefiningClass(Object methodBody)
Gets the class in which a given method was defined.s

Parameters:
methodBody - the body of a method
Returns:
the class in which methodBody was defined

getMethodBody

public static Object getMethodBody(Klass klass,
                                   int offset,
                                   boolean isStatic)
Gets the body of the method given a class and method table index.

Parameters:
klass - the class that defined the method
offset - the index of the method in its enclosing methods table
isStatic - true if the requested method is static, false if it is virtual
Returns:
the designated method body

getMethodBodyLength

public static int getMethodBodyLength(Object methodBody)
Return the length of methodBody (the byte code array) in bytes.

Parameters:
methodBody - Object
Returns:
number of bytecodes

getIDForMethodBody

public static DataType.MethodID getIDForMethodBody(Klass definingClass,
                                                   Object methodBody)
Gets the JDWP identifier for a method given the method's body.

Parameters:
definingClass - the class that defined the method
methodBody - the method's body
Returns:
the JDWP identifier for methodBody

isAtExceptionBreakpoint

public static boolean isAtExceptionBreakpoint(VMThread vmThread)
Determines if the current hit breakpoint (if any) is an exception breakpoint.

Parameters:
vmThread - thread to check
Returns:
true if the given thread is at an exception breakpoint.

getThreadCurrentExecutionPoint

public static ExecutionPoint getThreadCurrentExecutionPoint(VMThread thread)
Get execution state of non-running thread. This is different from the saved execution point recorded by breakpoints, stepping, exception handling, etc.

Parameters:
thread -
Returns:
current execution point

inspectStack

public static int inspectStack(DebuggerSupport.StackInspector inspector,
                               ExecutionPoint from,
                               int frameNo)
Traverses one or more stack frames in a thread (that must be suspended).

Parameters:
inspector - the frame inspector delegate
from - the location in the call stack of the thread at which to start inspecting. If null, then inspection starts at the inner most frame.
frameNo - the frame to inspect or -1 if all frames are to be inspected. A frame is identified by the number of frames between it and the inner most frame (i.e. the inner most frame will be 0)
Returns:
the number of frames inspected

setDebugger

public static void setDebugger(Isolate isolate,
                               Debugger debugger,
                               boolean attach)
Attaches or detaches a debugger to an isolate.

Parameters:
isolate - the target debuggee isolate
debugger - the debugger wanting to attach or detach
attach - specifies if this in an attach or detach operation

countStackFrames

public static int countStackFrames(VMThread vmThread,
                                   ExecutionPoint from)
Count the number of frames on the stack, while thread is temporarily suspended.

Parameters:
vmThread - the thread to count the frames of
from - the location in the call stack of the thread at which to start inspecting. If null, then inspection starts at the inner most frame.
Returns:
number of frames

"

2013 FRC Java API

"

"
For updated information see the Java FRC site
"