RFR: 8298524: Debug function to trace reachability of CDS archived heap objects

Calvin Cheung ccheung at openjdk.org
Mon Dec 12 20:01:59 UTC 2022


On Mon, 12 Dec 2022 07:40:34 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> Please review this small change to help debugging the CDS heap archiving code. 
> 
> Here's an example in gdb that shows how the `java.lang.Module` object at `0x00000005ce8d9ba0` is reached from the root (`ArchivedClassLoaders::servicesCatalogs `)
> 
> 
> Thread 8 "VM Thread" hit Breakpoint 2, HeapShared::check_module_oop (orig_module_obj=0x5ce8bf588)
>     at heapShared.cpp:1193
> 1193	  assert(DumpSharedSpaces, "must be");
> (gdb) call CDSHeapVerifier::trace_to_root(tty, orig_module_obj)
> [ 0] {0x00000005ce8bb900} jdk.internal.loader.ArchivedClassLoaders::servicesCatalogs (offset = 24)
> [ 1] {0x00000005ce8bba08} [Ljdk.internal.module.ServicesCatalog; @[0]
> [ 2] {0x00000005ce8bbb60} jdk.internal.module.ServicesCatalog::map (offset = 12)
> [ 3] {0x00000005ce8bbb70} java.util.concurrent.ConcurrentHashMap::table (offset = 40)
> [ 4] {0x00000005ce8d9638} [Ljava.util.concurrent.ConcurrentHashMap$Node; @[0]
> [ 5] {0x00000005ce8d9bc0} java.util.concurrent.ConcurrentHashMap$Node::val (offset = 20)
> [ 6] {0x00000005ce8d9b78} java.util.concurrent.CopyOnWriteArrayList::array (offset = 16)
> [ 7] {0x00000005ce8d9ba0} [Ljava.lang.Object; @[0]
> [ 8] {0x00000005ce8d9b30} jdk.internal.module.ServicesCatalog$ServiceProvider::module (offset = 12)
> [ 9] {0x00000005ce8bf588} java.lang.Module

Just one minor comment.

src/hotspot/share/cds/cdsHeapVerifier.cpp line 278:

> 276: 
> 277: // Hint: to exercise this function, uncomment out one of the ADD_EXCL lines above.
> 278: int CDSHeapVerifier::trace_to_root(outputStream* st, oop orig_obj, oop orig_field, HeapShared::CachedOopInfo* info) {

With this change, this function could also be exercised via a debugger. Should the comment be updated?

-------------

Marked as reviewed by ccheung (Reviewer).

PR: https://git.openjdk.org/jdk/pull/11628


More information about the hotspot-runtime-dev mailing list