< prev index next >

src/hotspot/share/services/diagnosticCommand.cpp

Print this page

 112   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
 113 #if INCLUDE_SERVICES
 114   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
 115   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
 116   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDictionaryDCmd>(full_export, true, false));
 117   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
 118   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassesDCmd>(full_export, true, false));
 119   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
 120   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
 121   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<metaspace::MetaspaceDCmd>(full_export, true, false));
 122   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<EventLogDCmd>(full_export, true, false));
 123 #if INCLUDE_JVMTI // Both JVMTI and SERVICES have to be enabled to have this dcmd
 124   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export, true, false));
 125 #endif // INCLUDE_JVMTI
 126 #endif // INCLUDE_SERVICES
 127 #if INCLUDE_JVMTI
 128   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(full_export, true, false));
 129 #endif // INCLUDE_JVMTI
 130   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
 131   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpToFileDCmd>(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   InstanceKlass* ik = InstanceKlass::cast(k);
1131   if (HAS_PENDING_EXCEPTION) {
1132     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1133     output()->cr();
1134     CLEAR_PENDING_EXCEPTION;
1135     return;
1136   }
1137 
1138   // invoke the ThreadDump method to dump to file
1139   JavaValue result(T_OBJECT);
1140   JavaCallArguments args;
1141   args.push_oop(h_path);
1142   args.push_int(overwrite ? JNI_TRUE : JNI_FALSE);
1143   JavaCalls::call_static(&result,
1144                          k,
1145                          name,
1146                          signature,
1147                          &args,
1148                          THREAD);
1149   if (HAS_PENDING_EXCEPTION) {
1150     java_lang_Throwable::print(PENDING_EXCEPTION, output());
1151     output()->cr();
1152     CLEAR_PENDING_EXCEPTION;
1153     return;
1154   }
1155 
1156   // check that result is byte array
1157   oop res = cast_to_oop(result.get_jobject());
1158   assert(res->is_typeArray(), "just checking");
1159   assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
1160 
1161   // copy the bytes to the output stream
1162   typeArrayOop ba = typeArrayOop(res);
1163   jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
1164   output()->print_raw((const char*)addr, ba->length());
1165 }
1166 








































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

 112   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
 113 #if INCLUDE_SERVICES
 114   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
 115   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
 116   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemDictionaryDCmd>(full_export, true, false));
 117   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
 118   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassesDCmd>(full_export, true, false));
 119   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
 120   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
 121   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<metaspace::MetaspaceDCmd>(full_export, true, false));
 122   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<EventLogDCmd>(full_export, true, false));
 123 #if INCLUDE_JVMTI // Both JVMTI and SERVICES have to be enabled to have this dcmd
 124   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export, true, false));
 125 #endif // INCLUDE_JVMTI
 126 #endif // INCLUDE_SERVICES
 127 #if INCLUDE_JVMTI
 128   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(full_export, true, false));
 129 #endif // INCLUDE_JVMTI
 130   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
 131   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpToFileDCmd>(full_export, true, false));
 132   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VThreadSummaryDCmd>(full_export, true, false));
 133   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
 134   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderHierarchyDCmd>(full_export, true, false));
 135   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false));
 136   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false));
 137   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false));
 138 #ifdef LINUX
 139   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PerfMapDCmd>(full_export, true, false));
 140   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<TrimCLibcHeapDCmd>(full_export, true, false));
 141   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<MallocInfoDcmd>(full_export, true, false));
 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
 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));
 151   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilationMemoryStatisticDCmd>(full_export, true, false));
 152 

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

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