edu.rice.cs.drjava.model.debug
Class NoDebuggerAvailable

java.lang.Object
  extended by edu.rice.cs.drjava.model.debug.NoDebuggerAvailable
All Implemented Interfaces:
Debugger

public class NoDebuggerAvailable
extends Object
implements Debugger

Placeholder class indicating that no debugger is available to DrJava. This class follows the Singleton pattern.

Version:
$Id: NoDebuggerAvailable.java 4641 2008-08-21 06:20:45Z rcartwright $

Nested Class Summary
 
Nested classes/interfaces inherited from interface edu.rice.cs.drjava.model.debug.Debugger
Debugger.StepType
 
Field Summary
static NoDebuggerAvailable ONLY
          Singleton instance of this class.
 
Method Summary
 void addListener(DebugListener listener)
          Adds a listener to this Debugger.
 void addWatch(String field)
          Adds a watch on the given field or variable.
 DebugModelCallback callback()
           
 void clearCurrentStepRequest()
          Called from interactionsEnded in MainFrame in order to clear any current StepRequests that remain.
 Breakpoint getBreakpoint(int line, String className)
          Gets the Breakpoint object at the specified line in the given class.
 ArrayList<DebugStackData> getCurrentStackFrameData()
          Returns a Vector of StackData for the current thread or null if the current thread is null.
 ArrayList<DebugThreadData> getCurrentThreadData()
          Returns a Vector of ThreadData or null if the vm is null.
 ArrayList<DebugWatchData> getWatches()
          Returns all currently watched fields and variables.
 boolean hasRunningThread()
          Returns whether the thread the debugger is tracking is now running.
 boolean hasSuspendedThreads()
           
 boolean isAvailable()
          Returns whether the debugger is currently available in this JVM.
 boolean isCurrentThreadSuspended()
          Returns whether the debugger's current thread is suspended.
 boolean isReady()
          Returns the status of the debugger.
 void removeAllWatches()
          Removes all watches on existing fields and variables.
 void removeBreakpoint(Breakpoint breakpoint)
          Removes a breakpoint.
 void removeListener(DebugListener listener)
          Removes a listener to this JPDADebugger.
 void removeWatch(int index)
          Removes the watch at the given index.
 void removeWatch(String field)
          Removes any watches on the given field or variable.
 void resume()
          Resumes execution of the currently loaded document.
 void resume(DebugThreadData data)
          Resumes execution of the given thread.
 void scrollToSource(Breakpoint bp)
          Scrolls to the source indicated by the given Breakpoint
 void scrollToSource(DebugStackData data)
          Scrolls to the source indicated by the given DebugStackData
 void setBreakpoint(Breakpoint breakpoint)
          Sets a breakpoint.
 void setCurrentThread(DebugThreadData d)
          Sets the current thread which is being debugged to the thread referenced by d.
 void shutdown()
          Disconnects the debugger from the Interactions JVM and cleans up any state.
 void startUp()
          Attaches the debugger to the Interactions JVM to prepare for debugging.
 void step(Debugger.StepType type)
          Steps the execution of the currently loaded document.
 void suspend(DebugThreadData d)
          Suspends execution of the currently.
 void suspendAll()
          Suspends all the threads.
 boolean toggleBreakpoint(OpenDefinitionsDocument doc, int offset, int lineNum, boolean isEnabled)
          Toggles whether a breakpoint is set at the given line in the given document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONLY

public static final NoDebuggerAvailable ONLY
Singleton instance of this class.

Method Detail

isAvailable

public boolean isAvailable()
Returns whether the debugger is currently available in this JVM. This does not indicate whether it is ready to be used.

Specified by:
isAvailable in interface Debugger

callback

public DebugModelCallback callback()
Specified by:
callback in interface Debugger

startUp

public void startUp()
             throws DebugException
Attaches the debugger to the Interactions JVM to prepare for debugging.

Specified by:
startUp in interface Debugger
Throws:
DebugException

shutdown

public void shutdown()
Disconnects the debugger from the Interactions JVM and cleans up any state.

Specified by:
shutdown in interface Debugger

isReady

public boolean isReady()
Returns the status of the debugger.

Specified by:
isReady in interface Debugger

suspend

public void suspend(DebugThreadData d)
Suspends execution of the currently.


suspendAll

public void suspendAll()
Suspends all the threads.


setCurrentThread

public void setCurrentThread(DebugThreadData d)
Sets the current thread which is being debugged to the thread referenced by d.

Specified by:
setCurrentThread in interface Debugger

resume

public void resume()
Resumes execution of the currently loaded document.

Specified by:
resume in interface Debugger

resume

public void resume(DebugThreadData data)
Resumes execution of the given thread.

Specified by:
resume in interface Debugger
Parameters:
data - the DebugThreadData representing the thread to resume

step

public void step(Debugger.StepType type)
          throws DebugException
Steps the execution of the currently loaded document.

Specified by:
step in interface Debugger
Throws:
DebugException

clearCurrentStepRequest

public void clearCurrentStepRequest()
Called from interactionsEnded in MainFrame in order to clear any current StepRequests that remain.


addWatch

public void addWatch(String field)
Adds a watch on the given field or variable.

Specified by:
addWatch in interface Debugger
Parameters:
field - the name of the field we will watch

removeWatch

public void removeWatch(String field)
Removes any watches on the given field or variable.

Specified by:
removeWatch in interface Debugger
Parameters:
field - the name of the field we will watch

removeWatch

public void removeWatch(int index)
Removes the watch at the given index.

Specified by:
removeWatch in interface Debugger
Parameters:
index - Index of the watch to remove

removeAllWatches

public void removeAllWatches()
Removes all watches on existing fields and variables.

Specified by:
removeAllWatches in interface Debugger

toggleBreakpoint

public boolean toggleBreakpoint(OpenDefinitionsDocument doc,
                                int offset,
                                int lineNum,
                                boolean isEnabled)
                         throws DebugException
Toggles whether a breakpoint is set at the given line in the given document.

Specified by:
toggleBreakpoint in interface Debugger
Parameters:
doc - Document in which to set or remove the breakpoint
offset - Start offset on the line to set the breakpoint
lineNum - Line on which to set or remove the breakpoint, >=1
isEnabled - true if this breakpoint should be enabled
Throws:
DebugException

setBreakpoint

public void setBreakpoint(Breakpoint breakpoint)
Sets a breakpoint.

Specified by:
setBreakpoint in interface Debugger
Parameters:
breakpoint - The new breakpoint to set

removeBreakpoint

public void removeBreakpoint(Breakpoint breakpoint)
Removes a breakpoint.

Specified by:
removeBreakpoint in interface Debugger
Parameters:
breakpoint - The breakpoint to remove.

getWatches

public ArrayList<DebugWatchData> getWatches()
Returns all currently watched fields and variables.

Specified by:
getWatches in interface Debugger

getCurrentThreadData

public ArrayList<DebugThreadData> getCurrentThreadData()
Returns a Vector of ThreadData or null if the vm is null.

Specified by:
getCurrentThreadData in interface Debugger

getCurrentStackFrameData

public ArrayList<DebugStackData> getCurrentStackFrameData()
Returns a Vector of StackData for the current thread or null if the current thread is null.

Specified by:
getCurrentStackFrameData in interface Debugger

addListener

public void addListener(DebugListener listener)
Adds a listener to this Debugger.

Specified by:
addListener in interface Debugger
Parameters:
listener - a listener that reacts on events generated by the Debugger

removeListener

public void removeListener(DebugListener listener)
Removes a listener to this JPDADebugger.

Specified by:
removeListener in interface Debugger
Parameters:
listener - listener to remove

hasSuspendedThreads

public boolean hasSuspendedThreads()
Specified by:
hasSuspendedThreads in interface Debugger
Returns:
true if there are any threads in the program currently being debugged which have been suspended (by the user or by hitting a breakpoint).

hasRunningThread

public boolean hasRunningThread()
Returns whether the thread the debugger is tracking is now running.

Specified by:
hasRunningThread in interface Debugger

isCurrentThreadSuspended

public boolean isCurrentThreadSuspended()
Returns whether the debugger's current thread is suspended.

Specified by:
isCurrentThreadSuspended in interface Debugger

scrollToSource

public void scrollToSource(DebugStackData data)
Scrolls to the source indicated by the given DebugStackData

Specified by:
scrollToSource in interface Debugger
Parameters:
data - the DebugStackData representing the source location

scrollToSource

public void scrollToSource(Breakpoint bp)
Scrolls to the source indicated by the given Breakpoint

Specified by:
scrollToSource in interface Debugger
Parameters:
bp - the Breakpoint representing the source location

getBreakpoint

public Breakpoint getBreakpoint(int line,
                                String className)
Gets the Breakpoint object at the specified line in the given class.

Specified by:
getBreakpoint in interface Debugger
Returns:
the Breakpoint corresponding to the line and className, or null if there is no such breakpoint.