From 5f1108f8f0768837591b06d47dec857963ed1fcb Mon Sep 17 00:00:00 2001 From: David Holmes Date: Tue, 7 Mar 2023 22:54:07 +0000 Subject: [PATCH] 8303151: DCmd framework cleanups Reviewed-by: jsjolen, stuefe, yyang --- .../share/services/diagnosticCommand.cpp | 10 +++------- .../share/services/diagnosticFramework.hpp | 18 +++++------------- src/hotspot/share/services/management.cpp | 7 +------ 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp index 9488f5780ec..5de1fb1b716 100644 --- a/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/hotspot/share/services/diagnosticCommand.cpp @@ -56,6 +56,7 @@ #include "services/diagnosticFramework.hpp" #include "services/heapDumper.hpp" #include "services/management.hpp" +#include "services/nmtDCmd.hpp" #include "services/writeableFlags.hpp" #include "utilities/debug.hpp" #include "utilities/events.hpp" @@ -80,7 +81,7 @@ static void loadAgentModule(TRAPS) { THREAD); } -void DCmdRegistrant::register_dcmds(){ +void DCmd::register_dcmds(){ // Registration of the diagnostic commands // First argument specifies which interfaces will export the command // Second argument specifies if the command is enabled @@ -153,14 +154,9 @@ void DCmdRegistrant::register_dcmds(){ #if INCLUDE_CDS DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); #endif // INCLUDE_CDS -} -#ifndef HAVE_EXTRA_DCMD -void DCmdRegistrant::register_dcmds_ext(){ - // Do nothing here + DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); } -#endif - HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap), _all("-all", "Show help for all commands", "BOOLEAN", false, "false"), diff --git a/src/hotspot/share/services/diagnosticFramework.hpp b/src/hotspot/share/services/diagnosticFramework.hpp index 6cb3aca1a90..3fdb89bf74d 100644 --- a/src/hotspot/share/services/diagnosticFramework.hpp +++ b/src/hotspot/share/services/diagnosticFramework.hpp @@ -310,6 +310,11 @@ public: // main method to invoke the framework static void parse_and_execute(DCmdSource source, outputStream* out, const char* cmdline, char delim, TRAPS); + + // Convenience method to register Dcmds, without a need to change + // management.cpp every time. + static void register_dcmds(); + }; class DCmdWithParser : public DCmd { @@ -452,17 +457,4 @@ private: } }; -// This class provides a convenient way to register Dcmds, without a need to change -// management.cpp every time. Body of these two methods resides in -// diagnosticCommand.cpp - -class DCmdRegistrant : public AllStatic { - -private: - static void register_dcmds(); - static void register_dcmds_ext(); - - friend class Management; -}; - #endif // SHARE_SERVICES_DIAGNOSTICFRAMEWORK_HPP diff --git a/src/hotspot/share/services/management.cpp b/src/hotspot/share/services/management.cpp index be6f1451e36..9ba1284ae82 100644 --- a/src/hotspot/share/services/management.cpp +++ b/src/hotspot/share/services/management.cpp @@ -61,7 +61,6 @@ #include "services/heapDumper.hpp" #include "services/lowMemoryDetector.hpp" #include "services/gcNotifier.hpp" -#include "services/nmtDCmd.hpp" #include "services/management.hpp" #include "services/memoryManager.hpp" #include "services/memoryPool.hpp" @@ -145,11 +144,7 @@ void Management::init() { _optional_support.isRemoteDiagnosticCommandsSupported = 1; // Registration of the diagnostic commands - DCmdRegistrant::register_dcmds(); - DCmdRegistrant::register_dcmds_ext(); - uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI - | DCmd_Source_MBean; - DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); + DCmd::register_dcmds(); } void Management::initialize(TRAPS) {