Integrated: 8266967: debug.cpp utility find() should print Java Object fields.
Kevin Walls
kevinw at openjdk.java.net
Mon Jun 7 22:29:18 UTC 2021
On Thu, 13 May 2021 12:12:42 GMT, Kevin Walls <kevinw at openjdk.org> wrote:
> This change enables debug.cpp's find() utility to print Java Objects with their fields.
>
> find() calls os::print_location, and Java heap objects are printed with instanceKlass oop_print_on.
> Removing the ifdef for defining oop_print_on for instanceKlass, and also on methods in FieldPrinter and FieldDescriptor, make this work.
>
>
> Checking other uses of os::print_location this might affect:
>
> macroAssembler_x86.cpp has MacroAssembler::print_state32 and MacroAssembler::print_state64
> which use os::print_location to print register contents and print words at top of stack.
> These will be more verbose, as it already is in non-PRODUCT builds.
>
> vmError uses os::print_location when showing the stack, i.e. this output:
>
> Stack slot to memory mapping:
> stack at sp + 0 slots: 0x0000000000000002 is an unknown value
> ..etc...
>
> ...will be more verbose when Java object references are found (for the 8 stack slots it tries to show).
>
>
> Shenandoah uses os::print_location once, but for non-Java heap objects so nothing changes.
>
>
> Manual testing on Linux-x64 and Windows: old behaviour shows these two lines only:
>
> "Executing find"
> 0x00000000ff0a03e0 is an oop: jdk.internal.loader.ClassLoaders$AppClassLoader
> {0x00000000ff0a03e0} - klass: 'jdk/internal/loader/ClassLoaders$AppClassLoader'
>
> ...then with the change the full info:
>
> "Executing find"
> 0x00000000ff0a03e0 is an oop: jdk.internal.loader.ClassLoaders$AppClassLoader
> {0x00000000ff0a03e0} - klass: 'jdk/internal/loader/ClassLoaders$AppClassLoader'
> - ---- fields (total size 13 words):
> - private 'defaultAssertionStatus' 'Z' @12 false
> - private final 'parent' 'Ljava/lang/ClassLoader;' @24 a 'jdk/internal/loader/ClassLoaders$PlatformClassLoader'{0x00000000ff0a0a
> 40} (ff0a0a40)
> - private final 'name' 'Ljava/lang/String;' @28 "app"{0x00000000ff0d0060} (ff0d0060)
> - private final 'unnamedModule' 'Ljava/lang/Module;' @32 a 'java/lang/Module'{0x00000000ff0a0448} (ff0a0448)
> ...etc...
This pull request has now been integrated.
Changeset: 5e557d86
Author: Kevin Walls <kevinw at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/5e557d8650d81f9f81938892de28a6dd8fea98b0
Stats: 20 lines in 4 files changed: 5 ins; 12 del; 3 mod
8266967: debug.cpp utility find() should print Java Object fields.
Reviewed-by: sspitsyn, coleenp
-------------
PR: https://git.openjdk.java.net/jdk/pull/4011
More information about the serviceability-dev
mailing list