public final class DebuggerSession extends Object implements Closeable
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:
try (DebuggerSessionsession =Debugger.find(instrumentEnv). startSession(newSuspendedCallback() { public void onSuspend(SuspendedEventevent) { // step into the next event event.prepareStepInto(1); } })) {SourcesomeCode =Source.newBuilder("...", "...", "example").build(); // install line breakpoint session.install(Breakpoint.newBuilder(someCode).lineIs(3).build()); }
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the current debugging session and disposes all installed breakpoints.
|
List<Breakpoint> |
getBreakpoints()
Returns all breakpoints
installed
in this session, in the install order. |
Debugger |
getDebugger()
Returns the
debugger instance that this session is associated with. |
Map<String,? extends DebugValue> |
getExportedSymbols()
Returns a polyglot scope - symbols explicitly exported by languages.
|
DebugScope |
getTopScope(String languageId)
Returns a language top scope.
|
Breakpoint |
install(Breakpoint breakpoint)
Adds a new breakpoint to this session and makes it capable of suspending execution.
|
boolean |
isBreakpointsActive(Breakpoint.Kind breakpointKind)
Test whether breakpoints of the given kind are active in this session.
|
void |
resumeAll()
Resumes all suspended executions that have not yet been notified.
|
void |
setBreakpointsActive(Breakpoint.Kind breakpointKind,
boolean active)
Set whether breakpoints of the given kind are active in this session.
|
void |
setContextsListener(DebugContextsListener listener,
boolean includeActiveContexts)
Set a
listener to be notified about changes in contexts in
guest language application. |
void |
setSteppingFilter(SuspensionFilter steppingFilter)
Set a stepping suspension filter.
|
void |
setThreadsListener(DebugThreadsListener listener,
boolean includeInitializedThreads)
Set a
listener to be notified about changes in threads in guest
language application. |
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 DebugScope getTopScope(String languageId) throws DebugException
DebugStackFrame.getScope() have no relation to the suspended location.DebugException - when guest language code throws an exceptionpublic Map<String,? extends DebugValue> getExportedSymbols()
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()
installed
in this session, in the install order. The returned list contains a current snapshot of
breakpoints, those that were disposed, or
installed on Debugger are
not included.Debugger.getBreakpoints()public void setBreakpointsActive(Breakpoint.Kind breakpointKind, boolean active)
breakpointKind - the kind of breakpoints to activate/deactivateactive - true to make breakpoints active, false to make
breakpoints inactive.public boolean isBreakpointsActive(Breakpoint.Kind breakpointKind)
breakpointKind - the kind of breakpoints to testpublic 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 closedpublic void setContextsListener(DebugContextsListener listener, boolean includeActiveContexts)
listener to be notified about changes in contexts in
guest language application. One listener can be set at a time, call with null to
remove the current listener.listener - a listener to receive the context events, or null to reset itincludeActiveContexts - whether or not this listener should be notified for present
active contextspublic void setThreadsListener(DebugThreadsListener listener, boolean includeInitializedThreads)
listener to be notified about changes in threads in guest
language application. One listener can be set at a time, call with null to
remove the current listener.listener - a listener to receive the context eventsincludeInitializedThreads - whether or not this listener should be notified for present
initialized threads