public final class DebuggerSession extends Object implements Closeable
PolyglotEngine debugging services.
PolyglotEngine debugging client
requests a new session from the engine's Debugger.SuspendedEvent via synchronous callback on the execution
thread.Session clients can manage guest language execution in several ways:
Breakpoint.A session may suspend a guest language execution thread in response to more than one request from its client. For example:
There can be multiple sessions associated with a single engine, which are independent of one another in the following ways:
SuspendedEvent instance.Usage example:
PolyglotEngineengine =PolyglotEngine.newBuilder().build(); try (DebuggerSessionsession =Debugger.find(engine). startSession(newSuspendedCallback() { public void onSuspend(SuspendedEventevent) { // step into the next event event.prepareStepInto(1); } })) {SourcesomeCode =Source.newBuilder("..."). mimeType("..."). name("example").build(); // install line breakpoint session.install(Breakpoint.newBuilder(someCode).lineIs(3).build()); // should print suspended at for each debugger step. engine.eval(someCode); }
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the current debugging session and disposes all installed breakpoints.
|
List<Breakpoint> |
getBreakpoints()
Returns all breakpoints in the order they were installed.
|
Debugger |
getDebugger()
Returns the
debugger instance that this session is associated with. |
Breakpoint |
install(Breakpoint breakpoint)
Adds a new breakpoint to this session and makes it capable of suspending execution.
|
boolean |
isBreakpointsActive()
Test whether breakpoints are active in this session.
|
void |
resumeAll()
Resumes all suspended executions that have not yet been notified.
|
void |
setBreakpointsActive(boolean active)
Set whether breakpoints are active in this session.
|
void |
setSteppingFilter(SuspensionFilter steppingFilter)
Set a stepping suspension filter.
|
void |
suspendNextExecution()
Suspends the next execution on the first thread that is encountered.
|
String |
toString() |
public Debugger getDebugger()
debugger instance that this session is associated with. Can be
used also after the session has already been closed.public void setSteppingFilter(SuspensionFilter steppingFilter)
public void suspendNextExecution()
DebuggerSession.suspendNextExecution() is
called again. If multiple threads are executing at the same time then there are no guarantees
on which thread is going to be suspended. Will throw an IllegalStateException if the
session is already closed.public void resumeAll()
public void close()
close in interface Closeableclose in interface AutoCloseablepublic List<Breakpoint> getBreakpoints()
Disposed breakpoints are automatically removed from this list.public void setBreakpointsActive(boolean active)
active - true to make all breakpoints active, false to make
all breakpoints inactive.public boolean isBreakpointsActive()
public Breakpoint install(Breakpoint breakpoint)
The breakpoint suspends execution by making a callback to this
session, together with an event description that includes
which breakpoint(s) were hit.
breakpoint - a new breakpointIllegalStateException - if the session has been closed