changeset 8978:dbcf38c78dae

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
author sgehwolf
date Mon, 23 Jul 2018 18:08:46 +0200
parents 59bbf36a21f9
children bcccbecdde63
files agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java
diffstat 2 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java	Tue Oct 02 17:17:43 2018 +0200
+++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java	Mon Jul 23 18:08:46 2018 +0200
@@ -55,7 +55,15 @@
 
    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;
--- a/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java	Tue Oct 02 17:17:43 2018 +0200
+++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java	Mon Jul 23 18:08:46 2018 +0200
@@ -46,7 +46,15 @@
 
   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;