RFR: 8292699: Improve printing of classes in native debugger [v12]

Ioi Lam iklam at openjdk.org
Sun Oct 23 05:25:22 UTC 2022


> Current in gdb, you can print information about a class or method with something like
> 
> 
> call ((InstanceKlass*)0x00000008000411b8)->print_on(tty)
> call ((Method*)0x00007fffb4000d08)->print_codes_on(tty)
> 
> 
> However, it's difficult to find a class or method by its name and print out its contents.
> 
> This RFE adds 3 new functions in debug.cpp so you can easily find classes/methods and print out their contents. They all have a `flags` argument that controls the verbosity.
> 
> - `findclass()`: class name only
> - `findmethod()`: class name and method name
> - `findmethod2()`: class name and method name/signature
> 
> I also cleaned up `BytecodeTracer` to remove unnecessary complexity.
> 
> Here are some examples:
> 
> 
> (gdb) call findclass("java/lang/Object", 0)
> [0] 0x00000008000411b8 java.lang.Object, loader data: 0x00007ffff0130d10 of 'bootstrap'
> 
> (gdb) call findclass("java/lang/Object", 1)
> [0] 0x00000008000411b8 java.lang.Object, loader data: 0x00007ffff0130d10 of 'bootstrap'
> 0x00007fffb4000658 <init> : ()V
> 0x00007fffb40010f0 finalize : ()V
> 0x00007fffb4000f00 wait0 : (J)V
> 0x00007fffb40008e8 equals : (Ljava/lang/Object;)Z
> 0x00007fffb4000aa0 toString : ()Ljava/lang/String;
> 0x00007fffb40007f0 hashCode : ()I
> 0x00007fffb4000720 getClass : ()Ljava/lang/Class;
> 0x00007fffb40009a0 clone : ()Ljava/lang/Object;
> 0x00007fffb4000b50 notify : ()V
> 0x00007fffb4000c20 notifyAll : ()V
> 0x00007fffb4000e50 wait : (J)V
> 0x00007fffb4001028 wait : (JI)V
> 0x00007fffb4000d08 wait : ()V
> 
> (gdb) call findclass("*ClassLoader", 0)
> [0] 0x000000080007de40 jdk.internal.loader.ClassLoaders$BootClassLoader, loader data: 0x00007ffff0130d10 of 'bootstrap'
> [1] 0x0000000800053c58 jdk.internal.loader.ClassLoaders$PlatformClassLoader, loader data: 0x00007ffff0130d10 of 'bootstrap'
> [2] 0x0000000800053918 jdk.internal.loader.ClassLoaders$AppClassLoader, loader data: 0x00007ffff0130d10 of 'bootstrap'
> [....]
> 
> (gdb) call findmethod2("*ang/Object*", "wait", "()V", 0x7)
> [0] 0x00000008000411b8 java.lang.Object, loader data: 0x00007ffff0130d10 of 'bootstrap'
> 0x00007fffb4000d08 wait : ()V
> 0x00007fffb4000ce8 0 fast_aload_0
> 0x00007fffb4000ce9 1 lconst_0
> 0x00007fffb4000cea 2 invokevirtual 38 <java/lang/Object.wait(J)V>
> 0x00007fffb4000ced 5 return

Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 15 additional commits since the last revision:

 - added gtest case
 - removed unnecessary code; simplified start matching; added Symbol::is_star_match
 - Merge branch 'master' into 8292699-improve-class-printing-in-gdb
 - @coleenp comments
 - Allow ClassPrinter to also print to streams other than tty
 - added functions for printing InstanceKlass* and Method* pointers directly
 - some code clean-up; added help message
 - Use proper locking
 - Do not use class external name in printing
 - Added detailed printing of invokehandle
 - ... and 5 more: https://git.openjdk.org/jdk/compare/20736487...c029465b

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/9957/files
  - new: https://git.openjdk.org/jdk/pull/9957/files/e4afb9fa..c029465b

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=9957&range=11
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=9957&range=10-11

  Stats: 182323 lines in 3671 files changed: 97021 ins; 63297 del; 22005 mod
  Patch: https://git.openjdk.org/jdk/pull/9957.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9957/head:pull/9957

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


More information about the hotspot-dev mailing list