< 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 #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));

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








































1157   // copy the bytes to the output stream
1158   typeArrayOop ba = typeArrayOop(res);
1159   jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
1160   output()->print_raw((const char*)addr, ba->length());
1161 }
1162 
1163 CompilationMemoryStatisticDCmd::CompilationMemoryStatisticDCmd(outputStream* output, bool heap) :
1164     DCmdWithParser(output, heap),
1165   _human_readable("-H", "Human readable format", "BOOLEAN", false, "false"),
1166   _minsize("-s", "Minimum memory size", "MEMORY SIZE", false, "0") {
1167   _dcmdparser.add_dcmd_option(&_human_readable);
1168   _dcmdparser.add_dcmd_option(&_minsize);
1169 }
1170 
1171 void CompilationMemoryStatisticDCmd::execute(DCmdSource source, TRAPS) {
1172   const bool human_readable = _human_readable.value();
1173   const size_t minsize = _minsize.has_value() ? _minsize.value()._size : 0;
1174   CompilationMemoryStatistic::print_all_by_size(output(), human_readable, minsize);
1175 }
1176 

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

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

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