src/hotspot/share/services/diagnosticCommand.cpp
changeset 55217 bb3359bcf534
parent 54786 ebf733a324d4
child 55294 3493c1bc59fd
equal deleted inserted replaced
55216:3eb7187b20f0 55217:bb3359bcf534
     1 /*
     1 /*
     2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    46 #include "services/diagnosticFramework.hpp"
    46 #include "services/diagnosticFramework.hpp"
    47 #include "services/heapDumper.hpp"
    47 #include "services/heapDumper.hpp"
    48 #include "services/management.hpp"
    48 #include "services/management.hpp"
    49 #include "services/writeableFlags.hpp"
    49 #include "services/writeableFlags.hpp"
    50 #include "utilities/debug.hpp"
    50 #include "utilities/debug.hpp"
       
    51 #include "utilities/events.hpp"
    51 #include "utilities/formatBuffer.hpp"
    52 #include "utilities/formatBuffer.hpp"
    52 #include "utilities/macros.hpp"
    53 #include "utilities/macros.hpp"
    53 
    54 
    54 
    55 
    55 static void loadAgentModule(TRAPS) {
    56 static void loadAgentModule(TRAPS) {
    93   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDictionaryDCmd>(full_export, true, false));
    94   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDictionaryDCmd>(full_export, true, false));
    94   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
    95   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
    95   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
    96   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
    96   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
    97   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
    97   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<metaspace::MetaspaceDCmd>(full_export, true, false));
    98   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<metaspace::MetaspaceDCmd>(full_export, true, false));
       
    99   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<EventLogDCmd>(full_export, true, false));
    98 #if INCLUDE_JVMTI // Both JVMTI and SERVICES have to be enabled to have this dcmd
   100 #if INCLUDE_JVMTI // Both JVMTI and SERVICES have to be enabled to have this dcmd
    99   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export, true, false));
   101   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export, true, false));
   100 #endif // INCLUDE_JVMTI
   102 #endif // INCLUDE_JVMTI
   101 #endif // INCLUDE_SERVICES
   103 #endif // INCLUDE_SERVICES
   102 #if INCLUDE_JVMTI
   104 #if INCLUDE_JVMTI
   963     return 0;
   965     return 0;
   964   }
   966   }
   965 }
   967 }
   966 //---<  END  >--- CodeHeap State Analytics.
   968 //---<  END  >--- CodeHeap State Analytics.
   967 
   969 
       
   970 EventLogDCmd::EventLogDCmd(outputStream* output, bool heap) :
       
   971   DCmdWithParser(output, heap),
       
   972   _log("log", "Name of log to be printed. If omitted, all logs are printed.", "STRING", false, NULL),
       
   973   _max("max", "Maximum number of events to be printed (newest first). If omitted, all events are printed.", "STRING", false, NULL)
       
   974 {
       
   975   _dcmdparser.add_dcmd_option(&_log);
       
   976   _dcmdparser.add_dcmd_option(&_max);
       
   977 }
       
   978 
       
   979 void EventLogDCmd::execute(DCmdSource source, TRAPS) {
       
   980   const char* max_value = _max.value();
       
   981   long max = -1;
       
   982   if (max_value != NULL) {
       
   983     char* endptr = NULL;
       
   984     max = ::strtol(max_value, &endptr, 10);
       
   985     if (max == 0 && max_value == endptr) {
       
   986       output()->print_cr("Invalid max option: \"%s\".", max_value);
       
   987       return;
       
   988     }
       
   989   }
       
   990   const char* log_name = _log.value();
       
   991   if (log_name != NULL) {
       
   992     Events::print_one(output(), log_name, max);
       
   993   } else {
       
   994     Events::print_all(output(), max);
       
   995   }
       
   996 }
       
   997 
       
   998 int EventLogDCmd::num_arguments() {
       
   999   ResourceMark rm;
       
  1000   EventLogDCmd* dcmd = new EventLogDCmd(NULL, false);
       
  1001   if (dcmd != NULL) {
       
  1002     DCmdMark mark(dcmd);
       
  1003     return dcmd->_dcmdparser.num_arguments();
       
  1004   } else {
       
  1005     return 0;
       
  1006   }
       
  1007 }
       
  1008 
   968 void CompilerDirectivesPrintDCmd::execute(DCmdSource source, TRAPS) {
  1009 void CompilerDirectivesPrintDCmd::execute(DCmdSource source, TRAPS) {
   969   DirectivesStack::print(output());
  1010   DirectivesStack::print(output());
   970 }
  1011 }
   971 
  1012 
   972 CompilerDirectivesAddDCmd::CompilerDirectivesAddDCmd(outputStream* output, bool heap) :
  1013 CompilerDirectivesAddDCmd::CompilerDirectivesAddDCmd(outputStream* output, bool heap) :