package bluej.debugger;
import java.io.File;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import bluej.classmgr.BPClassLoader;
import bluej.debugger.jdi.JdiDebugger;
import bluej.debugger.jdi.TestResultsWithRunTime;
import bluej.utility.javafx.FXPlatformSupplier;
import threadchecker.OnThread;
import threadchecker.Tag;
| A class defining the debugger primitives needed by BlueJ. May be supported by different
| implementations, locally or remotely.
|
| <p>Debugger has a listener interface to allow listening for certain events. Events reported to
| the listener are guaranteed to be serialised, that is, a callback will not be entered while
| the previous callback is still executing.
|
| <p>Part of the listener interface is notification of debugger state changes. There possible
| states are UNKNOWN, NOTREADY, IDLE, RUNNING, SUSPENDED and LAUNCH_FAILED. Only certain
| transitions are possible:
|
| <ul>
| <li>UNKNOWN to NOTREADY: when the debugger is first launched
| <li>NOTREADY to IDLE: when the debugger finishes launching or restarting
| <li>IDLE to RUNNING: when the debugger begins execution of user code
| <li>IDLE to NOTREADY: when the virtual machine restarts (possibly for external reasons)
| <li>RUNNING to IDLE: when user code finishes or is otherwise terminated
| <li>RUNNING to SUSPENDED: when a breakpoint is hit etc.
| <li>SUSPENDED to RUNNING: when execution is continued after a breakpoint etc.
| </ul>
|
| Transitions that do not conform to the list are modified by inserting appropriate transitions.
| For instance a transition from RUNNING to NOTREADY is represented as a transition first to
| IDLE and then to NOTREADY.
|
| @author Michael Cahill
| @author Michael Kolling
| @author Andrew Patterson
|
public abstract class Debugger
{
public static final String PERSIST_BREAKPOINT_PROPERTY = "VMReference.PERSIST_BREAKPOINT";
public static final int NORMAL_EXIT = 0;
public static final int EXCEPTION = 2;
public static final int TERMINATED = 3;
| Virtual machine states
|
| The unknown state can only be the previous state, and only in the first state change
|
public static final int UNKNOWN = 0;
| The debugger is not yet ready to execute code etc
|
public static final int NOTREADY = 1;
| The debugger is idle: ready to execute
|
public static final int IDLE = 2;
| The debugger is currently running user code
|
public static final int RUNNING = 3;
| The debugger is suspended, i.e. running user code but stopped at a breakpoint/step
|
public static final int SUSPENDED = 4;
| The debugger failed to start.
|
public static final int LAUNCH_FAILED = 5;
| Create an instance of a debugger.
| The constructor for the debugger should not be
| a long process. Actual startup for the debug
| VM should go in launch().
|
| @return a Debugger instance
|
public static Debugger getDebuggerImpl(File startingDirectory, DebuggerTerminal terminal, DebuggerThreadListener debuggerThreadListener)
{
return new JdiDebugger(startingDirectory, terminal, debuggerThreadListener);
}
| Set the user libraries to be added to the system classpath when the VM is launched
| or restarted.
|
public abstract void setUserLibraries(URL[] libraries);
| Launch a VM for running user code, which will be controlled by this debugger instance.
| This should be called only once.
|
| <p>This can be a lengthy process so this should be executed in a sub thread.
|
@OnThread(Tag.Any)
public abstract void launch();
| Terminate the debug VM, stop all user processes etc. Optionally restart afterwards.
|
public abstract void close(boolean restart);
| Add a listener for DebuggerEvents
|
| @param l the DebuggerListener to add
| @return the machine state at the time the listener was added
| (any changes from this state will have been signalled to the listener)
|
public abstract int addDebuggerListener(DebuggerListener l);
| Remove a listener for DebuggerEvents.
|
| @param l the DebuggerListener to remove
|
@OnThread(Tag.Any)
public abstract void removeDebuggerListener(DebuggerListener l);
| Create a class loader in the debugger.
|
public abstract void newClassLoader(BPClassLoader bpClassLoader);
| Remove all breakpoints in the given class.
|
@OnThread(Tag.Any)
public abstract void removeBreakpointsForClass(String className);
| Add a debugger object into the project scope.
|
| @param scopeId the scope identifier
| @param newInstanceName the name of the object
| @param dob the object itself
| @return true if the object could be added with this name,
| false if there was a name clash.
|
public abstract boolean addObject(String scopeId, String newInstanceName, DebuggerObject dob);
| Remove a debugger object from the project scope.
|
public abstract void removeObject(String scopeId, String instanceName);
| Return the debugger objects that exist in the
| debugger.
|
| @return a Map of (String name, DebuggerObject obj) entries
|
public abstract Map getObjects();
| Guess a suitable name for an object about to be put on the object bench.
|
| @param startingName a fully qualified class name (will be stripped of
| qualifying part) or a field name that will be used
| as the basis for the new name.
| @return a String suitable as a name for an object on the object bench.
|
public abstract String guessNewName(String className);
| Guess a suitable name for an object about to be put on the object bench.
|
| @param obj the object that will be put on the object bench
| @return a String suitable as a name for an object on the object bench.
|
public abstract String guessNewName(DebuggerObject obj);
| Return the machine status; one of the "machine state" constants:
|* (IDLE, RUNNING, SUSPENDED, NOTREADY).
*/
public abstract int getStatus();
/**
* Run the setUp() method of a test class and return the created
* objects.
*
| @param className the fully qualified name of the class
| @return a Map of (String name, DebuggerObject obj) entries
|
@OnThread(Tag.Any)
public abstract FXPlatformSupplier
top,
use,
map,
abstract class Debugger
. getDebuggerImpl
. setUserLibraries
. launch
. close
. addDebuggerListener
. removeDebuggerListener
. newClassLoader
. removeBreakpointsForClass
. addObject
. removeObject
. getObjects
. guessNewName
. guessNewName
. runTestSetUp
. runTestMethod
. disposeWindows
. instantiateClass
. instantiateClass
. getClass
. launchFXApp
. getMirror
. toggleBreakpoint
. toggleBreakpoint
. toggleBreakpoint
. setRunOnThread
179 neLoCode
+ 123 LoComm