Class DebugStackFrame
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.
- Since:
- 0.17
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Evaluates the given code in the state of the current execution and in the same guest language as the current language is defined in.Provides a host frame.Returns public information about the language of this frame.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.getRawFrame
(Class<? extends TruffleLanguage<?>> languageClass, FrameInstance.FrameAccess access) Returns the underlying frame for this debug stack frame ornull
if the requesting language class does not match the root node guest language.getRawNode
(Class<? extends TruffleLanguage<?>> languageClass) Returns the current node for this stack frame, ornull
if the requesting language class does not match the root node guest language.getScope()
Get the current inner-most scope.Returns the source section of the location where the debugging session was suspended.int
hashCode()
boolean
isHost()
Returnstrue
if this frame is a host frame.boolean
Returns whether this stack frame is a language implementation artifact that should be hidden during normal guest language debugging, for example in stack traces.
-
Method Details
-
isInternal
public 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.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.
- Since:
- 0.17
-
isHost
public boolean isHost()Returnstrue
if this frame is a host frame. Host frames providestack trace element
, have noscope
, nosource section
and can notevaluate
code.Host frames are provided only when
host info
is set totrue
.- Since:
- 20.3
- See Also:
-
getHostTraceElement
Provides a host frame. Returns the host stack trace element if and only if this ishost
frame.- Returns:
- the host stack trace element, or
null
when not a host frame. - Since:
- 20.3
- See Also:
-
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. If the language does not provide such a description thennull
is returned.This method is thread-safe.
- Throws:
DebugException
- Since:
- 0.17
-
getSourceSection
Returns the source section of the location where the debugging session was suspended. The source section isnull
if the source location is not available.This method is thread-safe.
- Since:
- 0.17
-
getLanguage
Returns public information about the language of this frame.- Returns:
- the language info, or
null
when no language is associated with this frame. - Since:
- 19.0
-
getScope
Get the current inner-most scope. The scope remain valid as long as the current stack frame remains valid.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.- Returns:
- the scope, or
null
when no language is associated with this frame location, or when no local scope exists. - Throws:
DebugException
- when guest language code throws an exception- Since:
- 0.26
-
getRawNode
Returns the current node for this stack frame, ornull
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.- Parameters:
languageClass
- the Truffle language class for a given guest language- Returns:
- the node associated with the frame
- Since:
- 20.1
-
getRawFrame
public Frame getRawFrame(Class<? extends TruffleLanguage<?>> languageClass, FrameInstance.FrameAccess access) Returns the underlying frame for this debug stack frame ornull
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.- Parameters:
languageClass
- the Truffle language class for a given guest languageaccess
- the frame access mode- Returns:
- the frame
- Since:
- 20.1
-
eval
Evaluates the given code in the state of the current execution and in the same guest language as the current language is defined in. Returns a heap value that remains valid even if this stack frame becomes invalid.This method is not thread-safe and will throw an
IllegalStateException
if called on another thread than it was created with.- Parameters:
code
- the code to evaluate- Returns:
- the return value of the expression
- Throws:
DebugException
- when guest language code throws an exceptionIllegalStateException
- if called on another thread than this frame was created with, or iflanguage
of this frame is notinteractive
.- Since:
- 0.17
-
equals
-
hashCode
public int hashCode()
-