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 53a2e26a84b05dc48763b62d000f201185a052be..95fa38d72a4ac995de013d828e62e9448270556a 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 dbc8b71f35c80ec6da35612167e80f0ef30dc326..1d5e015e8888657ac182dca380840b3e9e3ad155 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;