< prev index next >

src/hotspot/share/services/diagnosticCommand.cpp

Print this page

 111   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
 112 #if INCLUDE_SERVICES
 113   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
 114   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
 115   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDictionaryDCmd>(full_export, true, false));
 116   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
 117   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassesDCmd>(full_export, true, false));
 118   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
 119   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
 120   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<metaspace::MetaspaceDCmd>(full_export, true, false));
 121   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<EventLogDCmd>(full_export, true, false));
 122 #if INCLUDE_JVMTI // Both JVMTI and SERVICES have to be enabled to have this dcmd
 123   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export, true, false));
 124 #endif // INCLUDE_JVMTI
 125 #endif // INCLUDE_SERVICES
 126 #if INCLUDE_JVMTI
 127   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(full_export, true, false));
 128 #endif // INCLUDE_JVMTI
 129   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
 130   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpToFileDCmd>(full_export, true, false));

 131   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
 132   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderHierarchyDCmd>(full_export, true, false));
 133   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false));
 134   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false));
 135   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false));
 136 #ifdef LINUX
 137   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PerfMapDCmd>(full_export, true, false));
 138   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<TrimCLibcHeapDCmd>(full_export, true, false));
 139   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<MallocInfoDcmd>(full_export, true, false));
 140 #endif // LINUX
 141 #if defined(LINUX) || defined(_WIN64)
 142   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemMapDCmd>(full_export, true,false));
 143   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDumpMapDCmd>(full_export, true,false));
 144 #endif // LINUX or WINDOWS
 145   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeHeapAnalyticsDCmd>(full_export, true, false));
 146 
 147   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesPrintDCmd>(full_export, true, false));
 148   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesAddDCmd>(full_export, true, false));
 149   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesRemoveDCmd>(full_export, true, false));
 150   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesClearDCmd>(full_export, true, false));

1061   _dcmdparser.add_dcmd_option(&_format);
1062   _dcmdparser.add_dcmd_argument(&_filepath);
1063 }
1064 
1065 void ThreadDumpToFileDCmd::execute(DCmdSource source, TRAPS) {
1066   bool json = (_format.value() != nullptr) && (strcmp(_format.value(), "json") == 0);
1067   char* path = _filepath.value();
1068   bool overwrite = _overwrite.value();
1069   Symbol* name = (json) ? vmSymbols::dumpThreadsToJson_name() : vmSymbols::dumpThreads_name();
1070   dumpToFile(name, vmSymbols::string_bool_byte_array_signature(), path, overwrite, CHECK);
1071 }
1072 
1073 void ThreadDumpToFileDCmd::dumpToFile(Symbol* name, Symbol* signature, const char* path, bool overwrite, TRAPS) {
1074   ResourceMark rm(THREAD);
1075   HandleMark hm(THREAD);
1076 
1077   Handle h_path = java_lang_String::create_from_str(path, CHECK);
1078 
1079   Symbol* sym = vmSymbols::jdk_internal_vm_ThreadDumper();
1080   Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK);
1081   InstanceKlass* ik = InstanceKlass::cast(k);
1082   if (HAS_PENDING_EXCEPTION) {
1083     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1084     output()->cr();
1085     CLEAR_PENDING_EXCEPTION;
1086     return;
1087   }
1088 
1089   // invoke the ThreadDump method to dump to file
1090   JavaValue result(T_OBJECT);
1091   JavaCallArguments args;
1092   args.push_oop(h_path);
1093   args.push_int(overwrite ? JNI_TRUE : JNI_FALSE);
1094   JavaCalls::call_static(&result,
1095                          k,
1096                          name,
1097                          signature,
1098                          &args,
1099                          THREAD);
1100   if (HAS_PENDING_EXCEPTION) {
1101     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1102     output()->cr();
1103     CLEAR_PENDING_EXCEPTION;
1104     return;
1105   }
1106 
1107   // check that result is byte array
1108   oop res = cast_to_oop(result.get_jobject());
1109   assert(res->is_typeArray(), "just checking");
1110   assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
1111 








































1112   // copy the bytes to the output stream
1113   typeArrayOop ba = typeArrayOop(res);
1114   jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
1115   output()->print_raw((const char*)addr, ba->length());
1116 }
1117 
1118 CompilationMemoryStatisticDCmd::CompilationMemoryStatisticDCmd(outputStream* output, bool heap) :
1119     DCmdWithParser(output, heap),
1120   _human_readable("-H", "Human readable format", "BOOLEAN", false, "false"),
1121   _minsize("-s", "Minimum memory size", "MEMORY SIZE", false, "0") {
1122   _dcmdparser.add_dcmd_option(&_human_readable);
1123   _dcmdparser.add_dcmd_option(&_minsize);
1124 }
1125 
1126 void CompilationMemoryStatisticDCmd::execute(DCmdSource source, TRAPS) {
1127   const bool human_readable = _human_readable.value();
1128   const size_t minsize = _minsize.has_value() ? _minsize.value()._size : 0;
1129   CompilationMemoryStatistic::print_all_by_size(output(), human_readable, minsize);
1130 }
1131 

 111   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
 112 #if INCLUDE_SERVICES
 113   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
 114   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
 115   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDictionaryDCmd>(full_export, true, false));
 116   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
 117   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassesDCmd>(full_export, true, false));
 118   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
 119   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
 120   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<metaspace::MetaspaceDCmd>(full_export, true, false));
 121   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<EventLogDCmd>(full_export, true, false));
 122 #if INCLUDE_JVMTI // Both JVMTI and SERVICES have to be enabled to have this dcmd
 123   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export, true, false));
 124 #endif // INCLUDE_JVMTI
 125 #endif // INCLUDE_SERVICES
 126 #if INCLUDE_JVMTI
 127   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(full_export, true, false));
 128 #endif // INCLUDE_JVMTI
 129   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
 130   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpToFileDCmd>(full_export, true, false));
 131   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VThreadSummaryDCmd>(full_export, true, false));
 132   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
 133   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderHierarchyDCmd>(full_export, true, false));
 134   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false));
 135   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false));
 136   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false));
 137 #ifdef LINUX
 138   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PerfMapDCmd>(full_export, true, false));
 139   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<TrimCLibcHeapDCmd>(full_export, true, false));
 140   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<MallocInfoDcmd>(full_export, true, false));
 141 #endif // LINUX
 142 #if defined(LINUX) || defined(_WIN64)
 143   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemMapDCmd>(full_export, true,false));
 144   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDumpMapDCmd>(full_export, true,false));
 145 #endif // LINUX or WINDOWS
 146   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeHeapAnalyticsDCmd>(full_export, true, false));
 147 
 148   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesPrintDCmd>(full_export, true, false));
 149   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesAddDCmd>(full_export, true, false));
 150   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesRemoveDCmd>(full_export, true, false));
 151   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesClearDCmd>(full_export, true, false));

1062   _dcmdparser.add_dcmd_option(&_format);
1063   _dcmdparser.add_dcmd_argument(&_filepath);
1064 }
1065 
1066 void ThreadDumpToFileDCmd::execute(DCmdSource source, TRAPS) {
1067   bool json = (_format.value() != nullptr) && (strcmp(_format.value(), "json") == 0);
1068   char* path = _filepath.value();
1069   bool overwrite = _overwrite.value();
1070   Symbol* name = (json) ? vmSymbols::dumpThreadsToJson_name() : vmSymbols::dumpThreads_name();
1071   dumpToFile(name, vmSymbols::string_bool_byte_array_signature(), path, overwrite, CHECK);
1072 }
1073 
1074 void ThreadDumpToFileDCmd::dumpToFile(Symbol* name, Symbol* signature, const char* path, bool overwrite, TRAPS) {
1075   ResourceMark rm(THREAD);
1076   HandleMark hm(THREAD);
1077 
1078   Handle h_path = java_lang_String::create_from_str(path, CHECK);
1079 
1080   Symbol* sym = vmSymbols::jdk_internal_vm_ThreadDumper();
1081   Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK);

1082   if (HAS_PENDING_EXCEPTION) {
1083     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1084     output()->cr();
1085     CLEAR_PENDING_EXCEPTION;
1086     return;
1087   }
1088 
1089   // invoke the ThreadDump method to dump to file
1090   JavaValue result(T_OBJECT);
1091   JavaCallArguments args;
1092   args.push_oop(h_path);
1093   args.push_int(overwrite ? JNI_TRUE : JNI_FALSE);
1094   JavaCalls::call_static(&result,
1095                          k,
1096                          name,
1097                          signature,
1098                          &args,
1099                          THREAD);
1100   if (HAS_PENDING_EXCEPTION) {
1101     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1102     output()->cr();
1103     CLEAR_PENDING_EXCEPTION;
1104     return;
1105   }
1106 
1107   // check that result is byte array
1108   oop res = cast_to_oop(result.get_jobject());
1109   assert(res->is_typeArray(), "just checking");
1110   assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
1111 
1112   // copy the bytes to the output stream
1113   typeArrayOop ba = typeArrayOop(res);
1114   jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
1115   output()->print_raw((const char*)addr, ba->length());
1116 }
1117 
1118 void VThreadSummaryDCmd::execute(DCmdSource source, TRAPS) {
1119   ResourceMark rm(THREAD);
1120   HandleMark hm(THREAD);
1121 
1122   Symbol* sym = vmSymbols::jdk_internal_vm_VThreadSummary();
1123   Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK);
1124   if (HAS_PENDING_EXCEPTION) {
1125     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1126     output()->cr();
1127     CLEAR_PENDING_EXCEPTION;
1128     return;
1129   }
1130 
1131   // invoke VThreadSummary.print method
1132   JavaValue result(T_OBJECT);
1133   JavaCallArguments args;
1134   JavaCalls::call_static(&result,
1135                          k,
1136                          vmSymbols::print_name(),
1137                          vmSymbols::void_byte_array_signature(),
1138                          &args,
1139                          THREAD);
1140   if (HAS_PENDING_EXCEPTION) {
1141     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1142     output()->cr();
1143     CLEAR_PENDING_EXCEPTION;
1144     return;
1145   }
1146 
1147   // check that result is byte array
1148   oop res = cast_to_oop(result.get_jobject());
1149   assert(res->is_typeArray(), "just checking");
1150   assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
1151 
1152   // copy the bytes to the output stream
1153   typeArrayOop ba = typeArrayOop(res);
1154   jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
1155   output()->print_raw((const char*)addr, ba->length());
1156 }
1157 
1158 CompilationMemoryStatisticDCmd::CompilationMemoryStatisticDCmd(outputStream* output, bool heap) :
1159     DCmdWithParser(output, heap),
1160   _human_readable("-H", "Human readable format", "BOOLEAN", false, "false"),
1161   _minsize("-s", "Minimum memory size", "MEMORY SIZE", false, "0") {
1162   _dcmdparser.add_dcmd_option(&_human_readable);
1163   _dcmdparser.add_dcmd_option(&_minsize);
1164 }
1165 
1166 void CompilationMemoryStatisticDCmd::execute(DCmdSource source, TRAPS) {
1167   const bool human_readable = _human_readable.value();
1168   const size_t minsize = _minsize.has_value() ? _minsize.value()._size : 0;
1169   CompilationMemoryStatistic::print_all_by_size(output(), human_readable, minsize);
1170 }
1171 
< prev index next >