public final class DebugStackFrame extends Object
name
, the current source location
and
scopes
containing local variables and arguments. Furthermore it allows to
evaluate
guest language expressions in the lexical context of a particular
frame.
Debug stack frames are only valid as long as suspended events
are valid.
Suspended events are valid as long while the originating SuspendedCallback
is still
executing. All methods of the frame throw IllegalStateException
if they become invalid.
Depending on the method, clients may access the stack frame only on the execution thread where
the suspended event of the stack frame was created and the notification was received. For some
methods, access from other threads may throw IllegalStateException
. Please see the
javadoc of the individual method for details.
SuspendedEvent.getStackFrames()
,
SuspendedEvent.getTopStackFrame()
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
DebugValue |
eval(String code)
Evaluates the given code in the state of the current execution and in the same guest language
as the current language is defined in.
|
StackTraceElement |
getHostTraceElement()
Provides a host frame.
|
LanguageInfo |
getLanguage()
Returns public information about the language of this frame.
|
String |
getName()
A description of the AST (expected to be a method or procedure name in most languages) that
identifies the AST for the benefit of guest language programmers using tools; it might
appear, for example in the context of a stack dump or trace and is not expected to be called
often.
|
Frame |
getRawFrame(Class<? extends TruffleLanguage<?>> languageClass,
FrameInstance.FrameAccess access)
Returns the underlying frame for this debug stack frame or
null if the
requesting language class does not match the root node guest language. |
Node |
getRawNode(Class<? extends TruffleLanguage<?>> languageClass)
Returns the current node for this stack frame, or
null if the requesting
language class does not match the root node guest language. |
DebugScope |
getScope()
Get the current inner-most scope.
|
SourceSection |
getSourceSection()
Returns the source section of the location where the debugging session was suspended.
|
int |
hashCode() |
boolean |
isHost()
Returns
true if this frame is a host frame. |
boolean |
isInternal()
Returns whether this stack frame is a language implementation artifact that should be hidden
during normal guest language debugging, for example in stack traces.
|
public boolean isInternal()
Language implementations sometimes create method calls internally that do not correspond to anything explicitly written by a programmer, for example when the body of a looping construct is implemented as callable block. Language implementors mark these methods as internal.
Clients of the debugging API should assume that displaying internal frames is unlikely to help programmers debug guest language programs and might possibly create confusion. However, clients may choose to display all frames, for example in a special mode to support development of programming language implementations.
The decision to mark a method as internal is language-specific, reflects judgments about tool usability, and is subject to change.
This method is thread-safe.
public boolean isHost()
true
if this frame is a host frame. Host frames provide
stack trace element
, have no scope
, no
source section
and can not evaluate
code.
Host frames are provided only when host info
is set to true
.
DebuggerSession.setShowHostStackFrames(boolean)
public StackTraceElement getHostTraceElement()
host
frame.null
when not a host frame.DebugStackFrame.isHost()
public String getName() throws DebugException
null
is
returned.
This method is thread-safe.
DebugException
public SourceSection getSourceSection()
null
if the source location is not available.
This method is thread-safe.
public LanguageInfo getLanguage()
null
when no language is associated with this
frame.public DebugScope getScope() throws DebugException
Use DebuggerSession.getTopScope(java.lang.String)
to get scopes with global validity.
This method is not thread-safe and will throw an IllegalStateException
if called on
another thread than it was created with.
null
when no language is associated with this frame
location, or when no local scope exists.DebugException
- when guest language code throws an exceptionpublic Node getRawNode(Class<? extends TruffleLanguage<?>> languageClass)
null
if the requesting
language class does not match the root node guest language.
This method is permitted only if the guest language class is available. This is the case if
you want to utilize the Debugger API directly from within a guest language, or if you are an
instrument bound/dependent on a specific language.languageClass
- the Truffle language class for a given guest languagepublic Frame getRawFrame(Class<? extends TruffleLanguage<?>> languageClass, FrameInstance.FrameAccess access)
null
if the
requesting language class does not match the root node guest language.
This method is permitted only if the guest language class is available. This is the case if
you want to utilize the Debugger API directly from within a guest language, or if you are an
instrument bound/dependent on a specific language.languageClass
- the Truffle language class for a given guest languageaccess
- the frame access modepublic DebugValue eval(String code) throws DebugException
This method is not thread-safe and will throw an IllegalStateException
if called on
another thread than it was created with.
code
- the code to evaluateDebugException
- when guest language code throws an exceptionIllegalStateException
- if called on another thread than this frame was created with,
or if language
of this frame is not
interactive
.