diff --git a/src/hotspot/share/utilities/nativeStackPrinter.cpp b/src/hotspot/share/utilities/nativeStackPrinter.cpp index b243791c933..17d72565f2f 100644 --- a/src/hotspot/share/utilities/nativeStackPrinter.cpp +++ b/src/hotspot/share/utilities/nativeStackPrinter.cpp @@ -51,6 +51,7 @@ void NativeStackPrinter::print_stack_from_frame(outputStream* st, frame fr, int count = 0; while (count++ < limit) { fr.print_on_error(st, buf, buf_size); + st->print(" fp=%p", fr.fp()); if (fr.pc()) { // print source file and line, if available char filename[128]; int line_no; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java index 9fa0fc20e99..a1677ec8f88 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java @@ -29,6 +29,7 @@ import sun.jvm.hotspot.debugger.linux.*; import sun.jvm.hotspot.debugger.cdbg.*; import sun.jvm.hotspot.debugger.cdbg.basic.*; +import sun.jvm.hotspot.runtime.*; public final class LinuxAMD64CFrame extends BasicCFrame { @@ -107,7 +108,7 @@ private boolean isValidFrame(Address nextCFA, boolean isNative) { (!isNative || (isNative && nextCFA.greaterThan(cfa))); } - private Address getNextCFA(DwarfParser nextDwarf, ThreadContext context, Address senderFP) { + private Address getNextCFA(DwarfParser nextDwarf, ThreadContext context, Address senderFP, Address senderPC) { Address nextCFA; boolean isNative = false; @@ -115,13 +116,17 @@ private Address getNextCFA(DwarfParser nextDwarf, ThreadContext context, Address senderFP = cfa.getAddressAt(0); // RBP by default } - if (nextDwarf == null) { // Next frame is Java + if (VM.getVM().getCodeCache().contains(senderPC)) { // Next frame is Java nextCFA = (dwarf == null) ? senderFP // Current frame is Java : cfa.getAddressAt(dwarf.getBasePointerOffsetFromCFA()); // Current frame is Native } else { // Next frame is Native - if (dwarf == null) { // Current frame is Java + if (VM.getVM().getCodeCache().contains(pc())) { // Current frame is Java nextCFA = senderFP.addOffsetTo(-nextDwarf.getBasePointerOffsetFromCFA()); } else { // Current frame is Native + if (nextDwarf == null) { // maybe runtime entrypoint (_start()) + throw new DebuggerException("nextDwarf is null even though native call"); + } + isNative = true; int nextCFAReg = nextDwarf.getCFARegister(); if (nextCFAReg == AMD64ThreadContext.RBP) { @@ -187,9 +192,12 @@ public CFrame sender(ThreadProxy th, Address fp, Address pc) { } } - Address nextCFA = getNextCFA(nextDwarf, context, fp); - return nextCFA == null ? null - : new LinuxAMD64CFrame(dbg, nextCFA, nextPC, nextDwarf, false, fallback); + try { + Address nextCFA = getNextCFA(nextDwarf, context, fp, nextPC); + return new LinuxAMD64CFrame(dbg, nextCFA, nextPC, nextDwarf, false, fallback); + } catch (DebuggerException _) { + return null; + } } private DwarfParser createDwarfParser(Address pc) throws DebuggerException { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java index 2d972d3df17..ce526cf0de7 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java @@ -272,9 +272,7 @@ public Frame sender(RegisterMap regMap, CodeBlob cb) { if (cb != null) { if (cb.isUpcallStub()) { return senderForUpcallStub(map, (UpcallStub)cb); - } else if (cb.isContinuationStub()) { - return senderForContinuationStub(map, cb); - } else { + } else if (cb.getFrameSize() > 0) { return senderForCompiledFrame(map, cb); } } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java index 9865fbbe0f2..17c1dd7f457 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java @@ -248,9 +248,6 @@ private void printUnknown(PrintStream out) { private static record JavaNameInfo(String[] names, Address senderFP, Address senderPC) {}; private JavaNameInfo getJavaNames(ThreadProxy th, Address fp) { - if (fp == null) { - return null; - } JavaVFrame[] jvframes = jframeCache.get(th); if (jvframes == null) return null; // not a java thread @@ -259,7 +256,8 @@ private JavaNameInfo getJavaNames(ThreadProxy th, Address fp) { for (int fCount = 0; fCount < jvframes.length; fCount++) { JavaVFrame vf = jvframes[fCount]; Frame f = vf.getFrame(); - if (fp.equals(f.getFP())) { + if ((fp == null && f.getFP() == null) || // special case in CodeBlob + (fp != null && fp.equals(f.getFP()))) { bottomJVFrame = vf; StringBuilder sb = new StringBuilder(); Method method = vf.getMethod();