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 |
125 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false)); |
127 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false)); |
126 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStatusDCmd>(jmx_agent_export_flags, true,false)); |
128 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStatusDCmd>(jmx_agent_export_flags, true,false)); |
127 |
129 |
128 // Debug on cmd (only makes sense with JVMTI since the agentlib needs it). |
130 // Debug on cmd (only makes sense with JVMTI since the agentlib needs it). |
129 #if INCLUDE_JVMTI |
131 #if INCLUDE_JVMTI |
130 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<DebugOnCmdStartDCmd>(full_export, true, false)); |
132 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<DebugOnCmdStartDCmd>(full_export, true, true)); |
131 #endif // INCLUDE_JVMTI |
133 #endif // INCLUDE_JVMTI |
132 |
134 |
133 } |
135 } |
134 |
136 |
135 #ifndef HAVE_EXTRA_DCMD |
137 #ifndef HAVE_EXTRA_DCMD |
942 |
944 |
943 //---< BEGIN >--- CodeHeap State Analytics. |
945 //---< BEGIN >--- CodeHeap State Analytics. |
944 CodeHeapAnalyticsDCmd::CodeHeapAnalyticsDCmd(outputStream* output, bool heap) : |
946 CodeHeapAnalyticsDCmd::CodeHeapAnalyticsDCmd(outputStream* output, bool heap) : |
945 DCmdWithParser(output, heap), |
947 DCmdWithParser(output, heap), |
946 _function("function", "Function to be performed (aggregate, UsedSpace, FreeSpace, MethodCount, MethodSpace, MethodAge, MethodNames, discard", "STRING", false, "all"), |
948 _function("function", "Function to be performed (aggregate, UsedSpace, FreeSpace, MethodCount, MethodSpace, MethodAge, MethodNames, discard", "STRING", false, "all"), |
947 _granularity("granularity", "Detail level - smaller value -> more detail", "STRING", false, "4096") { |
949 _granularity("granularity", "Detail level - smaller value -> more detail", "INT", false, "4096") { |
948 _dcmdparser.add_dcmd_argument(&_function); |
950 _dcmdparser.add_dcmd_argument(&_function); |
949 _dcmdparser.add_dcmd_argument(&_granularity); |
951 _dcmdparser.add_dcmd_argument(&_granularity); |
950 } |
952 } |
951 |
953 |
952 void CodeHeapAnalyticsDCmd::execute(DCmdSource source, TRAPS) { |
954 void CodeHeapAnalyticsDCmd::execute(DCmdSource source, TRAPS) { |
953 CompileBroker::print_heapinfo(output(), _function.value(), _granularity.value()); |
955 jlong granularity = _granularity.value(); |
|
956 if (granularity < 1) { |
|
957 Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(), |
|
958 "Invalid granularity value " JLONG_FORMAT ". Should be positive.\n", granularity); |
|
959 return; |
|
960 } |
|
961 |
|
962 CompileBroker::print_heapinfo(output(), _function.value(), granularity); |
954 } |
963 } |
955 |
964 |
956 int CodeHeapAnalyticsDCmd::num_arguments() { |
965 int CodeHeapAnalyticsDCmd::num_arguments() { |
957 ResourceMark rm; |
966 ResourceMark rm; |
958 CodeHeapAnalyticsDCmd* dcmd = new CodeHeapAnalyticsDCmd(NULL, false); |
967 CodeHeapAnalyticsDCmd* dcmd = new CodeHeapAnalyticsDCmd(NULL, false); |
962 } else { |
971 } else { |
963 return 0; |
972 return 0; |
964 } |
973 } |
965 } |
974 } |
966 //---< END >--- CodeHeap State Analytics. |
975 //---< END >--- CodeHeap State Analytics. |
|
976 |
|
977 EventLogDCmd::EventLogDCmd(outputStream* output, bool heap) : |
|
978 DCmdWithParser(output, heap), |
|
979 _log("log", "Name of log to be printed. If omitted, all logs are printed.", "STRING", false, NULL), |
|
980 _max("max", "Maximum number of events to be printed (newest first). If omitted, all events are printed.", "STRING", false, NULL) |
|
981 { |
|
982 _dcmdparser.add_dcmd_option(&_log); |
|
983 _dcmdparser.add_dcmd_option(&_max); |
|
984 } |
|
985 |
|
986 void EventLogDCmd::execute(DCmdSource source, TRAPS) { |
|
987 const char* max_value = _max.value(); |
|
988 long max = -1; |
|
989 if (max_value != NULL) { |
|
990 char* endptr = NULL; |
|
991 max = ::strtol(max_value, &endptr, 10); |
|
992 if (max == 0 && max_value == endptr) { |
|
993 output()->print_cr("Invalid max option: \"%s\".", max_value); |
|
994 return; |
|
995 } |
|
996 } |
|
997 const char* log_name = _log.value(); |
|
998 if (log_name != NULL) { |
|
999 Events::print_one(output(), log_name, max); |
|
1000 } else { |
|
1001 Events::print_all(output(), max); |
|
1002 } |
|
1003 } |
|
1004 |
|
1005 int EventLogDCmd::num_arguments() { |
|
1006 ResourceMark rm; |
|
1007 EventLogDCmd* dcmd = new EventLogDCmd(NULL, false); |
|
1008 if (dcmd != NULL) { |
|
1009 DCmdMark mark(dcmd); |
|
1010 return dcmd->_dcmdparser.num_arguments(); |
|
1011 } else { |
|
1012 return 0; |
|
1013 } |
|
1014 } |
967 |
1015 |
968 void CompilerDirectivesPrintDCmd::execute(DCmdSource source, TRAPS) { |
1016 void CompilerDirectivesPrintDCmd::execute(DCmdSource source, TRAPS) { |
969 DirectivesStack::print(output()); |
1017 DirectivesStack::print(output()); |
970 } |
1018 } |
971 |
1019 |