src/share/vm/services/diagnosticCommand.cpp

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>


 303 int HeapDumpDCmd::num_arguments() {
 304   ResourceMark rm;
 305   HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false);
 306   if (dcmd != NULL) {
 307     DCmdMark mark(dcmd);
 308     return dcmd->_dcmdparser.num_arguments();
 309   } else {
 310     return 0;
 311   }
 312 }
 313 
 314 ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) :
 315                                        DCmdWithParser(output, heap),
 316   _all("-all", "Inspect all objects, including unreachable objects",
 317        "BOOLEAN", false, "false") {
 318   _dcmdparser.add_dcmd_option(&_all);
 319 }
 320 
 321 void ClassHistogramDCmd::execute(DCmdSource source, TRAPS) {
 322   VM_GC_HeapInspection heapop(output(),
 323                               !_all.value() /* request full gc if false */,
 324                               true /* need_prologue */);
 325   VMThread::execute(&heapop);
 326 }
 327 
 328 int ClassHistogramDCmd::num_arguments() {
 329   ResourceMark rm;
 330   ClassHistogramDCmd* dcmd = new ClassHistogramDCmd(NULL, false);
 331   if (dcmd != NULL) {
 332     DCmdMark mark(dcmd);
 333     return dcmd->_dcmdparser.num_arguments();
 334   } else {
 335     return 0;
 336   }
 337 }
 338 
 339 #define DEFAULT_COLUMNS "InstBytes,KlassBytes,CpAll,annotations,MethodCount,Bytecodes,MethodAll,ROAll,RWAll,Total"
 340 ClassStatsDCmd::ClassStatsDCmd(outputStream* output, bool heap) :
 341                                        DCmdWithParser(output, heap),
 342   _csv("-csv", "Print in CSV (comma-separated values) format for spreadsheets",
 343        "BOOLEAN", false, "false"),
 344   _all("-all", "Show all columns",
 345        "BOOLEAN", false, "false"),
 346   _help("-help", "Show meaning of all the columns",
 347        "BOOLEAN", false, "false"),
 348   _columns("columns", "Comma-separated list of all the columns to show. "
 349            "If not specified, the following columns are shown: " DEFAULT_COLUMNS,
 350            "STRING", false) {
 351   _dcmdparser.add_dcmd_option(&_all);
 352   _dcmdparser.add_dcmd_option(&_csv);
 353   _dcmdparser.add_dcmd_option(&_help);
 354   _dcmdparser.add_dcmd_argument(&_columns);
 355 }
 356 
 357 void ClassStatsDCmd::execute(DCmdSource source, TRAPS) {
 358   if (!UnlockDiagnosticVMOptions) {
 359     output()->print_cr("GC.class_stats command requires -XX:+UnlockDiagnosticVMOptions");
 360     return;
 361   }
 362 
 363   VM_GC_HeapInspection heapop(output(),
 364                               true, /* request_full_gc */
 365                               true /* need_prologue */);
 366   heapop.set_csv_format(_csv.value());
 367   heapop.set_print_help(_help.value());
 368   heapop.set_print_class_stats(true);
 369   if (_all.value()) {
 370     if (_columns.has_value()) {
 371       output()->print_cr("Cannot specify -all and individual columns at the same time");
 372       return;
 373     } else {
 374       heapop.set_columns(NULL);
 375     }
 376   } else {
 377     if (_columns.has_value()) {
 378       heapop.set_columns(_columns.value());
 379     } else {
 380       heapop.set_columns(DEFAULT_COLUMNS);
 381     }
 382   }
 383   VMThread::execute(&heapop);
 384 }
 385 




 303 int HeapDumpDCmd::num_arguments() {
 304   ResourceMark rm;
 305   HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false);
 306   if (dcmd != NULL) {
 307     DCmdMark mark(dcmd);
 308     return dcmd->_dcmdparser.num_arguments();
 309   } else {
 310     return 0;
 311   }
 312 }
 313 
 314 ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) :
 315                                        DCmdWithParser(output, heap),
 316   _all("-all", "Inspect all objects, including unreachable objects",
 317        "BOOLEAN", false, "false") {
 318   _dcmdparser.add_dcmd_option(&_all);
 319 }
 320 
 321 void ClassHistogramDCmd::execute(DCmdSource source, TRAPS) {
 322   VM_GC_HeapInspection heapop(output(),
 323                               !_all.value() /* request full gc if false */);

 324   VMThread::execute(&heapop);
 325 }
 326 
 327 int ClassHistogramDCmd::num_arguments() {
 328   ResourceMark rm;
 329   ClassHistogramDCmd* dcmd = new ClassHistogramDCmd(NULL, false);
 330   if (dcmd != NULL) {
 331     DCmdMark mark(dcmd);
 332     return dcmd->_dcmdparser.num_arguments();
 333   } else {
 334     return 0;
 335   }
 336 }
 337 
 338 #define DEFAULT_COLUMNS "InstBytes,KlassBytes,CpAll,annotations,MethodCount,Bytecodes,MethodAll,ROAll,RWAll,Total"
 339 ClassStatsDCmd::ClassStatsDCmd(outputStream* output, bool heap) :
 340                                        DCmdWithParser(output, heap),
 341   _csv("-csv", "Print in CSV (comma-separated values) format for spreadsheets",
 342        "BOOLEAN", false, "false"),
 343   _all("-all", "Show all columns",
 344        "BOOLEAN", false, "false"),
 345   _help("-help", "Show meaning of all the columns",
 346        "BOOLEAN", false, "false"),
 347   _columns("columns", "Comma-separated list of all the columns to show. "
 348            "If not specified, the following columns are shown: " DEFAULT_COLUMNS,
 349            "STRING", false) {
 350   _dcmdparser.add_dcmd_option(&_all);
 351   _dcmdparser.add_dcmd_option(&_csv);
 352   _dcmdparser.add_dcmd_option(&_help);
 353   _dcmdparser.add_dcmd_argument(&_columns);
 354 }
 355 
 356 void ClassStatsDCmd::execute(DCmdSource source, TRAPS) {
 357   if (!UnlockDiagnosticVMOptions) {
 358     output()->print_cr("GC.class_stats command requires -XX:+UnlockDiagnosticVMOptions");
 359     return;
 360   }
 361 
 362   VM_GC_HeapInspection heapop(output(),
 363                               true /* request_full_gc */);

 364   heapop.set_csv_format(_csv.value());
 365   heapop.set_print_help(_help.value());
 366   heapop.set_print_class_stats(true);
 367   if (_all.value()) {
 368     if (_columns.has_value()) {
 369       output()->print_cr("Cannot specify -all and individual columns at the same time");
 370       return;
 371     } else {
 372       heapop.set_columns(NULL);
 373     }
 374   } else {
 375     if (_columns.has_value()) {
 376       heapop.set_columns(_columns.value());
 377     } else {
 378       heapop.set_columns(DEFAULT_COLUMNS);
 379     }
 380   }
 381   VMThread::execute(&heapop);
 382 }
 383