JDK-8244669 : convert clhsdb "mem" command from javascript to java
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: svc-agent
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-05-08
  • Updated: 2022-12-27
  • Resolved: 2021-12-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 19
17.0.7-oracleFixed 19 b04Fixed
Related Reports
Relates :  
Relates :  
Description
"mem" is very similar to "examine". There are 3 differences:
(1) "mem" prints just one word of memory per line whereas "examine" prints as many as will fit. This difference will remain since it is intentional.
(2)  if the address is in a .dso, instead of printing the address, "mem" will print the native symbol name plus the offset. However, this doesn't actually appear to work, so I plan on dropping this feature. However, see the -v option below.
(3) The address range argument for "mem" is the start address plus an optional argument which is number of words to print: "mem address [ length ]". The syntax for "examine" is "examine { address[/count] | address,address }". I plan on having "mem" support the same address range argument as "examine". That means specifying the count as a separate argument won't be supported. The count instead needs to be part of the "address[/count]" argument.

I also plan on adding a -v option to "mem". It will serve two purposes. The first is to essentially do a findpc on the address to print out what the address points to. This will help make up for no longer printing native symbol names for each line of output. Instead if the address is a native symbol (or any other type of memory that SA recognizes) you will see that in the findpc output. The 2nd thing -v will trigger is for each value in memory that is printed, it will also call findpc on that value, so if it is an address it will print out what the address is for. Here's an example showing the contents of the 1st 20 words of a hotspot Method object.

hsdb> mem -v 0x0000151c4c403530/20
Address 0x0000151c4c403530: Method jdk/test/lib/apps/LingeredApp.steadyState(Ljava/lang/Object;)V@0x0000151c4c403530
0x0000151c4c403530: 0x0000151c919cebc8 vtable for Method + 0x10
0x0000151c4c403538: 0x0000000000000000
0x0000151c4c403540: 0x0000151c4c4034d0
0x0000151c4c403548: 0x0000151c4c406c00 MethodData for steadyState(Ljava/lang/Object;)V
0x0000151c4c403550: 0x0000151c4c406bc0 Is of type MethodCounters
0x0000151c4c403558: 0x0000151c882b1810
0x0000151c4c403560: 0xfffffffeb000000a
0x0000151c4c403568: 0x0000000000000000
0x0000151c4c403570: 0x0000000000000000
0x0000151c4c403578: 0x0000151c70851c00 In interpreter codelet: method entry point (kind = zerolocals) [0x0000151c70851be8, 0x0000151c708521e0)  1528 bytes  
0x0000151c4c403580: 0x0000151c785733a0 In code in NMethod for jdk/test/lib/apps/LingeredApp.steadyState(Ljava/lang/Object;)V==>nsun.jvm.hotspot.code.NMethod@0x0000151c78573210
0x0000151c4c403588: 0x0000151c78573210 Is of type nmethod
0x0000151c4c403590: 0x0000151c70958d60 In code in sun.jvm.hotspot.code.AdapterBlob@0x0000151c70958c90
0x0000151c4c403598: 0x00ff020000000015
0x0000151c4c4035a0: 0x000702000702000d
0x0000151c4c4035a8: 0x00fa810107010002
0x0000151c4c4035b0: 0x0000000000000004
0x0000151c4c4035b8: 0x000000000000019d
0x0000151c4c4035c0: 0x0000151c4c400260 ConstantPool for jdk/test/lib/apps/LingeredApp
0x0000151c4c4035c8: 0x0000151c4c403690


Comments
Fix request [17u] I backport this for parity with 17.0.7-oracle. Low risk, changes only debugging tools. I had to resolve because of a trivial difference to head. SAP nightly testing passed.
23-12-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/968 Date: 2022-12-22 10:40:03 +0000
22-12-2022

Changeset: eaefb1a1 Author: Chris Plummer <cjplummer@openjdk.org> Date: 2021-12-22 23:02:41 +0000 URL: https://git.openjdk.java.net/jdk/commit/eaefb1a1ed9edea440628e3a5c5483ebd52bfcb0
22-12-2021

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/6902 Date: 2021-12-21 01:26:07 +0000
21-12-2021