On Wed, 14 Jan 2026 06:06:28 GMT, Yasumasa Suenaga <[email protected]> wrote:

>> When we run `jhsdb jstack --mixed` on Windows, we can see top of call frames 
>> only as following:
>> 
>> 
>> ----------------- 4 -----------------
>> "main" #3 prio=5 tid=0x0000021ee0357e90 nid=22356 waiting on condition 
>> [0x0000004ae7eff000]
>>    java.lang.Thread.State: TIMED_WAITING (sleeping)
>>    JavaThread state: _thread_blocked
>> 0x00007ffca3c41c44 ntdll!NtWaitForSingleObject + 0x14
>> ----------------- 5 -----------------
>> 
>> 
>> This is long standing bugs since JDK 9 at least (maybe this includes older 
>> JDK releases).
>> We cannot depend on base pointer to unwind call frames, but SA do that.
>> 
>> This PR use 
>> [GetStackTrace](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/dbgeng/nf-dbgeng-idebugcontrol-getstacktrace)
>>  to find caller frame, then native call frames would be unwinded.
>> 
>> However it has still problems for JIT'ed frames because it does not have a 
>> hint for unwinder like 
>> [RtlAddFunctionTable](https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-rtladdfunctiontable).
>>  But it would affect entire of JIT compilers, so I've limited the change to 
>> SA.
>> 
>> This change passed serviceability/sa tests on Windows 11.
>
> Yasumasa Suenaga has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Update TestJhsdbJstackMixed.java

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java
 line 88:

> 86:                                         .filter(jt -> 
> thread.equals(jt.getThreadProxy()))
> 87:                                         .findFirst()
> 88:                                         .orElse(null);

I wonder if this code should be moved into its own API. Call it something like 
mapThreadProxyToJavaThread(), or maybe getJavaThreadForThreadProxy(). It would 
make the code more readable.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29019#discussion_r2715062051

Reply via email to