On Thu, 23 Dec 2021 03:31:44 GMT, Chris Plummer <cjplum...@openjdk.org> wrote:
> HSDB has a Memory Viewer feature that brings up a window that shows the > memory contents in a specific address range. It basically looks just like the > clhsdb "mem" output. The recently revived "mem" command (see > [JDK-824466](https://bugs.openjdk.java.net/browse/JDK-8244669) and PR #6902) > adds a -v options which causes PointerFinder (aka findpc) to be called on > each value in memory to provide details about what the value points to (if it > is an address). This PR adds this same feature to HSDB by adding a new > Annotated Memory Viewer window. See the [this > image](https://bugs.openjdk.java.net/secure/attachment/97439/memory_viewer.png) > which shows the current Memory Viewer window, and just below it the new > Annotated Memory Viewer window showing the same address range. > > A couple of implementation notes. Both types of memory viewers share the > MemoryPanel class. The traditional viewer uses two columns, one for the > address and one for its contents. The annotated viewer uses just one column > which contains the entire line. For example: > > 0x00007f7eb010c330: 0x00007f7eb6c9dfb0 vtable for os::PlatformMonitor + 0x10 > > This approach was chosen rather than using 3 columns because it was a > difficult to get the first two columns to be just wide enough for the 64-bit > values while having the 3rd column be a long line of text. You end up with a > lot of wasted space in the first two columns as you make the window wider > while trying to get all the text of the 3rd column into view. > > Regarding the changes in MemoryPanel.handleImport(), Memory Viewer supports > clicking on a value that's an address and dragging it back onto the window to > start displaying memory at that address. This dropped text ends up being > processed by MemoryPanel.handleImport(). When you try this with Annotated > Memory Viewer, you end up with the entire line being passed to > MemoryPanel.handleImport(), not just an address (one downside of going with > just 1 column instead of 3). So the changes in MemoryPanel.handleImport() > detect this and pull the desired address out of the string. It seems to be a nice feature introduced with this. Looks good to me. Just one nit inlined. Thanks, Serguei src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/MemoryPanel.java line 140: > 138: Address addr = bigIntToAddress(bigaddr); > 139: > 140: col1 = bigIntToHexString(bigaddr); Nit: This can be simplified just a little bit by moving the lines 137-138 above line 134. So, it will be like this: BigInteger bigaddr = startVal.add(new BigInteger(Integer.toString((row * addressSize)))); Address addr = bigIntToAddress(bigaddr); String col1 = bigIntToHexString(bigaddr); String col2 = unmappedAddrString; String col3 = ""; ------------- Marked as reviewed by sspitsyn (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/6923