1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * builtin-list.c 4 * 5 * Builtin list command: list all event types 6 * 7 * Copyright (C) 2009, Thomas Gleixner <tglx@linutronix.de> 8 * Copyright (C) 2008-2009, Red Hat Inc, Ingo Molnar <mingo@redhat.com> 9 * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com> 10 */ 11 #include "builtin.h" 12 13 #include "util/print-events.h" 14 #include "util/pmus.h" 15 #include "util/pmu.h" 16 #include "util/debug.h" 17 #include "util/metricgroup.h" 18 #include "util/pfm.h" 19 #include "util/string2.h" 20 #include "util/strlist.h" 21 #include "util/strbuf.h" 22 #include "util/tool_pmu.h" 23 #include <subcmd/pager.h> 24 #include <subcmd/parse-options.h> 25 #include <linux/zalloc.h> 26 #include <ctype.h> 27 #include <stdarg.h> 28 #include <stdio.h> 29 30 /** 31 * struct print_state - State and configuration passed to the default_print 32 * functions. 33 */ 34 struct print_state { 35 /** @fp: File to write output to. */ 36 FILE *fp; 37 /** 38 * @pmu_glob: Optionally restrict PMU and metric matching to PMU or 39 * debugfs subsystem name. 40 */ 41 char *pmu_glob; 42 /** @event_glob: Optional pattern matching glob. */ 43 char *event_glob; 44 /** @name_only: Print event or metric names only. */ 45 bool name_only; 46 /** @desc: Print the event or metric description. */ 47 bool desc; 48 /** @long_desc: Print longer event or metric description. */ 49 bool long_desc; 50 /** @deprecated: Print deprecated events or metrics. */ 51 bool deprecated; 52 /** 53 * @detailed: Print extra information on the perf event such as names 54 * and expressions used internally by events. 55 */ 56 bool detailed; 57 /** @metrics: Controls printing of metric and metric groups. */ 58 bool metrics; 59 /** @metricgroups: Controls printing of metric and metric groups. */ 60 bool metricgroups; 61 /** @last_topic: The last printed event topic. */ 62 char *last_topic; 63 /** @last_metricgroups: The last printed metric group. */ 64 char *last_metricgroups; 65 /** @visited_metrics: Metrics that are printed to avoid duplicates. */ 66 struct strlist *visited_metrics; 67 }; 68 69 static void default_print_start(void *ps) 70 { 71 struct print_state *print_state = ps; 72 73 if (!print_state->name_only && pager_in_use()) { 74 fprintf(print_state->fp, 75 "\nList of pre-defined events (to be used in -e or -M):\n\n"); 76 } 77 } 78 79 static void default_print_end(void *print_state __maybe_unused) {} 80 81 static const char *skip_spaces_or_commas(const char *str) 82 { 83 while (isspace(*str) || *str == ',') 84 ++str; 85 return str; 86 } 87 88 static void wordwrap(FILE *fp, const char *s, int start, int max, int corr) 89 { 90 int column = start; 91 int n; 92 bool saw_newline = false; 93 bool comma = false; 94 95 while (*s) { 96 int wlen = strcspn(s, " ,\t\n"); 97 const char *sep = comma ? "," : " "; 98 99 if ((column + wlen >= max && column > start) || saw_newline) { 100 fprintf(fp, comma ? ",\n%*s" : "\n%*s", start, ""); 101 column = start + corr; 102 } 103 if (column <= start) 104 sep = ""; 105 n = fprintf(fp, "%s%.*s", sep, wlen, s); 106 if (n <= 0) 107 break; 108 saw_newline = s[wlen] == '\n'; 109 s += wlen; 110 comma = s[0] == ','; 111 column += n; 112 s = skip_spaces_or_commas(s); 113 } 114 } 115 116 static void default_print_event(void *ps, const char *topic, const char *pmu_name, 117 const char *event_name, const char *event_alias, 118 const char *scale_unit __maybe_unused, 119 bool deprecated, const char *event_type_desc, 120 const char *desc, const char *long_desc, 121 const char *encoding_desc) 122 { 123 struct print_state *print_state = ps; 124 int pos; 125 FILE *fp = print_state->fp; 126 127 if (deprecated && !print_state->deprecated) 128 return; 129 130 if (print_state->pmu_glob && pmu_name && !strglobmatch(pmu_name, print_state->pmu_glob)) 131 return; 132 133 if (print_state->event_glob && 134 (!event_name || !strglobmatch(event_name, print_state->event_glob)) && 135 (!event_alias || !strglobmatch(event_alias, print_state->event_glob)) && 136 (!topic || !strglobmatch_nocase(topic, print_state->event_glob))) 137 return; 138 139 if (print_state->name_only) { 140 if (event_alias && strlen(event_alias)) 141 fprintf(fp, "%s ", event_alias); 142 else 143 fprintf(fp, "%s ", event_name); 144 return; 145 } 146 147 if (strcmp(print_state->last_topic, topic ?: "")) { 148 if (topic) 149 fprintf(fp, "\n%s:\n", topic); 150 zfree(&print_state->last_topic); 151 print_state->last_topic = strdup(topic ?: ""); 152 } 153 154 if (event_alias && strlen(event_alias)) 155 pos = fprintf(fp, " %s OR %s", event_name, event_alias); 156 else 157 pos = fprintf(fp, " %s", event_name); 158 159 if (!topic && event_type_desc) { 160 for (; pos < 53; pos++) 161 fputc(' ', fp); 162 fprintf(fp, "[%s]\n", event_type_desc); 163 } else 164 fputc('\n', fp); 165 166 if (long_desc && print_state->long_desc) 167 desc = long_desc; 168 169 if (desc && (print_state->desc || print_state->long_desc)) { 170 char *desc_with_unit = NULL; 171 int desc_len = -1; 172 173 if (pmu_name && strcmp(pmu_name, "default_core")) { 174 desc_len = strlen(desc); 175 desc_len = asprintf(&desc_with_unit, 176 desc_len > 0 && desc[desc_len - 1] != '.' 177 ? "%s. Unit: %s" : "%s Unit: %s", 178 desc, pmu_name); 179 } 180 fprintf(fp, "%*s", 8, "["); 181 wordwrap(fp, desc_len > 0 ? desc_with_unit : desc, 8, pager_get_columns(), 0); 182 fprintf(fp, "]\n"); 183 free(desc_with_unit); 184 } 185 186 if (print_state->detailed && encoding_desc) { 187 fprintf(fp, "%*s", 8, ""); 188 wordwrap(fp, encoding_desc, 8, pager_get_columns(), 0); 189 fputc('\n', fp); 190 } 191 } 192 193 static void default_print_metric(void *ps, 194 const char *group, 195 const char *name, 196 const char *desc, 197 const char *long_desc, 198 const char *expr, 199 const char *threshold, 200 const char *unit __maybe_unused, 201 const char *pmu_name __maybe_unused) 202 { 203 struct print_state *print_state = ps; 204 FILE *fp = print_state->fp; 205 206 if (print_state->event_glob && 207 (!print_state->metrics || !name || !strglobmatch(name, print_state->event_glob)) && 208 (!print_state->metricgroups || !group || !strglobmatch(group, print_state->event_glob))) 209 return; 210 211 if (!print_state->name_only && !print_state->last_metricgroups) { 212 if (print_state->metricgroups) { 213 fprintf(fp, "\nMetric Groups:\n"); 214 if (!print_state->metrics) 215 fputc('\n', fp); 216 } else { 217 fprintf(fp, "\nMetrics:\n\n"); 218 } 219 } 220 if (!print_state->last_metricgroups || 221 strcmp(print_state->last_metricgroups, group ?: "")) { 222 if (group && print_state->metricgroups) { 223 if (print_state->name_only) { 224 fprintf(fp, "%s ", group); 225 } else { 226 const char *gdesc = print_state->desc 227 ? describe_metricgroup(group) 228 : NULL; 229 const char *print_colon = ""; 230 231 if (print_state->metrics) { 232 print_colon = ":"; 233 fputc('\n', fp); 234 } 235 236 if (gdesc) 237 fprintf(fp, "%s%s [%s]\n", group, print_colon, gdesc); 238 else 239 fprintf(fp, "%s%s\n", group, print_colon); 240 } 241 } 242 zfree(&print_state->last_metricgroups); 243 print_state->last_metricgroups = strdup(group ?: ""); 244 } 245 if (!print_state->metrics) 246 return; 247 248 if (print_state->name_only) { 249 if (print_state->metrics && 250 !strlist__has_entry(print_state->visited_metrics, name)) { 251 fprintf(fp, "%s ", name); 252 strlist__add(print_state->visited_metrics, name); 253 } 254 return; 255 } 256 fprintf(fp, " %s\n", name); 257 258 if (long_desc && print_state->long_desc) { 259 fprintf(fp, "%*s", 8, "["); 260 wordwrap(fp, long_desc, 8, pager_get_columns(), 0); 261 fprintf(fp, "]\n"); 262 } else if (desc && print_state->desc) { 263 fprintf(fp, "%*s", 8, "["); 264 wordwrap(fp, desc, 8, pager_get_columns(), 0); 265 fprintf(fp, "]\n"); 266 } 267 if (expr && print_state->detailed) { 268 fprintf(fp, "%*s", 8, "["); 269 wordwrap(fp, expr, 8, pager_get_columns(), 0); 270 fprintf(fp, "]\n"); 271 } 272 if (threshold && print_state->detailed) { 273 fprintf(fp, "%*s", 8, "["); 274 wordwrap(fp, threshold, 8, pager_get_columns(), 0); 275 fprintf(fp, "]\n"); 276 } 277 } 278 279 struct json_print_state { 280 /** @fp: File to write output to. */ 281 FILE *fp; 282 /** Should a separator be printed prior to the next item? */ 283 bool need_sep; 284 }; 285 286 static void json_print_start(void *ps) 287 { 288 struct json_print_state *print_state = ps; 289 FILE *fp = print_state->fp; 290 291 fprintf(fp, "[\n"); 292 } 293 294 static void json_print_end(void *ps) 295 { 296 struct json_print_state *print_state = ps; 297 FILE *fp = print_state->fp; 298 299 fprintf(fp, "%s]\n", print_state->need_sep ? "\n" : ""); 300 } 301 302 static void fix_escape_fprintf(FILE *fp, struct strbuf *buf, const char *fmt, ...) 303 { 304 va_list args; 305 306 va_start(args, fmt); 307 strbuf_setlen(buf, 0); 308 for (size_t fmt_pos = 0; fmt_pos < strlen(fmt); fmt_pos++) { 309 switch (fmt[fmt_pos]) { 310 case '%': 311 fmt_pos++; 312 switch (fmt[fmt_pos]) { 313 case 's': { 314 const char *s = va_arg(args, const char*); 315 316 strbuf_addstr(buf, s); 317 break; 318 } 319 case 'S': { 320 const char *s = va_arg(args, const char*); 321 322 for (size_t s_pos = 0; s_pos < strlen(s); s_pos++) { 323 switch (s[s_pos]) { 324 case '\n': 325 strbuf_addstr(buf, "\\n"); 326 break; 327 case '\r': 328 strbuf_addstr(buf, "\\r"); 329 break; 330 case '\\': 331 fallthrough; 332 case '\"': 333 strbuf_addch(buf, '\\'); 334 fallthrough; 335 default: 336 strbuf_addch(buf, s[s_pos]); 337 break; 338 } 339 } 340 break; 341 } 342 default: 343 pr_err("Unexpected format character '%c'\n", fmt[fmt_pos]); 344 strbuf_addch(buf, '%'); 345 strbuf_addch(buf, fmt[fmt_pos]); 346 } 347 break; 348 default: 349 strbuf_addch(buf, fmt[fmt_pos]); 350 break; 351 } 352 } 353 va_end(args); 354 fputs(buf->buf, fp); 355 } 356 357 static void json_print_event(void *ps, const char *topic, const char *pmu_name, 358 const char *event_name, const char *event_alias, 359 const char *scale_unit, 360 bool deprecated, const char *event_type_desc, 361 const char *desc, const char *long_desc, 362 const char *encoding_desc) 363 { 364 struct json_print_state *print_state = ps; 365 bool need_sep = false; 366 FILE *fp = print_state->fp; 367 struct strbuf buf; 368 369 strbuf_init(&buf, 0); 370 fprintf(fp, "%s{\n", print_state->need_sep ? ",\n" : ""); 371 print_state->need_sep = true; 372 if (pmu_name) { 373 fix_escape_fprintf(fp, &buf, "\t\"Unit\": \"%S\"", pmu_name); 374 need_sep = true; 375 } 376 if (topic) { 377 fix_escape_fprintf(fp, &buf, "%s\t\"Topic\": \"%S\"", 378 need_sep ? ",\n" : "", 379 topic); 380 need_sep = true; 381 } 382 if (event_name) { 383 fix_escape_fprintf(fp, &buf, "%s\t\"EventName\": \"%S\"", 384 need_sep ? ",\n" : "", 385 event_name); 386 need_sep = true; 387 } 388 if (event_alias && strlen(event_alias)) { 389 fix_escape_fprintf(fp, &buf, "%s\t\"EventAlias\": \"%S\"", 390 need_sep ? ",\n" : "", 391 event_alias); 392 need_sep = true; 393 } 394 if (scale_unit && strlen(scale_unit)) { 395 fix_escape_fprintf(fp, &buf, "%s\t\"ScaleUnit\": \"%S\"", 396 need_sep ? ",\n" : "", 397 scale_unit); 398 need_sep = true; 399 } 400 if (event_type_desc) { 401 fix_escape_fprintf(fp, &buf, "%s\t\"EventType\": \"%S\"", 402 need_sep ? ",\n" : "", 403 event_type_desc); 404 need_sep = true; 405 } 406 if (deprecated) { 407 fix_escape_fprintf(fp, &buf, "%s\t\"Deprecated\": \"%S\"", 408 need_sep ? ",\n" : "", 409 deprecated ? "1" : "0"); 410 need_sep = true; 411 } 412 if (desc) { 413 fix_escape_fprintf(fp, &buf, "%s\t\"BriefDescription\": \"%S\"", 414 need_sep ? ",\n" : "", 415 desc); 416 need_sep = true; 417 } 418 if (long_desc) { 419 fix_escape_fprintf(fp, &buf, "%s\t\"PublicDescription\": \"%S\"", 420 need_sep ? ",\n" : "", 421 long_desc); 422 need_sep = true; 423 } 424 if (encoding_desc) { 425 fix_escape_fprintf(fp, &buf, "%s\t\"Encoding\": \"%S\"", 426 need_sep ? ",\n" : "", 427 encoding_desc); 428 need_sep = true; 429 } 430 fprintf(fp, "%s}", need_sep ? "\n" : ""); 431 strbuf_release(&buf); 432 } 433 434 static void json_print_metric(void *ps __maybe_unused, const char *group, 435 const char *name, const char *desc, 436 const char *long_desc, const char *expr, 437 const char *threshold, const char *unit, 438 const char *pmu_name) 439 { 440 struct json_print_state *print_state = ps; 441 bool need_sep = false; 442 FILE *fp = print_state->fp; 443 struct strbuf buf; 444 445 strbuf_init(&buf, 0); 446 fprintf(fp, "%s{\n", print_state->need_sep ? ",\n" : ""); 447 print_state->need_sep = true; 448 if (group) { 449 fix_escape_fprintf(fp, &buf, "\t\"MetricGroup\": \"%S\"", group); 450 need_sep = true; 451 } 452 if (name) { 453 fix_escape_fprintf(fp, &buf, "%s\t\"MetricName\": \"%S\"", 454 need_sep ? ",\n" : "", 455 name); 456 need_sep = true; 457 } 458 if (expr) { 459 fix_escape_fprintf(fp, &buf, "%s\t\"MetricExpr\": \"%S\"", 460 need_sep ? ",\n" : "", 461 expr); 462 need_sep = true; 463 } 464 if (threshold) { 465 fix_escape_fprintf(fp, &buf, "%s\t\"MetricThreshold\": \"%S\"", 466 need_sep ? ",\n" : "", 467 threshold); 468 need_sep = true; 469 } 470 if (unit) { 471 fix_escape_fprintf(fp, &buf, "%s\t\"ScaleUnit\": \"%S\"", 472 need_sep ? ",\n" : "", 473 unit); 474 need_sep = true; 475 } 476 if (desc) { 477 fix_escape_fprintf(fp, &buf, "%s\t\"BriefDescription\": \"%S\"", 478 need_sep ? ",\n" : "", 479 desc); 480 need_sep = true; 481 } 482 if (long_desc) { 483 fix_escape_fprintf(fp, &buf, "%s\t\"PublicDescription\": \"%S\"", 484 need_sep ? ",\n" : "", 485 long_desc); 486 need_sep = true; 487 } 488 if (pmu_name) { 489 fix_escape_fprintf(fp, &buf, "%s\t\"Unit\": \"%S\"", 490 need_sep ? ",\n" : "", 491 pmu_name); 492 need_sep = true; 493 } 494 fprintf(fp, "%s}", need_sep ? "\n" : ""); 495 strbuf_release(&buf); 496 } 497 498 static bool json_skip_duplicate_pmus(void *ps __maybe_unused) 499 { 500 return false; 501 } 502 503 static bool default_skip_duplicate_pmus(void *ps) 504 { 505 struct print_state *print_state = ps; 506 507 return !print_state->long_desc; 508 } 509 510 int cmd_list(int argc, const char **argv) 511 { 512 int i, ret = 0; 513 struct print_state default_ps = { 514 .fp = stdout, 515 .desc = true, 516 }; 517 struct print_state json_ps = { 518 .fp = stdout, 519 }; 520 void *ps = &default_ps; 521 struct print_callbacks print_cb = { 522 .print_start = default_print_start, 523 .print_end = default_print_end, 524 .print_event = default_print_event, 525 .print_metric = default_print_metric, 526 .skip_duplicate_pmus = default_skip_duplicate_pmus, 527 }; 528 const char *cputype = NULL; 529 const char *unit_name = NULL; 530 const char *output_path = NULL; 531 bool json = false; 532 struct option list_options[] = { 533 OPT_BOOLEAN(0, "raw-dump", &default_ps.name_only, "Dump raw events"), 534 OPT_BOOLEAN('j', "json", &json, "JSON encode events and metrics"), 535 OPT_BOOLEAN('d', "desc", &default_ps.desc, 536 "Print extra event descriptions. --no-desc to not print."), 537 OPT_BOOLEAN('v', "long-desc", &default_ps.long_desc, 538 "Print longer event descriptions and all similar PMUs with alphanumeric suffixes."), 539 OPT_BOOLEAN(0, "details", &default_ps.detailed, 540 "Print information on the perf event names and expressions used internally by events."), 541 OPT_STRING('o', "output", &output_path, "file", "output file name"), 542 OPT_BOOLEAN(0, "deprecated", &default_ps.deprecated, 543 "Print deprecated events."), 544 OPT_STRING(0, "cputype", &cputype, "cpu type", 545 "Limit PMU or metric printing to the given PMU (e.g. cpu, core or atom)."), 546 OPT_STRING(0, "unit", &unit_name, "PMU name", 547 "Limit PMU or metric printing to the specified PMU."), 548 OPT_INCR(0, "debug", &verbose, 549 "Enable debugging output"), 550 OPT_END() 551 }; 552 const char * const list_usage[] = { 553 #ifdef HAVE_LIBPFM 554 "perf list [<options>] [hw|sw|cache|tracepoint|pmu|sdt|metric|metricgroup|event_glob|pfm]", 555 #else 556 "perf list [<options>] [hw|sw|cache|tracepoint|pmu|sdt|metric|metricgroup|event_glob]", 557 #endif 558 NULL 559 }; 560 561 set_option_flag(list_options, 0, "raw-dump", PARSE_OPT_HIDDEN); 562 /* Hide hybrid flag for the more generic 'unit' flag. */ 563 set_option_flag(list_options, 0, "cputype", PARSE_OPT_HIDDEN); 564 565 argc = parse_options(argc, argv, list_options, list_usage, 566 PARSE_OPT_STOP_AT_NON_OPTION); 567 568 if (output_path) { 569 default_ps.fp = fopen(output_path, "w"); 570 json_ps.fp = default_ps.fp; 571 } 572 573 setup_pager(); 574 575 if (!default_ps.name_only) 576 setup_pager(); 577 578 if (json) { 579 print_cb = (struct print_callbacks){ 580 .print_start = json_print_start, 581 .print_end = json_print_end, 582 .print_event = json_print_event, 583 .print_metric = json_print_metric, 584 .skip_duplicate_pmus = json_skip_duplicate_pmus, 585 }; 586 ps = &json_ps; 587 } else { 588 default_ps.last_topic = strdup(""); 589 assert(default_ps.last_topic); 590 default_ps.visited_metrics = strlist__new(NULL, NULL); 591 assert(default_ps.visited_metrics); 592 if (unit_name) 593 default_ps.pmu_glob = strdup(unit_name); 594 else if (cputype) { 595 const struct perf_pmu *pmu = perf_pmus__pmu_for_pmu_filter(cputype); 596 597 if (!pmu) { 598 pr_err("ERROR: cputype is not supported!\n"); 599 ret = -1; 600 goto out; 601 } 602 default_ps.pmu_glob = strdup(pmu->name); 603 } 604 } 605 print_cb.print_start(ps); 606 607 if (argc == 0) { 608 default_ps.metrics = true; 609 default_ps.metricgroups = true; 610 print_events(&print_cb, ps); 611 goto out; 612 } 613 614 for (i = 0; i < argc; ++i) { 615 char *sep, *s; 616 617 if (strcmp(argv[i], "tracepoint") == 0) 618 print_tracepoint_events(&print_cb, ps); 619 else if (strcmp(argv[i], "hw") == 0 || 620 strcmp(argv[i], "hardware") == 0) 621 print_symbol_events(&print_cb, ps, PERF_TYPE_HARDWARE, 622 event_symbols_hw, PERF_COUNT_HW_MAX); 623 else if (strcmp(argv[i], "sw") == 0 || 624 strcmp(argv[i], "software") == 0) { 625 char *old_pmu_glob = default_ps.pmu_glob; 626 627 print_symbol_events(&print_cb, ps, PERF_TYPE_SOFTWARE, 628 event_symbols_sw, PERF_COUNT_SW_MAX); 629 default_ps.pmu_glob = strdup("tool"); 630 if (!default_ps.pmu_glob) { 631 ret = -1; 632 goto out; 633 } 634 perf_pmus__print_pmu_events(&print_cb, ps); 635 zfree(&default_ps.pmu_glob); 636 default_ps.pmu_glob = old_pmu_glob; 637 } else if (strcmp(argv[i], "cache") == 0 || 638 strcmp(argv[i], "hwcache") == 0) 639 print_hwcache_events(&print_cb, ps); 640 else if (strcmp(argv[i], "pmu") == 0) 641 perf_pmus__print_pmu_events(&print_cb, ps); 642 else if (strcmp(argv[i], "sdt") == 0) 643 print_sdt_events(&print_cb, ps); 644 else if (strcmp(argv[i], "metric") == 0 || strcmp(argv[i], "metrics") == 0) { 645 default_ps.metricgroups = false; 646 default_ps.metrics = true; 647 metricgroup__print(&print_cb, ps); 648 } else if (strcmp(argv[i], "metricgroup") == 0 || 649 strcmp(argv[i], "metricgroups") == 0) { 650 default_ps.metricgroups = true; 651 default_ps.metrics = false; 652 metricgroup__print(&print_cb, ps); 653 } 654 #ifdef HAVE_LIBPFM 655 else if (strcmp(argv[i], "pfm") == 0) 656 print_libpfm_events(&print_cb, ps); 657 #endif 658 else if ((sep = strchr(argv[i], ':')) != NULL) { 659 char *old_pmu_glob = default_ps.pmu_glob; 660 661 default_ps.event_glob = strdup(argv[i]); 662 if (!default_ps.event_glob) { 663 ret = -1; 664 goto out; 665 } 666 667 print_tracepoint_events(&print_cb, ps); 668 print_sdt_events(&print_cb, ps); 669 default_ps.metrics = true; 670 default_ps.metricgroups = true; 671 metricgroup__print(&print_cb, ps); 672 zfree(&default_ps.event_glob); 673 default_ps.pmu_glob = old_pmu_glob; 674 } else { 675 if (asprintf(&s, "*%s*", argv[i]) < 0) { 676 printf("Critical: Not enough memory! Trying to continue...\n"); 677 continue; 678 } 679 default_ps.event_glob = s; 680 print_symbol_events(&print_cb, ps, PERF_TYPE_HARDWARE, 681 event_symbols_hw, PERF_COUNT_HW_MAX); 682 print_symbol_events(&print_cb, ps, PERF_TYPE_SOFTWARE, 683 event_symbols_sw, PERF_COUNT_SW_MAX); 684 print_hwcache_events(&print_cb, ps); 685 perf_pmus__print_pmu_events(&print_cb, ps); 686 print_tracepoint_events(&print_cb, ps); 687 print_sdt_events(&print_cb, ps); 688 default_ps.metrics = true; 689 default_ps.metricgroups = true; 690 metricgroup__print(&print_cb, ps); 691 free(s); 692 } 693 } 694 695 out: 696 print_cb.print_end(ps); 697 free(default_ps.pmu_glob); 698 free(default_ps.last_topic); 699 free(default_ps.last_metricgroups); 700 strlist__delete(default_ps.visited_metrics); 701 if (output_path) 702 fclose(default_ps.fp); 703 704 return ret; 705 } 706