54 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false));
55 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false));
56 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SetVMFlagDCmd>(full_export, true, false));
57 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMDynamicLibrariesDCmd>(full_export, true, false));
58 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false));
59 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMInfoDCmd>(full_export, true, false));
60 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false));
61 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false));
62 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapInfoDCmd>(full_export, true, false));
63 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
64 #if INCLUDE_SERVICES // Heap dumping/inspection supported
65 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
66 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
67 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));
68 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
69 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
70 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
71 #endif // INCLUDE_SERVICES
72 #if INCLUDE_JVMTI
73 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(full_export, true, false));
74 #endif // INCLUDE_JVMTI
75 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
76 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
77 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false));
78 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false));
79 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false));
80 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<TouchedMethodsDCmd>(full_export, true, false));
81
82 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesPrintDCmd>(full_export, true, false));
83 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesAddDCmd>(full_export, true, false));
84 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesRemoveDCmd>(full_export, true, false));
85 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesClearDCmd>(full_export, true, false));
86
87 // Enhanced JMX Agent Support
88 // These commands won't be exported via the DiagnosticCommandMBean until an
89 // appropriate permission is created for them
90 uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI;
91 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));
92 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));
93 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));
234
235 if (ret != Flag::SUCCESS) {
236 output()->print_cr("%s", err_msg.buffer());
237 }
238 }
239
240 int SetVMFlagDCmd::num_arguments() {
241 ResourceMark rm;
242 SetVMFlagDCmd* dcmd = new SetVMFlagDCmd(NULL, false);
243 if (dcmd != NULL) {
244 DCmdMark mark(dcmd);
245 return dcmd->_dcmdparser.num_arguments();
246 } else {
247 return 0;
248 }
249 }
250
251 void JVMTIDataDumpDCmd::execute(DCmdSource source, TRAPS) {
252 if (JvmtiExport::should_post_data_dump()) {
253 JvmtiExport::post_data_dump();
254 }
255 }
256
257 void PrintSystemPropertiesDCmd::execute(DCmdSource source, TRAPS) {
258 // load sun.misc.VMSupport
259 Symbol* klass = vmSymbols::sun_misc_VMSupport();
260 Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK);
261 instanceKlassHandle ik (THREAD, k);
262 if (ik->should_be_initialized()) {
263 ik->initialize(THREAD);
264 }
265 if (HAS_PENDING_EXCEPTION) {
266 java_lang_Throwable::print(PENDING_EXCEPTION, output());
267 output()->cr();
268 CLEAR_PENDING_EXCEPTION;
269 return;
270 }
271
272 // invoke the serializePropertiesToByteArray method
273 JavaValue result(T_OBJECT);
|
54 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(full_export, true, false));
55 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(full_export, true, false));
56 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SetVMFlagDCmd>(full_export, true, false));
57 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMDynamicLibrariesDCmd>(full_export, true, false));
58 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(full_export, true, false));
59 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMInfoDCmd>(full_export, true, false));
60 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(full_export, true, false));
61 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(full_export, true, false));
62 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapInfoDCmd>(full_export, true, false));
63 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<FinalizerInfoDCmd>(full_export, true, false));
64 #if INCLUDE_SERVICES // Heap dumping/inspection supported
65 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(DCmd_Source_Internal | DCmd_Source_AttachAPI, true, false));
66 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(full_export, true, false));
67 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(full_export, true, false));
68 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHierarchyDCmd>(full_export, true, false));
69 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SymboltableDCmd>(full_export, true, false));
70 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<StringtableDCmd>(full_export, true, false));
71 #endif // INCLUDE_SERVICES
72 #if INCLUDE_JVMTI
73 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIDataDumpDCmd>(full_export, true, false));
74 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JVMTIAgentLoadDCmd>(full_export, true, false));
75 #endif // INCLUDE_JVMTI
76 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
77 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
78 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompileQueueDCmd>(full_export, true, false));
79 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeListDCmd>(full_export, true, false));
80 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CodeCacheDCmd>(full_export, true, false));
81 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<TouchedMethodsDCmd>(full_export, true, false));
82
83 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesPrintDCmd>(full_export, true, false));
84 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesAddDCmd>(full_export, true, false));
85 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesRemoveDCmd>(full_export, true, false));
86 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CompilerDirectivesClearDCmd>(full_export, true, false));
87
88 // Enhanced JMX Agent Support
89 // These commands won't be exported via the DiagnosticCommandMBean until an
90 // appropriate permission is created for them
91 uint32_t jmx_agent_export_flags = DCmd_Source_Internal | DCmd_Source_AttachAPI;
92 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(jmx_agent_export_flags, true,false));
93 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(jmx_agent_export_flags, true,false));
94 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(jmx_agent_export_flags, true,false));
235
236 if (ret != Flag::SUCCESS) {
237 output()->print_cr("%s", err_msg.buffer());
238 }
239 }
240
241 int SetVMFlagDCmd::num_arguments() {
242 ResourceMark rm;
243 SetVMFlagDCmd* dcmd = new SetVMFlagDCmd(NULL, false);
244 if (dcmd != NULL) {
245 DCmdMark mark(dcmd);
246 return dcmd->_dcmdparser.num_arguments();
247 } else {
248 return 0;
249 }
250 }
251
252 void JVMTIDataDumpDCmd::execute(DCmdSource source, TRAPS) {
253 if (JvmtiExport::should_post_data_dump()) {
254 JvmtiExport::post_data_dump();
255 }
256 }
257
258 JVMTIAgentLoadDCmd::JVMTIAgentLoadDCmd(outputStream* output, bool heap) :
259 DCmdWithParser(output, heap),
260 _libpath("library path", "Absolute path of the JVMTI agent to load.",
261 "STRING", true),
262 _option("agent option", "Option string to pass the agent.", "STRING", false) {
263 _dcmdparser.add_dcmd_argument(&_libpath);
264 _dcmdparser.add_dcmd_argument(&_option);
265 }
266
267 void JVMTIAgentLoadDCmd::execute(DCmdSource source, TRAPS) {
268
269 if (_libpath.value() == NULL) {
270 output()->print_cr("JVMTI.agent_load dcmd needs library path.");
271 return;
272 }
273
274 char *suffix = strrchr(_libpath.value(), '.');
275 bool is_java_agent = (suffix != NULL) && (strncmp(".jar", suffix, 4) == 0);
276
277 if (is_java_agent) {
278 if (_option.value() == NULL) {
279 JvmtiExport::load_agent_library("instrument", "false",
280 _libpath.value(), output());
281 } else {
282 int opt_len = strlen(_libpath.value()) + strlen(_option.value()) + 2;
283 char opt[opt_len];
284 snprintf(opt, opt_len, "%s=%s", _libpath.value(), _option.value());
285 JvmtiExport::load_agent_library("instrument", "false", opt, output());
286 }
287 } else {
288 JvmtiExport::load_agent_library(_libpath.value(), "true",
289 _option.value(), output());
290 }
291 }
292
293 int JVMTIAgentLoadDCmd::num_arguments() {
294 ResourceMark rm;
295 JVMTIAgentLoadDCmd* dcmd = new JVMTIAgentLoadDCmd(NULL, false);
296 if (dcmd != NULL) {
297 DCmdMark mark(dcmd);
298 return dcmd->_dcmdparser.num_arguments();
299 } else {
300 return 0;
301 }
302 }
303
304 void PrintSystemPropertiesDCmd::execute(DCmdSource source, TRAPS) {
305 // load sun.misc.VMSupport
306 Symbol* klass = vmSymbols::sun_misc_VMSupport();
307 Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK);
308 instanceKlassHandle ik (THREAD, k);
309 if (ik->should_be_initialized()) {
310 ik->initialize(THREAD);
311 }
312 if (HAS_PENDING_EXCEPTION) {
313 java_lang_Throwable::print(PENDING_EXCEPTION, output());
314 output()->cr();
315 CLEAR_PENDING_EXCEPTION;
316 return;
317 }
318
319 // invoke the serializePropertiesToByteArray method
320 JavaValue result(T_OBJECT);
|