comparison src/share/vm/services/diagnosticCommand.cpp @ 7956:16fb9f942703

6479360: PrintClassHistogram improvements Summary: jcmd <pid> GC.class_stats (UnlockDiagnosticVMOptions) Reviewed-by: coleenp, hseigel, sla, acorn Contributed-by: ioi.lam@oracle.com
author acorn
date Fri, 25 Jan 2013 15:06:18 -0500
parents 9855b7e559ae
children 8f696cf1a0fb
comparison
equal deleted inserted replaced
7950:6cf2530f7fd3 7956:16fb9f942703
1 /* 1 /*
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
41 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(true, false)); 41 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(true, false));
42 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(true, false)); 42 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(true, false));
43 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(true, false)); 43 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(true, false));
44 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(true, false)); 44 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(true, false));
45 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(true, false)); 45 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(true, false));
46 #if INCLUDE_SERVICES // Heap dumping supported 46 #if INCLUDE_SERVICES // Heap dumping/inspection supported
47 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(true, false)); 47 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(true, false));
48 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(true, false));
49 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(true, false));
48 #endif // INCLUDE_SERVICES 50 #endif // INCLUDE_SERVICES
49 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(true, false));
50 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(true, false)); 51 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(true, false));
51
52 //Enhanced JMX Agent Support 52 //Enhanced JMX Agent Support
53 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(true,false)); 53 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(true,false));
54 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(true,false)); 54 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(true,false));
55 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(true,false)); 55 DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(true,false));
56 56
250 JavaCalls::call_static(&result, klass, 250 JavaCalls::call_static(&result, klass,
251 vmSymbols::run_finalization_name(), 251 vmSymbols::run_finalization_name(),
252 vmSymbols::void_method_signature(), CHECK); 252 vmSymbols::void_method_signature(), CHECK);
253 } 253 }
254 254
255 #if INCLUDE_SERVICES // Heap dumping supported 255 #if INCLUDE_SERVICES // Heap dumping/inspection supported
256 HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) : 256 HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) :
257 DCmdWithParser(output, heap), 257 DCmdWithParser(output, heap),
258 _filename("filename","Name of the dump file", "STRING",true), 258 _filename("filename","Name of the dump file", "STRING",true),
259 _all("-all", "Dump all objects, including unreachable objects", 259 _all("-all", "Dump all objects, including unreachable objects",
260 "BOOLEAN", false, "false") { 260 "BOOLEAN", false, "false") {
290 return dcmd->_dcmdparser.num_arguments(); 290 return dcmd->_dcmdparser.num_arguments();
291 } else { 291 } else {
292 return 0; 292 return 0;
293 } 293 }
294 } 294 }
295 #endif // INCLUDE_SERVICES
296 295
297 ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) : 296 ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) :
298 DCmdWithParser(output, heap), 297 DCmdWithParser(output, heap),
299 _all("-all", "Inspect all objects, including unreachable objects", 298 _all("-all", "Inspect all objects, including unreachable objects",
300 "BOOLEAN", false, "false") { 299 "BOOLEAN", false, "false") {
316 return dcmd->_dcmdparser.num_arguments(); 315 return dcmd->_dcmdparser.num_arguments();
317 } else { 316 } else {
318 return 0; 317 return 0;
319 } 318 }
320 } 319 }
320
321 #define DEFAULT_COLUMNS "InstBytes,KlassBytes,CpAll,annotations,MethodCount,Bytecodes,MethodAll,ROAll,RWAll,Total"
322 ClassStatsDCmd::ClassStatsDCmd(outputStream* output, bool heap) :
323 DCmdWithParser(output, heap),
324 _csv("-csv", "Print in CSV (comma-separated values) format for spreadsheets",
325 "BOOLEAN", false, "false"),
326 _all("-all", "Show all columns",
327 "BOOLEAN", false, "false"),
328 _help("-help", "Show meaning of all the columns",
329 "BOOLEAN", false, "false"),
330 _columns("columns", "Comma-separated list of all the columns to show. "
331 "If not specified, the following columns are shown: " DEFAULT_COLUMNS,
332 "STRING", false) {
333 _dcmdparser.add_dcmd_option(&_all);
334 _dcmdparser.add_dcmd_option(&_csv);
335 _dcmdparser.add_dcmd_option(&_help);
336 _dcmdparser.add_dcmd_argument(&_columns);
337 }
338
339 void ClassStatsDCmd::execute(TRAPS) {
340 if (!UnlockDiagnosticVMOptions) {
341 output()->print_cr("GC.class_stats command requires -XX:+UnlockDiagnosticVMOptions");
342 return;
343 }
344
345 VM_GC_HeapInspection heapop(output(),
346 true, /* request_full_gc */
347 true /* need_prologue */);
348 heapop.set_csv_format(_csv.value());
349 heapop.set_print_help(_help.value());
350 heapop.set_print_class_stats(true);
351 if (_all.value()) {
352 if (_columns.has_value()) {
353 output()->print_cr("Cannot specify -all and individual columns at the same time");
354 return;
355 } else {
356 heapop.set_columns(NULL);
357 }
358 } else {
359 if (_columns.has_value()) {
360 heapop.set_columns(_columns.value());
361 } else {
362 heapop.set_columns(DEFAULT_COLUMNS);
363 }
364 }
365 VMThread::execute(&heapop);
366 }
367
368 int ClassStatsDCmd::num_arguments() {
369 ResourceMark rm;
370 ClassStatsDCmd* dcmd = new ClassStatsDCmd(NULL, false);
371 if (dcmd != NULL) {
372 DCmdMark mark(dcmd);
373 return dcmd->_dcmdparser.num_arguments();
374 } else {
375 return 0;
376 }
377 }
378 #endif // INCLUDE_SERVICES
321 379
322 ThreadDumpDCmd::ThreadDumpDCmd(outputStream* output, bool heap) : 380 ThreadDumpDCmd::ThreadDumpDCmd(outputStream* output, bool heap) :
323 DCmdWithParser(output, heap), 381 DCmdWithParser(output, heap),
324 _locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false") { 382 _locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false") {
325 _dcmdparser.add_dcmd_option(&_locks); 383 _dcmdparser.add_dcmd_option(&_locks);