public final class SuspendedEvent extends Object
Debugger
clients to the state of a guest language execution thread that has
been suspended, for example by a Breakpoint
or stepping action.
DebuggerSession
instruments
guest language code in order to
implement breakpoints, stepping actions, or other debugging actions on
behalf of the session's debugger client.SuspendedEvent
to the debugger client (synchronously) in a
callback on the guest language execution
thread.IllegalStateException
. Please see the javadoc of the individual method for details.IllegalStateException
after the suspended thread resumes
guest language execution.
SuspendedEvent.getStackFrames()
describes the suspended thread's location in guest language
code. This information becomes unusable beyond the lifetime of the event and must not be stored.
SuspendedEvent.getReturnValue()
describes a local result when the thread is suspended just
after
the code source section.Clients use the following methods to request the debugging action(s) that will take effect when the event's thread resumes guest language execution. All prepare requests accumulate until resumed.
SuspendedEvent.prepareStepInto(int)
SuspendedEvent.prepareStepOut(int)
SuspendedEvent.prepareStepOver(int)
SuspendedEvent.prepareKill()
SuspendedEvent.prepareContinue()
continue
is assumed.
Modifier and Type | Method and Description |
---|---|
List<List<DebugStackTraceElement>> |
getAsynchronousStacks()
Get a list of asynchronous stack traces that led to scheduling of the current execution.
|
Throwable |
getBreakpointConditionException(Breakpoint breakpoint)
Returns the cause of failure, if any, during evaluation of a breakpoint's
condition.
|
List<Breakpoint> |
getBreakpoints()
Returns the
breakpoints that individually would cause the "hit" where
execution is suspended. |
DebugException |
getException()
Returns the debugger representation of a guest language exception that caused this suspended
event (via an exception breakpoint, for instance).
|
DebugValue[] |
getInputValues()
Returns the input values of the current source element gathered from return values of it's
executed children.
|
DebugValue |
getReturnValue()
Returns the return value of the currently executed source location.
|
DebuggerSession |
getSession()
Returns the debugger session this suspended event was created for.
|
SourceSection |
getSourceSection()
Returns the guest language source section of the AST node before/after the execution is
suspended.
|
Iterable<DebugStackFrame> |
getStackFrames()
Returns a list of guest language stack frame objects that indicate the current guest language
location.
|
SuspendAnchor |
getSuspendAnchor()
Returns where, within the guest language
source section , the
suspended position is. |
DebugStackFrame |
getTopStackFrame()
Returns the topmost stack frame returned by
SuspendedEvent.getStackFrames() . |
boolean |
hasSourceElement(SourceElement sourceElement)
Returns
true if the underlying guest language source location is denoted as the
source element. |
boolean |
isLanguageContextInitialized()
Test if the language context of the source of the event is initialized.
|
void |
prepareContinue()
Prepare to execute in Continue mode when guest language program execution resumes.
|
void |
prepareKill()
Prepare to terminate the suspended execution represented by this event.
|
SuspendedEvent |
prepareStepInto(int stepCount)
Prepare to execute in step into mode when guest language program execution
resumes.
|
SuspendedEvent |
prepareStepInto(StepConfig stepConfig)
Prepare to execute in step into mode when guest language program execution
resumes.
|
SuspendedEvent |
prepareStepOut(int stepCount)
Prepare to execute in step out mode when guest language program execution
resumes.
|
SuspendedEvent |
prepareStepOut(StepConfig stepConfig)
Prepare to execute in step out mode when guest language program execution
resumes.
|
SuspendedEvent |
prepareStepOver(int stepCount)
Prepare to execute in step over mode when guest language program execution
resumes.
|
SuspendedEvent |
prepareStepOver(StepConfig stepConfig)
Prepare to execute in step over mode when guest language program execution
resumes.
|
void |
prepareUnwindFrame(DebugStackFrame frame)
Prepare to unwind a frame.
|
void |
prepareUnwindFrame(DebugStackFrame frame,
DebugValue immediateReturnValue)
Prepare to unwind a frame.
|
void |
setReturnValue(DebugValue newValue)
Change the return value.
|
String |
toString() |
public DebuggerSession getSession()
This method is thread-safe.
public SourceSection getSourceSection()
null
if no source section information is available.
This method is thread-safe.
public SuspendAnchor getSuspendAnchor()
source section
, the
suspended position is.public boolean hasSourceElement(SourceElement sourceElement)
true
if the underlying guest language source location is denoted as the
source element.sourceElement
- the source element to check, must not be null
.public boolean isLanguageContextInitialized()
public DebugValue[] getInputValues()
AFTER
suspend anchor
. There can be null
values in the returned array for children we
did not intercept return values from.null
when no input is available.public DebugValue getReturnValue()
null
if the execution is suspended before
a guest language location.
The returned value is null
if an exception occurred during execution of the
instrumented source element, the exception is provided by SuspendedEvent.getException()
.
This method is not thread-safe and will throw an IllegalStateException
if called on
another thread than it was created with.
public void setReturnValue(DebugValue newValue)
return value
at the
current location, this method modifies the return value to a new one.newValue
- the new return value, can not be null
IllegalStateException
- when SuspendedEvent.getReturnValue()
returns null
public DebugException getException()
null
when no
exception occurred.public Throwable getBreakpointConditionException(Breakpoint breakpoint)
This method is thread-safe.
breakpoint
- a breakpoint associated with this eventpublic List<Breakpoint> getBreakpoints()
breakpoints
that individually would cause the "hit" where
execution is suspended. If Debugger-associated
breakpoint was hit, it is not possible to change the state of returned
breakpoint.
This method is thread-safe.
public DebugStackFrame getTopStackFrame()
SuspendedEvent.getStackFrames()
.
This method is not thread-safe and will throw an IllegalStateException
if called on
another thread than it was created with.
SuspendedEvent.getStackFrames()
public Iterable<DebugStackFrame> getStackFrames()
suspend
and should not be stored permanently.
This method is not thread-safe and will throw an IllegalStateException
if called on
another thread than it was created with.
public List<List<DebugStackTraceElement>> getAsynchronousStacks()
Languages might not provide asynchronous stack traces by default for performance reasons.
Call DebuggerSession.setAsynchronousStackDepth(int)
to request asynchronous stacks.
Languages may provide asynchronous stacks if it's of no performance penalty, or if requested
by other options.
DebuggerSession.setAsynchronousStackDepth(int)
public void prepareContinue()
This method is thread-safe and the prepared Continue mode is appended to any other previously prepared modes. No further modes can be prepared after continue.
IllegalStateException
- when continue
or
kill
is prepared already.public SuspendedEvent prepareStepInto(int stepCount)
SuspendedEvent.prepareStepInto(StepConfig)
for details, calling
this is identical to
prepareStepInto
.(StepConfig
.newBuilder
().count
(stepCount).build
())
.stepCount
- the number of times to perform StepInto before haltingIllegalArgumentException
- if stepCount <= 0
IllegalStateException
- when continue
or
kill
is prepared already.public SuspendedEvent prepareStepOut(int stepCount)
SuspendedEvent.prepareStepOut(StepConfig)
for details, calling this
is identical to
prepareStepOut
.(StepConfig
.newBuilder
().count
(stepCount).build
())
.stepCount
- the number of times to perform StepOver before haltingIllegalArgumentException
- if stepCount <= 0
IllegalStateException
- when continue
or
kill
is prepared already.public SuspendedEvent prepareStepOver(int stepCount)
SuspendedEvent.prepareStepOver(StepConfig)
for details, calling
this is identical to
prepareStepOver
.(StepConfig
.newBuilder
().count
(stepCount).build
())
.stepCount
- the number of times to perform step over before haltingIllegalArgumentException
- if stepCount <= 0
IllegalStateException
- when continue
or
kill
is prepared already.public SuspendedEvent prepareStepInto(StepConfig stepConfig)
source
elements
and repeats that process step count
times.
See StepConfig
for the details about the stepping behavior.
This mode persists until the thread resumes and then suspends, at which time the mode reverts to Continue, or the thread dies.
A breakpoint set at a location where execution would suspend is treated specially as a single event, to avoid multiple suspensions at a single location.
This method is thread-safe and the prepared StepInto mode is appended to any other previously prepared modes.
stepConfig
- the step configurationIllegalStateException
- when continue
or
kill
is prepared already, or when the current debugger
session has no source elements enabled for stepping.IllegalArgumentException
- when the StepConfig
contains source elements not
enabled for stepping in the current debugger session.public SuspendedEvent prepareStepOut(StepConfig stepConfig)
source elements
and repeats that process step count
times. See StepConfig
for the details about the stepping behavior.
This mode persists until the thread resumes and then suspends, at which time the mode reverts to Continue, or the thread dies.
A breakpoint set at a location where execution would suspend is treated specially as a single event, to avoid multiple suspensions at a single location.
This method is thread-safe and the prepared StepInto mode is appended to any other previously prepared modes.
stepConfig
- the step configurationIllegalStateException
- when continue
or
kill
is prepared already, or when the current debugger
session has no source elements enabled for stepping.IllegalArgumentException
- when the StepConfig
contains source elements not
enabled for stepping in the current debugger session.public SuspendedEvent prepareStepOver(StepConfig stepConfig)
source
elements
, ignoring any nested ones, and repeats that process
step count
times. See StepConfig
for the
details about the stepping behavior.
This mode persists until the thread resumes and then suspends, at which time the mode reverts to Continue, or the thread dies.
A breakpoint set at a location where execution would suspend is treated specially as a single event, to avoid multiple suspensions at a single location.
This method is thread-safe and the prepared StepInto mode is appended to any other previously prepared modes.
stepConfig
- the step configurationIllegalStateException
- when continue
or
kill
is prepared already, or when the current debugger
session has no source elements enabled for stepping.IllegalArgumentException
- when the StepConfig
contains source elements not
enabled for stepping in the current debugger session.public void prepareUnwindFrame(DebugStackFrame frame) throws IllegalArgumentException
execution stack of this event
.frame
- the frame to unwindIllegalArgumentException
- when the frame is not on the execution stack of this eventpublic void prepareUnwindFrame(DebugStackFrame frame, DebugValue immediateReturnValue) throws IllegalArgumentException
immediateReturnValue
. If the
return value is null
, the unwound frame will instead be reentered upon thread
resumption. The frame needs to be on the execution stack of this
event
.frame
- the frame to unwindimmediateReturnValue
- the value to returnIllegalArgumentException
- when the frame is not on the execution stack of this eventpublic void prepareKill()
This method is thread-safe and the prepared termination is appended to any other previously prepared modes. No further modes can be prepared after kill.
IllegalStateException
- when continue
or
kill
is prepared already.