RFR: JDK-8253001: [JVMCI] Add API for getting stacktraces independently of current thread
Vladimir Kozlov
kvn at openjdk.java.net
Mon Sep 21 18:48:24 UTC 2020
On Thu, 17 Sep 2020 14:26:56 GMT, Doug Simon <dnsimon at openjdk.org> wrote:
>> The idea is to add a more powerful API for cases where the current iterateFrames API cannot be used.
>>
>> For example, a debugger needs access to the content of stack frames such as local variables or monitors. In cases where
>> threads execute in the runtime or in native code, it's not possible to obtain a thread suspension hook, for which
>> iterateFrames can be used on the suspended thread. The getStackFrames method enables an immediate stack frames lookup
>> regardless of the status of the underlying thread. Another use case would be for lookup of backtraces for non-current
>> threads. The implementation is done by means of a VM operation that collects vframe data for each thread during a
>> safepoint, whereafter required object reallocation/reassign fields is performed based on the collected snapshot.
>
> @vnkozlov @veresov @dean-long it would be great to get some reviews of this soon. To assist, let me try provide a
> little more context on the area of JVMCI which is motivated by
> [Truffle](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/package-summary.html). The
> [`StackIntrospection.iterateFrames()`](https://github.com/openjdk/jdk/blob/6bab0f539fba8fb441697846347597b4a0ade428/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/stack/StackIntrospection.java#L45)
> API exists for Truffle to support walking guest language frames. In Truffle, all values, including primitives, are
> boxed which explains why there is no `InspectedFrame.setLocal(int index, Object value)` method. All Truffle guest
> language frame locals are accessed/updated by reading/updating the boxed value returned by `InspectedFrame.getLocal()`.
> With this existing API, a thread can only inspect its own stack frames. As the description of this PR states, it
> extends `StackIntrospection.iterateFrames()` with `StackIntrospection.getStackFrames()` so that a thread can inspect
> the frames of other threads. It is somewhat analogous to `java.lang.Thread.getAllStackTraces()` except it allows the
> local variables of the frames to be accessed as well.
I would like to hear answer to @dholmes-ora question in JBS:
"Do we really need yet another stack dumping interface in the VM? Why isn't a debugger using JVM TI?"
-------------
PR: https://git.openjdk.java.net/jdk/pull/110
More information about the hotspot-compiler-dev
mailing list