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<CompilerDirectivesReplaceDCmd>(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));
1170 _dcmdparser.add_dcmd_option(&_format);
1171 _dcmdparser.add_dcmd_argument(&_filepath);
1172 }
1173
1174 void ThreadDumpToFileDCmd::execute(DCmdSource source, TRAPS) {
1175 bool json = (_format.value() != nullptr) && (strcmp(_format.value(), "json") == 0);
1176 char* path = _filepath.value();
1177 bool overwrite = _overwrite.value();
1178 Symbol* name = (json) ? vmSymbols::dumpThreadsToJson_name() : vmSymbols::dumpThreads_name();
1179 dumpToFile(name, vmSymbols::string_bool_byte_array_signature(), path, overwrite, CHECK);
1180 }
1181
1182 void ThreadDumpToFileDCmd::dumpToFile(Symbol* name, Symbol* signature, const char* path, bool overwrite, TRAPS) {
1183 ResourceMark rm(THREAD);
1184 HandleMark hm(THREAD);
1185
1186 Handle h_path = java_lang_String::create_from_str(path, CHECK);
1187
1188 Symbol* sym = vmSymbols::jdk_internal_vm_ThreadDumper();
1189 Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK);
1190 InstanceKlass* ik = InstanceKlass::cast(k);
1191 if (HAS_PENDING_EXCEPTION) {
1192 java_lang_Throwable::print(PENDING_EXCEPTION, output());
1193 output()->cr();
1194 CLEAR_PENDING_EXCEPTION;
1195 return;
1196 }
1197
1198 // invoke the ThreadDump method to dump to file
1199 JavaValue result(T_OBJECT);
1200 JavaCallArguments args;
1201 args.push_oop(h_path);
1202 args.push_int(overwrite ? JNI_TRUE : JNI_FALSE);
1203 JavaCalls::call_static(&result,
1204 k,
1205 name,
1206 signature,
1207 &args,
1208 THREAD);
1209 if (HAS_PENDING_EXCEPTION) {
1210 java_lang_Throwable::print(PENDING_EXCEPTION, output());
1211 output()->cr();
1212 CLEAR_PENDING_EXCEPTION;
1213 return;
1214 }
1215
1216 // check that result is byte array
1217 oop res = cast_to_oop(result.get_jobject());
1218 assert(res->is_typeArray(), "just checking");
1219 assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
1220
1221 // copy the bytes to the output stream
1222 typeArrayOop ba = typeArrayOop(res);
1223 jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
1224 output()->print_raw((const char*)addr, ba->length());
1225 }
1226
1227 CompilationMemoryStatisticDCmd::CompilationMemoryStatisticDCmd(outputStream* output, bool heap) :
1228 DCmdWithParser(output, heap),
1229 _human_readable("-H", "Human readable format", "BOOLEAN", false, "false"),
1230 _minsize("-s", "Minimum memory size", "MEMORY SIZE", false, "0") {
1231 _dcmdparser.add_dcmd_option(&_human_readable);
1232 _dcmdparser.add_dcmd_option(&_minsize);
1233 }
1234
1235 void CompilationMemoryStatisticDCmd::execute(DCmdSource source, TRAPS) {
1236 const bool human_readable = _human_readable.value();
1237 const size_t minsize = _minsize.has_value() ? _minsize.value()._size : 0;
1238 CompilationMemoryStatistic::print_all_by_size(output(), human_readable, minsize);
1239 }
1240
1241 #ifdef LINUX
1242
1243 SystemMapDCmd::SystemMapDCmd(outputStream* output, bool heap) :
1244 DCmdWithParser(output, heap),
1245 _human_readable("-H", "Human readable format", "BOOLEAN", false, "false") {
1246 _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<CompilerDirectivesReplaceDCmd>(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));
1171 _dcmdparser.add_dcmd_option(&_format);
1172 _dcmdparser.add_dcmd_argument(&_filepath);
1173 }
1174
1175 void ThreadDumpToFileDCmd::execute(DCmdSource source, TRAPS) {
1176 bool json = (_format.value() != nullptr) && (strcmp(_format.value(), "json") == 0);
1177 char* path = _filepath.value();
1178 bool overwrite = _overwrite.value();
1179 Symbol* name = (json) ? vmSymbols::dumpThreadsToJson_name() : vmSymbols::dumpThreads_name();
1180 dumpToFile(name, vmSymbols::string_bool_byte_array_signature(), path, overwrite, CHECK);
1181 }
1182
1183 void ThreadDumpToFileDCmd::dumpToFile(Symbol* name, Symbol* signature, const char* path, bool overwrite, TRAPS) {
1184 ResourceMark rm(THREAD);
1185 HandleMark hm(THREAD);
1186
1187 Handle h_path = java_lang_String::create_from_str(path, CHECK);
1188
1189 Symbol* sym = vmSymbols::jdk_internal_vm_ThreadDumper();
1190 Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK);
1191 if (HAS_PENDING_EXCEPTION) {
1192 java_lang_Throwable::print(PENDING_EXCEPTION, output());
1193 output()->cr();
1194 CLEAR_PENDING_EXCEPTION;
1195 return;
1196 }
1197
1198 // invoke the ThreadDump method to dump to file
1199 JavaValue result(T_OBJECT);
1200 JavaCallArguments args;
1201 args.push_oop(h_path);
1202 args.push_int(overwrite ? JNI_TRUE : JNI_FALSE);
1203 JavaCalls::call_static(&result,
1204 k,
1205 name,
1206 signature,
1207 &args,
1208 THREAD);
1209 if (HAS_PENDING_EXCEPTION) {
1210 java_lang_Throwable::print(PENDING_EXCEPTION, output());
1211 output()->cr();
1212 CLEAR_PENDING_EXCEPTION;
1213 return;
1214 }
1215
1216 // check that result is byte array
1217 oop res = cast_to_oop(result.get_jobject());
1218 assert(res->is_typeArray(), "just checking");
1219 assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
1220
1221 // copy the bytes to the output stream
1222 typeArrayOop ba = typeArrayOop(res);
1223 jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
1224 output()->print_raw((const char*)addr, ba->length());
1225 }
1226
1227 void VThreadSchedulerDCmd::execute(DCmdSource source, TRAPS) {
1228 ResourceMark rm(THREAD);
1229 HandleMark hm(THREAD);
1230
1231 Symbol* sym = vmSymbols::java_lang_VirtualThread();
1232 Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK);
1233 if (HAS_PENDING_EXCEPTION) {
1234 java_lang_Throwable::print(PENDING_EXCEPTION, output());
1235 output()->cr();
1236 CLEAR_PENDING_EXCEPTION;
1237 return;
1238 }
1239
1240 // invoke printDefaultScheduler method
1241 JavaValue result(T_OBJECT);
1242 JavaCallArguments args;
1243 JavaCalls::call_static(&result,
1244 k,
1245 vmSymbols::printDefaultScheduler_name(),
1246 vmSymbols::void_byte_array_signature(),
1247 &args,
1248 THREAD);
1249 if (HAS_PENDING_EXCEPTION) {
1250 java_lang_Throwable::print(PENDING_EXCEPTION, output());
1251 output()->cr();
1252 CLEAR_PENDING_EXCEPTION;
1253 return;
1254 }
1255
1256 // check that result is byte array
1257 oop res = cast_to_oop(result.get_jobject());
1258 assert(res->is_typeArray(), "just checking");
1259 assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
1260
1261 // copy the bytes to the output stream
1262 typeArrayOop ba = typeArrayOop(res);
1263 jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
1264 output()->print_raw((const char*)addr, ba->length());
1265 }
1266
1267 CompilationMemoryStatisticDCmd::CompilationMemoryStatisticDCmd(outputStream* output, bool heap) :
1268 DCmdWithParser(output, heap),
1269 _human_readable("-H", "Human readable format", "BOOLEAN", false, "false"),
1270 _minsize("-s", "Minimum memory size", "MEMORY SIZE", false, "0") {
1271 _dcmdparser.add_dcmd_option(&_human_readable);
1272 _dcmdparser.add_dcmd_option(&_minsize);
1273 }
1274
1275 void CompilationMemoryStatisticDCmd::execute(DCmdSource source, TRAPS) {
1276 const bool human_readable = _human_readable.value();
1277 const size_t minsize = _minsize.has_value() ? _minsize.value()._size : 0;
1278 CompilationMemoryStatistic::print_all_by_size(output(), human_readable, minsize);
1279 }
1280
1281 #ifdef LINUX
1282
1283 SystemMapDCmd::SystemMapDCmd(outputStream* output, bool heap) :
1284 DCmdWithParser(output, heap),
1285 _human_readable("-H", "Human readable format", "BOOLEAN", false, "false") {
1286 _dcmdparser.add_dcmd_option(&_human_readable);
|