< 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   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemMapDCmd>(full_export, true,false));
 141   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDumpMapDCmd>(full_export, true,false));
 142 #endif // LINUX
 143   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeHeapAnalyticsDCmd>(full_export, true, false));
 144 
 145   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesPrintDCmd>(full_export, true, false));
 146   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesAddDCmd>(full_export, true, false));
 147   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesRemoveDCmd>(full_export, true, false));
 148   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesClearDCmd>(full_export, true, false));
 149   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilationMemoryStatisticDCmd>(full_export, true, false));
 150 

1109   _dcmdparser.add_dcmd_option(&_format);
1110   _dcmdparser.add_dcmd_argument(&_filepath);
1111 }
1112 
1113 void ThreadDumpToFileDCmd::execute(DCmdSource source, TRAPS) {
1114   bool json = (_format.value() != nullptr) && (strcmp(_format.value(), "json") == 0);
1115   char* path = _filepath.value();
1116   bool overwrite = _overwrite.value();
1117   Symbol* name = (json) ? vmSymbols::dumpThreadsToJson_name() : vmSymbols::dumpThreads_name();
1118   dumpToFile(name, vmSymbols::string_bool_byte_array_signature(), path, overwrite, CHECK);
1119 }
1120 
1121 void ThreadDumpToFileDCmd::dumpToFile(Symbol* name, Symbol* signature, const char* path, bool overwrite, TRAPS) {
1122   ResourceMark rm(THREAD);
1123   HandleMark hm(THREAD);
1124 
1125   Handle h_path = java_lang_String::create_from_str(path, CHECK);
1126 
1127   Symbol* sym = vmSymbols::jdk_internal_vm_ThreadDumper();
1128   Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK);
1129   InstanceKlass* ik = InstanceKlass::cast(k);
1130   if (HAS_PENDING_EXCEPTION) {
1131     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1132     output()->cr();
1133     CLEAR_PENDING_EXCEPTION;
1134     return;
1135   }
1136 
1137   // invoke the ThreadDump method to dump to file
1138   JavaValue result(T_OBJECT);
1139   JavaCallArguments args;
1140   args.push_oop(h_path);
1141   args.push_int(overwrite ? JNI_TRUE : JNI_FALSE);
1142   JavaCalls::call_static(&result,
1143                          k,
1144                          name,
1145                          signature,
1146                          &args,
1147                          THREAD);
1148   if (HAS_PENDING_EXCEPTION) {
1149     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1150     output()->cr();
1151     CLEAR_PENDING_EXCEPTION;
1152     return;
1153   }
1154 
1155   // check that result is byte array
1156   oop res = cast_to_oop(result.get_jobject());
1157   assert(res->is_typeArray(), "just checking");
1158   assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
1159 
1160   // copy the bytes to the output stream
1161   typeArrayOop ba = typeArrayOop(res);
1162   jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
1163   output()->print_raw((const char*)addr, ba->length());
1164 }
1165 








































1166 CompilationMemoryStatisticDCmd::CompilationMemoryStatisticDCmd(outputStream* output, bool heap) :
1167     DCmdWithParser(output, heap),
1168   _human_readable("-H", "Human readable format", "BOOLEAN", false, "false"),
1169   _minsize("-s", "Minimum memory size", "MEMORY SIZE", false, "0") {
1170   _dcmdparser.add_dcmd_option(&_human_readable);
1171   _dcmdparser.add_dcmd_option(&_minsize);
1172 }
1173 
1174 void CompilationMemoryStatisticDCmd::execute(DCmdSource source, TRAPS) {
1175   const bool human_readable = _human_readable.value();
1176   const size_t minsize = _minsize.has_value() ? _minsize.value()._size : 0;
1177   CompilationMemoryStatistic::print_all_by_size(output(), human_readable, minsize);
1178 }
1179 
1180 #ifdef LINUX
1181 
1182 SystemMapDCmd::SystemMapDCmd(outputStream* output, bool heap) :
1183     DCmdWithParser(output, heap),
1184   _human_readable("-H", "Human readable format", "BOOLEAN", false, "false") {
1185   _dcmdparser.add_dcmd_option(&_human_readable);

 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<VThreadSchedulerDCmd>(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   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemMapDCmd>(full_export, true,false));
 142   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDumpMapDCmd>(full_export, true,false));
 143 #endif // LINUX
 144   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeHeapAnalyticsDCmd>(full_export, true, false));
 145 
 146   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesPrintDCmd>(full_export, true, false));
 147   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesAddDCmd>(full_export, true, false));
 148   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesRemoveDCmd>(full_export, true, false));
 149   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesClearDCmd>(full_export, true, false));
 150   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilationMemoryStatisticDCmd>(full_export, true, false));
 151 

1110   _dcmdparser.add_dcmd_option(&_format);
1111   _dcmdparser.add_dcmd_argument(&_filepath);
1112 }
1113 
1114 void ThreadDumpToFileDCmd::execute(DCmdSource source, TRAPS) {
1115   bool json = (_format.value() != nullptr) && (strcmp(_format.value(), "json") == 0);
1116   char* path = _filepath.value();
1117   bool overwrite = _overwrite.value();
1118   Symbol* name = (json) ? vmSymbols::dumpThreadsToJson_name() : vmSymbols::dumpThreads_name();
1119   dumpToFile(name, vmSymbols::string_bool_byte_array_signature(), path, overwrite, CHECK);
1120 }
1121 
1122 void ThreadDumpToFileDCmd::dumpToFile(Symbol* name, Symbol* signature, const char* path, bool overwrite, TRAPS) {
1123   ResourceMark rm(THREAD);
1124   HandleMark hm(THREAD);
1125 
1126   Handle h_path = java_lang_String::create_from_str(path, CHECK);
1127 
1128   Symbol* sym = vmSymbols::jdk_internal_vm_ThreadDumper();
1129   Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK);

1130   if (HAS_PENDING_EXCEPTION) {
1131     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1132     output()->cr();
1133     CLEAR_PENDING_EXCEPTION;
1134     return;
1135   }
1136 
1137   // invoke the ThreadDump method to dump to file
1138   JavaValue result(T_OBJECT);
1139   JavaCallArguments args;
1140   args.push_oop(h_path);
1141   args.push_int(overwrite ? JNI_TRUE : JNI_FALSE);
1142   JavaCalls::call_static(&result,
1143                          k,
1144                          name,
1145                          signature,
1146                          &args,
1147                          THREAD);
1148   if (HAS_PENDING_EXCEPTION) {
1149     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1150     output()->cr();
1151     CLEAR_PENDING_EXCEPTION;
1152     return;
1153   }
1154 
1155   // check that result is byte array
1156   oop res = cast_to_oop(result.get_jobject());
1157   assert(res->is_typeArray(), "just checking");
1158   assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
1159 
1160   // copy the bytes to the output stream
1161   typeArrayOop ba = typeArrayOop(res);
1162   jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
1163   output()->print_raw((const char*)addr, ba->length());
1164 }
1165 
1166 void VThreadSchedulerDCmd::execute(DCmdSource source, TRAPS) {
1167   ResourceMark rm(THREAD);
1168   HandleMark hm(THREAD);
1169 
1170   Symbol* sym = vmSymbols::java_lang_VirtualThread();
1171   Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK);
1172   if (HAS_PENDING_EXCEPTION) {
1173     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1174     output()->cr();
1175     CLEAR_PENDING_EXCEPTION;
1176     return;
1177   }
1178 
1179   // invoke printDefaultScheduler method
1180   JavaValue result(T_OBJECT);
1181   JavaCallArguments args;
1182   JavaCalls::call_static(&result,
1183                          k,
1184                          vmSymbols::printDefaultScheduler_name(),
1185                          vmSymbols::void_byte_array_signature(),
1186                          &args,
1187                          THREAD);
1188   if (HAS_PENDING_EXCEPTION) {
1189     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1190     output()->cr();
1191     CLEAR_PENDING_EXCEPTION;
1192     return;
1193   }
1194 
1195   // check that result is byte array
1196   oop res = cast_to_oop(result.get_jobject());
1197   assert(res->is_typeArray(), "just checking");
1198   assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
1199 
1200   // copy the bytes to the output stream
1201   typeArrayOop ba = typeArrayOop(res);
1202   jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
1203   output()->print_raw((const char*)addr, ba->length());
1204 }
1205 
1206 CompilationMemoryStatisticDCmd::CompilationMemoryStatisticDCmd(outputStream* output, bool heap) :
1207     DCmdWithParser(output, heap),
1208   _human_readable("-H", "Human readable format", "BOOLEAN", false, "false"),
1209   _minsize("-s", "Minimum memory size", "MEMORY SIZE", false, "0") {
1210   _dcmdparser.add_dcmd_option(&_human_readable);
1211   _dcmdparser.add_dcmd_option(&_minsize);
1212 }
1213 
1214 void CompilationMemoryStatisticDCmd::execute(DCmdSource source, TRAPS) {
1215   const bool human_readable = _human_readable.value();
1216   const size_t minsize = _minsize.has_value() ? _minsize.value()._size : 0;
1217   CompilationMemoryStatistic::print_all_by_size(output(), human_readable, minsize);
1218 }
1219 
1220 #ifdef LINUX
1221 
1222 SystemMapDCmd::SystemMapDCmd(outputStream* output, bool heap) :
1223     DCmdWithParser(output, heap),
1224   _human_readable("-H", "Human readable format", "BOOLEAN", false, "false") {
1225   _dcmdparser.add_dcmd_option(&_human_readable);
< prev index next >