On Mon, 15 Mar 2021 07:29:16 GMT, Koichi Sakata <[email protected]> wrote:
> When running jstack with mixed option, the output of the lines that doesn't
> have an address are misaligned as followings.
>
> $ sudo jhsdb jstack --mixed --pid 5905
> ----------------- 5955 -----------------
> "event-handler" #20 daemon prio=5 tid=0x00007f133079a970 nid=0x1743 in
> Object.wait() [0x00007f1308bfe000]
> java.lang.Thread.State: WAITING (on object monitor)
> JavaThread state: _thread_blocked
> 0x00007f133a85b9f3 __pthread_cond_wait + 0x243
> 0x00007f133940b75b os::PlatformEvent::park() + 0x8b
> 0x00007f13393b7b2d ObjectMonitor::wait(long, bool, Thread*) + 0xf4d
> 0x00007f13397f0b95 ObjectSynchronizer::wait(Handle, long, Thread*) + 0x85
> 0x00007f1338e85961 JVM_MonitorWait + 0x241
> 0x00007f1328b264b7 java.lang.Object.wait(long) + 0xd7 (Native method)
> 0x00007f132177b3c4 * java.lang.Object.wait() bci:2 line:338 (Compiled frame)
> * com.sun.tools.jdi.EventQueueImpl.removeUnfiltered(long) bci:64 line:190
> (Compiled frame)
> * com.sun.tools.jdi.EventQueueImpl.remove(long) bci:18 line:97 (Interpreted
> frame)
> 0x00007f1321009543 * com.sun.tools.jdi.EventQueueImpl.remove() bci:2 line:83
> (Interpreted frame)
>
> This pull request aligns the indentation. So It will be able to improve
> readability.
>
> In this pull request the address part is filled with white spaces. The amount
> of space is calculated from VM's logarithmic address size and lastly 2, which
> is the length of "0x", is added.
>
> I checked the output on 64-bit and 32-bit OS.
>
> 0x00007f596cb2a6b7 java.lang.Object.wait(long) + 0xd7 (Native method)
> 0x00007f5965791ec4 * java.lang.Object.wait() bci:2 line:338 (Compiled
> frame)
> *
> com.sun.tools.jdi.EventQueueImpl.removeUnfiltered(long) bci:64 line:190
> (Compiled frame)
> * com.sun.tools.jdi.EventQueueImpl.remove(long)
> bci:18 line:97 (Interpreted frame)
> 0x00007f5965009543 * com.sun.tools.jdi.EventQueueImpl.remove() bci:2
> line:83 (Interpreted frame)
> 0x00007f59650099b3 * jdk.jshell.execution.JdiEventHandler.run() bci:18
> line:79 (Interpreted frame)
> 0x00007f596500985a * java.lang.Thread.run() bci:11 line:831 (Interpreted
> frame)
>
> 0x035002d4 java.lang.Object.wait(long) + 0x94 (Native method)
> 0x034fcd3c * java.lang.Object.wait() bci:2 line:338 (Compiled frame)
> * com.sun.tools.jdi.EventQueueImpl.removeUnfiltered(long)
> bci:64 line:190 (Compiled frame)
> * com.sun.tools.jdi.EventQueueImpl.remove(long) bci:18
> line:97 (Interpreted frame)
> 0x03296839 * com.sun.tools.jdi.EventQueueImpl.remove() bci:2 line:83
> (Interpreted frame)
What testing have you done?
Please update the copyright to 2021.
I noticed that in you original jstack output there is only 1 space after the
address, and now there appears to be multiple spaces. However, when I produce
the jstack out there's already multiple spaces. Was there some formatting issue
with your original output?
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java line 172:
> 170: // print java frame(s)
> 171: for (int i = 0; i < names.length; i++) {
> 172: if (0 < i) {
Please use `i > 0`
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java line 85:
> 83: }
> 84: final boolean cdbgCanDemangle = cdbg.canDemangle();
> 85: String fillerForAddress = " ".repeat(2 + (2 <<
> VM.getVM().getLogAddressSize())) + "\t";
Why not use `2 * VM.getVM().getAddressSize()` rather than `(2 <<
VM.getVM().getLogAddressSize()`?
-------------
PR: https://git.openjdk.java.net/jdk/pull/3004