-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8373110: jstack --mixed frames are broken on macOS after JDK-8371194 #28686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6268176
bb892eb
f5eeeaa
a42f8f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 2015, Red Hat Inc. | ||
| * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
|
|
@@ -26,15 +26,19 @@ | |
|
|
||
| package sun.jvm.hotspot.debugger.bsd.aarch64; | ||
|
|
||
| import sun.jvm.hotspot.code.*; | ||
| import sun.jvm.hotspot.debugger.*; | ||
| import sun.jvm.hotspot.debugger.aarch64.*; | ||
| import sun.jvm.hotspot.debugger.bsd.*; | ||
| import sun.jvm.hotspot.debugger.cdbg.*; | ||
| import sun.jvm.hotspot.debugger.cdbg.basic.*; | ||
| import sun.jvm.hotspot.runtime.*; | ||
| import sun.jvm.hotspot.runtime.aarch64.*; | ||
|
|
||
| public final class BsdAARCH64CFrame extends BasicCFrame { | ||
| public BsdAARCH64CFrame(BsdDebugger dbg, Address fp, Address pc) { | ||
| public BsdAARCH64CFrame(BsdDebugger dbg, Address sp, Address fp, Address pc) { | ||
| super(dbg.getCDebugger()); | ||
| this.sp = sp; | ||
| this.fp = fp; | ||
| this.pc = pc; | ||
| this.dbg = dbg; | ||
|
|
@@ -54,28 +58,65 @@ public Address localVariableBase() { | |
| return fp; | ||
| } | ||
|
|
||
| @Override | ||
| public CFrame sender(ThreadProxy thread) { | ||
| AARCH64ThreadContext context = (AARCH64ThreadContext) thread.getContext(); | ||
| Address rsp = context.getRegisterAsAddress(AARCH64ThreadContext.SP); | ||
| return sender(thread, null, null, null); | ||
| } | ||
|
|
||
| if ((fp == null) || fp.lessThan(rsp)) { | ||
| return null; | ||
| @Override | ||
| public CFrame sender(ThreadProxy thread, Address nextSP, Address nextFP, Address nextPC) { | ||
| // Check fp | ||
| // Skip if both nextFP and nextPC are given - do not need to load from fp. | ||
| if (nextFP == null && nextPC == null) { | ||
| if (fp == null) { | ||
| return null; | ||
| } | ||
|
|
||
| // Check alignment of fp | ||
| if (dbg.getAddressValue(fp) % (2 * ADDRESS_SIZE) != 0) { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| // Check alignment of fp | ||
| if (dbg.getAddressValue(fp) % (2 * ADDRESS_SIZE) != 0) { | ||
| if (nextFP == null) { | ||
| nextFP = fp.getAddressAt(0); | ||
| } | ||
| if (nextFP == null) { | ||
| return null; | ||
| } | ||
|
|
||
| Address nextFP = fp.getAddressAt(0 * ADDRESS_SIZE); | ||
| if (nextFP == null || nextFP.lessThanOrEqual(fp)) { | ||
| return null; | ||
| if (nextPC == null) { | ||
| nextPC = fp.getAddressAt(ADDRESS_SIZE); | ||
| } | ||
| Address nextPC = fp.getAddressAt(1 * ADDRESS_SIZE); | ||
| if (nextPC == null) { | ||
| return null; | ||
| } | ||
| return new BsdAARCH64CFrame(dbg, nextFP, nextPC); | ||
|
|
||
| if (nextSP == null) { | ||
| CodeCache cc = VM.getVM().getCodeCache(); | ||
| CodeBlob currentBlob = cc.findBlobUnsafe(pc()); | ||
|
|
||
| // This case is different from HotSpot. See JDK-8371194 for details. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good overall I think.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. We were trying to implement similar code with NativeStackPrinter used in generating hs_err log in HotSpot, but this condition is different with it. Comments in 8371195 says:
In os_bsd_aarch64.cpp, comment of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, so this is different to the HotSpot NativeStackPrinter and the frame::next_frame() method. |
||
| if (currentBlob != null && (currentBlob.isContinuationStub() || currentBlob.isNativeMethod())) { | ||
| // Use FP since it should always be valid for these cases. | ||
| // TODO: These should be walked as Frames not CFrames. | ||
| nextSP = fp.addOffsetTo(2 * ADDRESS_SIZE); | ||
| } else { | ||
| CodeBlob codeBlob = cc.findBlobUnsafe(nextPC); | ||
| boolean useCodeBlob = codeBlob != null && codeBlob.getFrameSize() > 0; | ||
| nextSP = useCodeBlob ? nextFP.addOffsetTo((2 * ADDRESS_SIZE) - codeBlob.getFrameSize()) : nextFP; | ||
| } | ||
| } | ||
| if (nextSP == null) { | ||
| return null; | ||
| } | ||
|
|
||
| return new BsdAARCH64CFrame(dbg, nextSP, nextFP, nextPC); | ||
| } | ||
|
|
||
| @Override | ||
| public Frame toFrame() { | ||
| return new AARCH64Frame(sp, fp, pc); | ||
| } | ||
|
|
||
| // package/class internals only | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it that for aarch64 these are all "next" arguments, but for AMD64 they are not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to declare like
sender(ThreadProxy th, Address sp, Address fp, Address pc)as defined inCFrame, however name of parameters (sp,fp,pc) have already declared as class members inBsdAARCH64CFrame. Thus I addednextas a prefix of parameter name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Looks like that was also the case with LunuxAARCH64CFrame.