< 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 

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








































1147 CompilationMemoryStatisticDCmd::CompilationMemoryStatisticDCmd(outputStream* output, bool heap) :
1148     DCmdWithParser(output, heap),
1149   _human_readable("-H", "Human readable format", "BOOLEAN", false, "false"),
1150   _minsize("-s", "Minimum memory size", "MEMORY SIZE", false, "0") {
1151   _dcmdparser.add_dcmd_option(&_human_readable);
1152   _dcmdparser.add_dcmd_option(&_minsize);
1153 }
1154 
1155 void CompilationMemoryStatisticDCmd::execute(DCmdSource source, TRAPS) {
1156   const bool human_readable = _human_readable.value();
1157   const size_t minsize = _minsize.has_value() ? _minsize.value()._size : 0;
1158   CompilationMemoryStatistic::print_all_by_size(output(), human_readable, minsize);
1159 }
1160 
1161 #ifdef LINUX
1162 
1163 SystemMapDCmd::SystemMapDCmd(outputStream* output, bool heap) :
1164     DCmdWithParser(output, heap),
1165   _human_readable("-H", "Human readable format", "BOOLEAN", false, "false") {
1166   _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 

1091   _dcmdparser.add_dcmd_option(&_format);
1092   _dcmdparser.add_dcmd_argument(&_filepath);
1093 }
1094 
1095 void ThreadDumpToFileDCmd::execute(DCmdSource source, TRAPS) {
1096   bool json = (_format.value() != nullptr) && (strcmp(_format.value(), "json") == 0);
1097   char* path = _filepath.value();
1098   bool overwrite = _overwrite.value();
1099   Symbol* name = (json) ? vmSymbols::dumpThreadsToJson_name() : vmSymbols::dumpThreads_name();
1100   dumpToFile(name, vmSymbols::string_bool_byte_array_signature(), path, overwrite, CHECK);
1101 }
1102 
1103 void ThreadDumpToFileDCmd::dumpToFile(Symbol* name, Symbol* signature, const char* path, bool overwrite, TRAPS) {
1104   ResourceMark rm(THREAD);
1105   HandleMark hm(THREAD);
1106 
1107   Handle h_path = java_lang_String::create_from_str(path, CHECK);
1108 
1109   Symbol* sym = vmSymbols::jdk_internal_vm_ThreadDumper();
1110   Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK);

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