< prev index next >

src/hotspot/share/services/diagnosticCommand.cpp

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 46,10 ***
--- 46,11 ---
  #include "nmt/memTracker.hpp"
  #include "nmt/nmtDCmd.hpp"
  #include "oops/instanceKlass.hpp"
  #include "oops/objArrayOop.inline.hpp"
  #include "oops/oop.inline.hpp"
+ #include "oops/oopCast.inline.hpp"
  #include "oops/typeArrayOop.inline.hpp"
  #include "prims/jvmtiAgentList.hpp"
  #include "runtime/fieldDescriptor.inline.hpp"
  #include "runtime/flags/jvmFlag.hpp"
  #include "runtime/handles.inline.hpp"

*** 115,10 ***
--- 116,11 ---
    DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export));
    DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassesDCmd>(full_export));
    DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export));
    DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export));
    DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<metaspace::MetaspaceDCmd>(full_export));
+   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintClassLayoutDCmd>(full_export));
    DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<EventLogDCmd>(full_export));
  #if INCLUDE_JVMTI // Both JVMTI and SERVICES have to be enabled to have this dcmd
    DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export));
  #endif // INCLUDE_JVMTI
  #endif // INCLUDE_SERVICES

*** 432,11 ***
  
    JavaCalls::call_static(&result, k,
                           vmSymbols::get_finalizer_histogram_name(),
                           vmSymbols::void_finalizer_histogram_entry_array_signature(), CHECK);
  
!   objArrayOop result_oop = (objArrayOop) result.get_oop();
    if (result_oop->length() == 0) {
      output()->print_cr("No instances waiting for finalization found");
      return;
    }
  
--- 434,11 ---
  
    JavaCalls::call_static(&result, k,
                           vmSymbols::get_finalizer_histogram_name(),
                           vmSymbols::void_finalizer_histogram_entry_array_signature(), CHECK);
  
!   refArrayOop result_oop = oop_cast<refArrayOop>(result.get_oop());
    if (result_oop->length() == 0) {
      output()->print_cr("No instances waiting for finalization found");
      return;
    }
  

*** 943,11 ***
  void ClassHierarchyDCmd::execute(DCmdSource source, TRAPS) {
    VM_PrintClassHierarchy printClassHierarchyOp(output(), _print_interfaces.value(),
                                                 _print_subclasses.value(), _classname.value());
    VMThread::execute(&printClassHierarchyOp);
  }
! #endif
  
  ClassesDCmd::ClassesDCmd(outputStream* output, bool heap) :
                                       DCmdWithParser(output, heap),
    _verbose("-verbose",
             "Dump the detailed content of a Java class. "
--- 945,35 ---
  void ClassHierarchyDCmd::execute(DCmdSource source, TRAPS) {
    VM_PrintClassHierarchy printClassHierarchyOp(output(), _print_interfaces.value(),
                                                 _print_subclasses.value(), _classname.value());
    VMThread::execute(&printClassHierarchyOp);
  }
! 
+ PrintClassLayoutDCmd::PrintClassLayoutDCmd(outputStream* output, bool heap) :
+                                        DCmdWithParser(output, heap),
+   _classname("classname", "Name of class whose layout should be printed. ",
+              "STRING", true) {
+   _dcmdparser.add_dcmd_argument(&_classname);
+ }
+ 
+ void PrintClassLayoutDCmd::execute(DCmdSource source, TRAPS) {
+   VM_PrintClassLayout printClassLayoutOp(output(), _classname.value());
+   VMThread::execute(&printClassLayoutOp);
+ }
+ 
+ int PrintClassLayoutDCmd::num_arguments() {
+   ResourceMark rm;
+   PrintClassLayoutDCmd* dcmd = new PrintClassLayoutDCmd(nullptr, false);
+   if (dcmd != nullptr) {
+     DCmdMark mark(dcmd);
+     return dcmd->_dcmdparser.num_arguments();
+   } else {
+     return 0;
+   }
+ }
+ 
+ #endif // INCLUDE_SERVICES
  
  ClassesDCmd::ClassesDCmd(outputStream* output, bool heap) :
                                       DCmdWithParser(output, heap),
    _verbose("-verbose",
             "Dump the detailed content of a Java class. "
< prev index next >