From 5e7aa551ea3b300bd49a20221acc9721f2d991d1 Mon Sep 17 00:00:00 2001 From: sgehwolf Date: Mon, 23 Jul 2018 18:08:46 +0200 Subject: [PATCH] 8208091: SA: jhsdb jstack --mixed throws UnmappedAddressException on i686 Summary: Be sure to use the same register index in native and Java code. Reviewed-by: sballal, cjplummer, tbell --- .../jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java | 10 +++++++++- .../hotspot/debugger/windows/x86/WindowsX86CFrame.java | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java b/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java index 53a2e26a8..95fa38d72 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java @@ -55,7 +55,15 @@ final public class LinuxX86CFrame extends BasicCFrame { public CFrame sender(ThreadProxy thread) { X86ThreadContext context = (X86ThreadContext) thread.getContext(); - Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP); + /* + * Native code fills in the stack pointer register value using index + * X86ThreadContext.SP. + * See file LinuxDebuggerLocal.c macro REG_INDEX(reg). + * + * Be sure to use SP, or UESP which is aliased to SP in Java code, + * for the frame pointer validity check. + */ + Address esp = context.getRegisterAsAddress(X86ThreadContext.SP); if ( (ebp == null) || ebp.lessThan(esp) ) { return null; diff --git a/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java b/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java index dbc8b71f3..1d5e015e8 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java @@ -46,7 +46,15 @@ public class WindowsX86CFrame extends BasicCFrame { public CFrame sender(ThreadProxy thread) { X86ThreadContext context = (X86ThreadContext) thread.getContext(); - Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP); + /* + * Native code fills in the stack pointer register value using index + * X86ThreadContext.SP. + * See file sawindbg.cpp macro REG_INDEX(x). + * + * Be sure to use SP, or UESP which is aliased to SP in Java code, + * for the frame pointer validity check. + */ + Address esp = context.getRegisterAsAddress(X86ThreadContext.SP); if ( (ebp == null) || ebp.lessThan(esp) ) { return null; -- GitLab