-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
The JVM can natively provide low-level diagnostic information, such as describing a Java Object in detail.
This can be accessed by attaching a native debugger, and is used in hs_err reporting, but should be more accessible.
The jcmd "VM.inspect" should be introduced, permitting usage against a live process. That includes a process started with -XX:+ShowMessageBoxOnError which has stopped with an error. At that point, the VM has not created the hs_err fatal error log, but we can already run "jcmd PID VM.info", to provide much of what would appear in the hs_err log, and a native debugger can be attached to discover the call stack.
jcmd VM.inspect describes an address given by the argument. It currently checks: CodeCache, Java Heap, JNI handles, Threads, stack locations, Metaspace, NMT information. Also accepts an option: -verbose=true as in some other jcmds.
The new command will let us examine additional Java objects, including fields and other details, e.g.
bash-4.2$ jcmd 1696 VM.inspect 0x000000011e0df1f8
1696:
0x000000011e0df1f8 is an oop: java.lang.NoSuchMethodError
{0x000000011e0df1f8} - klass: 'java/lang/NoSuchMethodError'
- ---- fields (total size 5 words):
- private transient 'depth' 'I' @12 34 (0x00000022)
- private transient 'backtrace' 'Ljava/lang/Object;' @16 a 'java/lang/Object'[7] {0x000000011e0df220} (0x23c1be44)
- private 'detailMessage' 'Ljava/lang/String;' @20 "'void java.lang.invoke.DirectMethodHandle$Holder.invokeSpecial(java.lang.Object, java.lang.Object, java.lang.Object)'"{0x000000011e0df158} (0x23c1be2b)
- private 'cause' 'Ljava/lang/Throwable;' @24 a 'java/lang/NoSuchMethodError'{0x000000011e0df1f8} (0x23c1be3f)
- private 'stackTrace' '[Ljava/lang/StackTraceElement;' @28 a 'java/lang/StackTraceElement'[0] {0x000000011f00d9e8} (0x23e01b3d)
- private 'suppressedExceptions' 'Ljava/util/List;' @32 a 'java/util/Collections$EmptyList'{0x000000011f00da08} (0x23e01b41)
bash-4.2$
bash-4.2$ jcmd 3998 VM.inspect -verbose=true 0x00007f7414189590
3998:
"Monitor Deflation Thread" #13 [4012] daemon prio=9 os_prio=0 cpu=120.77ms elapsed=2130.20s tid=0x00007f7414189590 nid=4012 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
bash-4.2$
bash-4.2$ jcmd 3998 VM.inspect 0x00007f73fc2ed8c0
3998:
0x00007f73fc2ed8c0 is at entry_point+0 in (nmethod*)0x00007f73fc2ed710
Compiled method (c1) 1960377 3 3 java.lang.String::length (11 bytes)
total in heap [0x00007f73fc2ed710,0x00007f73fc2edb58] = 1096
relocation [0x00007f73fc2ed868,0x00007f73fc2ed8a8] = 64
main code [0x00007f73fc2ed8c0,0x00007f73fc2eda30] = 368
stub code [0x00007f73fc2eda30,0x00007f73fc2edab8] = 136
metadata [0x00007f73fc2edab8,0x00007f73fc2edac8] = 16
scopes data [0x00007f73fc2edac8,0x00007f73fc2edaf0] = 40
scopes pcs [0x00007f73fc2edaf0,0x00007f73fc2edb40] = 80
dependencies [0x00007f73fc2edb40,0x00007f73fc2edb48] = 8
nul chk table [0x00007f73fc2edb48,0x00007f73fc2edb58] = 16
This can be accessed by attaching a native debugger, and is used in hs_err reporting, but should be more accessible.
The jcmd "VM.inspect" should be introduced, permitting usage against a live process. That includes a process started with -XX:+ShowMessageBoxOnError which has stopped with an error. At that point, the VM has not created the hs_err fatal error log, but we can already run "jcmd PID VM.info", to provide much of what would appear in the hs_err log, and a native debugger can be attached to discover the call stack.
jcmd VM.inspect describes an address given by the argument. It currently checks: CodeCache, Java Heap, JNI handles, Threads, stack locations, Metaspace, NMT information. Also accepts an option: -verbose=true as in some other jcmds.
The new command will let us examine additional Java objects, including fields and other details, e.g.
bash-4.2$ jcmd 1696 VM.inspect 0x000000011e0df1f8
1696:
0x000000011e0df1f8 is an oop: java.lang.NoSuchMethodError
{0x000000011e0df1f8} - klass: 'java/lang/NoSuchMethodError'
- ---- fields (total size 5 words):
- private transient 'depth' 'I' @12 34 (0x00000022)
- private transient 'backtrace' 'Ljava/lang/Object;' @16 a 'java/lang/Object'[7] {0x000000011e0df220} (0x23c1be44)
- private 'detailMessage' 'Ljava/lang/String;' @20 "'void java.lang.invoke.DirectMethodHandle$Holder.invokeSpecial(java.lang.Object, java.lang.Object, java.lang.Object)'"{0x000000011e0df158} (0x23c1be2b)
- private 'cause' 'Ljava/lang/Throwable;' @24 a 'java/lang/NoSuchMethodError'{0x000000011e0df1f8} (0x23c1be3f)
- private 'stackTrace' '[Ljava/lang/StackTraceElement;' @28 a 'java/lang/StackTraceElement'[0] {0x000000011f00d9e8} (0x23e01b3d)
- private 'suppressedExceptions' 'Ljava/util/List;' @32 a 'java/util/Collections$EmptyList'{0x000000011f00da08} (0x23e01b41)
bash-4.2$
bash-4.2$ jcmd 3998 VM.inspect -verbose=true 0x00007f7414189590
3998:
"Monitor Deflation Thread" #13 [4012] daemon prio=9 os_prio=0 cpu=120.77ms elapsed=2130.20s tid=0x00007f7414189590 nid=4012 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
bash-4.2$
bash-4.2$ jcmd 3998 VM.inspect 0x00007f73fc2ed8c0
3998:
0x00007f73fc2ed8c0 is at entry_point+0 in (nmethod*)0x00007f73fc2ed710
Compiled method (c1) 1960377 3 3 java.lang.String::length (11 bytes)
total in heap [0x00007f73fc2ed710,0x00007f73fc2edb58] = 1096
relocation [0x00007f73fc2ed868,0x00007f73fc2ed8a8] = 64
main code [0x00007f73fc2ed8c0,0x00007f73fc2eda30] = 368
stub code [0x00007f73fc2eda30,0x00007f73fc2edab8] = 136
metadata [0x00007f73fc2edab8,0x00007f73fc2edac8] = 16
scopes data [0x00007f73fc2edac8,0x00007f73fc2edaf0] = 40
scopes pcs [0x00007f73fc2edaf0,0x00007f73fc2edb40] = 80
dependencies [0x00007f73fc2edb40,0x00007f73fc2edb48] = 8
nul chk table [0x00007f73fc2edb48,0x00007f73fc2edb58] = 16
- csr for
-
JDK-8318156 jcmd should provide access to detailed JVM object information
-
- Provisional
-
- links to
-
Review openjdk/jdk/17655