public class Debugger extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
Debugger.VMEventListener
Interface for VM callbacks.
|
protected static class |
Debugger.VMEventReader
Reader Thread for VM Events.
|
| Modifier and Type | Field and Description |
|---|---|
protected List<LineBreakpoint> |
breakpoints |
protected Set<com.sun.jdi.ReferenceType> |
classes |
protected List<ClassLoadListener> |
classLoadListeners |
protected com.sun.jdi.ThreadReference |
currentThread |
protected JavaEditor |
editor |
protected com.sun.jdi.ReferenceType |
mainClass |
protected String |
mainClassName |
protected boolean |
paused |
protected com.sun.jdi.request.StepRequest |
requestedStep |
protected Runner |
runtime |
protected Map<LineID,LineID> |
runtimeLineChanges |
protected Set<String> |
runtimeTabsTracked |
protected String |
srcPath |
protected boolean |
started |
protected Debugger.VMEventListener |
vmEventListener |
| Constructor and Description |
|---|
Debugger(JavaEditor editor) |
| Modifier and Type | Method and Description |
|---|---|
void |
addClassLoadListener(ClassLoadListener listener)
Add a class load listener.
|
void |
continueDebug()
Resume paused debugging session.
|
protected String |
currentLocation(com.sun.jdi.ThreadReference t)
Get a description of the current location in a suspended thread.
|
protected List<VariableNode> |
getArrayFields(com.sun.jdi.ArrayReference array)
Get the fields of an array for insertion into a
JTree. |
Set<com.sun.jdi.ReferenceType> |
getClasses()
Get the main and nested
ReferenceTypes for the sketch. |
JavaEditor |
getEditor() |
List<VariableNode> |
getFields(com.sun.jdi.Value value,
int maxDepth,
boolean includeInherited)
Recursively get the fields of a
Value for insertion into a
JTree. |
protected List<VariableNode> |
getFields(com.sun.jdi.Value value,
int depth,
int maxDepth,
boolean includeInherited)
Recursively get the fields of a
Value for insertion into a
JTree. |
protected List<VariableNode> |
getLocals(com.sun.jdi.ThreadReference t,
int depth)
Compile a list of current locals usable for insertion into a
JTree. |
com.sun.jdi.ReferenceType |
getMainClass()
Retrieve the main class of the debuggee VM.
|
protected String |
getSourceLine(String filePath,
int lineNo,
int radius)
Read a line from the given file in the builds src folder.
1-based i.e. first line has line no. 1
|
protected List<DefaultMutableTreeNode> |
getStackTrace(com.sun.jdi.ThreadReference t)
Get the current call stack trace usable for insertion into a
JTree. |
protected List<VariableNode> |
getThisFields(com.sun.jdi.ThreadReference t,
int depth,
boolean includeInherited)
Compile a list of fields in the current this object usable for insertion
into a
JTree. |
protected boolean |
hasBreakpoint(LineID line)
Check if there's a breakpoint on a particular line.
|
boolean |
isBusy()
Check whether the debugger is currently busy. i.e. running (not
suspended).
|
boolean |
isPaused()
Check whether the debugger is paused. i.e. it is currently suspended
at a breakpoint or step.
|
boolean |
isStarted()
Check whether a debugging session is running. i.e. the debugger is
connected to a debuggee VM, VMStartEvent has been received and main
class is loaded.
|
LineID |
javaToSketchLine(LineID javaLine)
Translate a line (index) from java space to sketch space.
|
protected boolean |
locationIsVisible(com.sun.jdi.Location l)
Check whether a location corresponds to a code line in the editor.
|
protected LineID |
locationToLineID(com.sun.jdi.Location l)
Translate a java source location to a sketch line id.
|
protected String |
locationToString(com.sun.jdi.Location loc)
Get a string describing a location.
|
protected LineID |
originalToRuntimeLine(LineID line)
Get the runtime-changed line id for an original sketch line.
|
protected void |
printLocalVariables(com.sun.jdi.ThreadReference t)
Print local variables on a suspended thread.
|
protected void |
printSourceLocation(com.sun.jdi.Location l)
Print source code snippet.
|
protected void |
printSourceLocation(com.sun.jdi.ThreadReference t)
Print source code snippet of current location in a suspended thread.
|
protected void |
printStackTrace(com.sun.jdi.ThreadReference t)
Print call stack trace of a thread.
|
protected void |
printThis(com.sun.jdi.ThreadReference t)
Print visible fields of current "this" object on a suspended thread.
|
protected void |
printThread(com.sun.jdi.ThreadReference t)
Print info about a thread.
|
void |
printThreads()
Print info about all current threads.
|
protected void |
printType(com.sun.jdi.ReferenceType rt)
Print info about a ReferenceType.
|
void |
removeClassLoadListener(ClassLoadListener listener)
Remove a class load listener.
|
protected void |
resumeOtherThreads(com.sun.jdi.ThreadReference t)
Resume all other threads except the one given as parameter.
|
protected LineID |
runtimeToOriginalLine(LineID line)
Get the original line id for a sketch line that was changed at runtime.
|
LineID |
sketchToJavaLine(LineID sketchLine)
Translate a line (index) from sketch space to java space.
|
void |
startDebug()
Start a debugging session.
|
protected void |
startTrackingLineChanges()
Start tracking all line changes (due to edits) in the current tab.
|
protected void |
step(int stepDepth)
Step through source code lines.
|
void |
stepInto()
Step into current statement.
|
void |
stepOut()
Step out of current statement.
|
protected void |
stepOutIntoViewOrContinue()
Step out if this results in a visible location, otherwise continue.
|
void |
stepOver()
Step over current statement.
|
void |
stopDebug()
End debugging session.
|
protected void |
stopTrackingLineChanges()
Stop tracking line changes in all tabs.
|
protected String |
thisName(com.sun.jdi.ThreadReference t)
Get the class name of the current this object in a suspended thread.
|
protected String |
threadStatusToString(int status)
Convert a status code returned by
ThreadReference.status()
to a human readable form. |
protected void |
updateVariableInspector(com.sun.jdi.ThreadReference t)
Update variable inspector window.
|
com.sun.jdi.VirtualMachine |
vm() |
void |
vmEvent(com.sun.jdi.event.EventSet es)
Callback for VM events.
|
protected JavaEditor editor
protected Runner runtime
protected boolean started
protected boolean paused
protected com.sun.jdi.ThreadReference currentThread
protected String mainClassName
protected com.sun.jdi.ReferenceType mainClass
protected Set<com.sun.jdi.ReferenceType> classes
protected List<ClassLoadListener> classLoadListeners
protected String srcPath
protected List<LineBreakpoint> breakpoints
protected com.sun.jdi.request.StepRequest requestedStep
protected Debugger.VMEventListener vmEventListener
public Debugger(JavaEditor editor)
public com.sun.jdi.VirtualMachine vm()
public JavaEditor getEditor()
public com.sun.jdi.ReferenceType getMainClass()
ReferenceType
or null if the debugger is not started.public Set<com.sun.jdi.ReferenceType> getClasses()
ReferenceTypes for the sketch.ReferenceTypes,
empty list if nothing found (e.g. not yet loaded)public void addClassLoadListener(ClassLoadListener listener)
listener - the ClassLoadListenerpublic void removeClassLoadListener(ClassLoadListener listener)
listener - ClassLoadListenerpublic void startDebug()
public void stopDebug()
public void continueDebug()
protected void step(int stepDepth)
stepDepth - the step depth (StepRequest.STEP_OVER,
StepRequest.STEP_INTO or StepRequest.STEP_OUT)public void stepOver()
public void stepInto()
public void stepOut()
protected boolean hasBreakpoint(LineID line)
line - the line idpublic void vmEvent(com.sun.jdi.event.EventSet es)
Debugger.VMEventReader)es - Incoming set of events from VMprotected boolean locationIsVisible(com.sun.jdi.Location l)
l - the locationprotected void stepOutIntoViewOrContinue()
public boolean isStarted()
public boolean isPaused()
isStarted())public boolean isBusy()
protected void printStackTrace(com.sun.jdi.ThreadReference t)
t - suspended thread to print stack trace ofprotected void resumeOtherThreads(com.sun.jdi.ThreadReference t)
t - the thread not to resumepublic void printThreads()
protected void printThread(com.sun.jdi.ThreadReference t)
t - the thread to print info aboutprotected String threadStatusToString(int status)
ThreadReference.status()
to a human readable form.status - ThreadReference.THREAD_STATUS_MONITOR,
ThreadReference.THREAD_STATUS_NOT_STARTED,
ThreadReference.THREAD_STATUS_RUNNING,
ThreadReference.THREAD_STATUS_SLEEPING,
ThreadReference.THREAD_STATUS_UNKNOWN,
ThreadReference.THREAD_STATUS_WAIT or
ThreadReference.THREAD_STATUS_ZOMBIEprotected void printLocalVariables(com.sun.jdi.ThreadReference t)
t - suspended threadprotected void updateVariableInspector(com.sun.jdi.ThreadReference t)
t - suspended thread to retrieve locals and thisprotected String thisName(com.sun.jdi.ThreadReference t)
t - a suspended threadprotected String currentLocation(com.sun.jdi.ThreadReference t)
t - a suspended threadprotected String locationToString(com.sun.jdi.Location loc)
loc - a locationprotected List<VariableNode> getLocals(com.sun.jdi.ThreadReference t, int depth)
JTree. Recursively resolves object references.t - the suspended thread to get locals fordepth - how deep to resolve nested object references. 0 will not
resolve nested objects.protected List<VariableNode> getThisFields(com.sun.jdi.ThreadReference t, int depth, boolean includeInherited)
JTree. Recursively resolves object references.t - the suspended thread to get locals fordepth - how deep to resolve nested object references. 0 will not
resolve nested objects.protected List<VariableNode> getFields(com.sun.jdi.Value value, int depth, int maxDepth, boolean includeInherited)
Value for insertion into a
JTree.value - must be an instance of ObjectReferencedepth - the current depthmaxDepth - the depth to stop at (inclusive)public List<VariableNode> getFields(com.sun.jdi.Value value, int maxDepth, boolean includeInherited)
Value for insertion into a
JTree.value - must be an instance of ObjectReferencemaxDepth - max recursion depth. 0 will give only direct childrenprotected List<VariableNode> getArrayFields(com.sun.jdi.ArrayReference array)
JTree.array - the array referenceprotected List<DefaultMutableTreeNode> getStackTrace(com.sun.jdi.ThreadReference t)
JTree.t - the suspended thread to retrieve the call stack fromDefaultMutableTreeNodesprotected void printThis(com.sun.jdi.ThreadReference t)
t - suspended threadprotected void printSourceLocation(com.sun.jdi.ThreadReference t)
t - suspended threadprotected void printSourceLocation(com.sun.jdi.Location l)
l - Location object to print source code forprotected String getSourceLine(String filePath, int lineNo, int radius)
filePath - lineNo - protected void printType(com.sun.jdi.ReferenceType rt)
rt - the reference type to print outprotected LineID locationToLineID(com.sun.jdi.Location l)
l - the location to translatepublic LineID javaToSketchLine(LineID javaLine)
javaLine - the java line idprotected LineID originalToRuntimeLine(LineID line)
line - the original line id (at compile time)protected LineID runtimeToOriginalLine(LineID line)
line - the (possibly) changed runtime linepublic LineID sketchToJavaLine(LineID sketchLine)
sketchLine - the sketch line idprotected void startTrackingLineChanges()
protected void stopTrackingLineChanges()
Copyright © 2001–2017 Processing Foundation. All rights reserved.