aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index a368978d5177..6db0e37ee33b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -438,8 +438,9 @@ static void print_sym_table(void)
438 struct sym_entry *syme, *n; 438 struct sym_entry *syme, *n;
439 struct rb_root tmp = RB_ROOT; 439 struct rb_root tmp = RB_ROOT;
440 struct rb_node *nd; 440 struct rb_node *nd;
441 int sym_width = 0, dso_width; 441 int sym_width = 0, dso_width = 0;
442 const int win_width = winsize.ws_col - 1; 442 const int win_width = winsize.ws_col - 1;
443 struct dso *unique_dso = NULL, *first_dso = NULL;
443 444
444 samples = userspace_samples = 0; 445 samples = userspace_samples = 0;
445 446
@@ -509,7 +510,7 @@ static void print_sym_table(void)
509 printf(", %d CPUs)\n", nr_cpus); 510 printf(", %d CPUs)\n", nr_cpus);
510 } 511 }
511 512
512 printf("%-*.*s\n\n", win_width, win_width, graph_dotted_line); 513 printf("%-*.*s\n", win_width, win_width, graph_dotted_line);
513 514
514 if (sym_filter_entry) { 515 if (sym_filter_entry) {
515 show_details(sym_filter_entry); 516 show_details(sym_filter_entry);
@@ -525,28 +526,47 @@ static void print_sym_table(void)
525 (int)syme->snap_count < count_filter) 526 (int)syme->snap_count < count_filter)
526 continue; 527 continue;
527 528
529 if (first_dso == NULL)
530 unique_dso = first_dso = syme->map->dso;
531 else if (syme->map->dso != first_dso)
532 unique_dso = NULL;
533
534 if (syme->map->dso->long_name_len > dso_width)
535 dso_width = syme->map->dso->long_name_len;
536
528 if (syme->name_len > sym_width) 537 if (syme->name_len > sym_width)
529 sym_width = syme->name_len; 538 sym_width = syme->name_len;
530 } 539 }
531 540
532 printed = 0; 541 printed = 0;
533 542
543 if (unique_dso)
544 printf("DSO: %s\n", unique_dso->long_name);
545 else {
546 int max_dso_width = winsize.ws_col - sym_width - 29;
547 if (dso_width > max_dso_width)
548 dso_width = max_dso_width;
549 putchar('\n');
550 }
534 if (nr_counters == 1) 551 if (nr_counters == 1)
535 printf(" samples pcnt"); 552 printf(" samples pcnt");
536 else 553 else
537 printf(" weight samples pcnt"); 554 printf(" weight samples pcnt");
538 555
539 dso_width = winsize.ws_col - sym_width - 29;
540
541 if (verbose) 556 if (verbose)
542 printf(" RIP "); 557 printf(" RIP ");
543 printf(" %-*.*s DSO\n", sym_width, sym_width, "function"); 558 printf(" %-*.*s", sym_width, sym_width, "function");
559 if (!unique_dso)
560 printf(" DSO");
561 putchar('\n');
544 printf(" %s _______ _____", 562 printf(" %s _______ _____",
545 nr_counters == 1 ? " " : "______"); 563 nr_counters == 1 ? " " : "______");
546 if (verbose) 564 if (verbose)
547 printf(" ________________"); 565 printf(" ________________");
548 printf(" %-*.*s %-*.*s\n\n", sym_width, sym_width, graph_line, 566 printf(" %-*.*s", sym_width, sym_width, graph_line);
549 dso_width, dso_width, graph_line); 567 if (!unique_dso)
568 printf(" %-*.*s", dso_width, dso_width, graph_line);
569 puts("\n");
550 570
551 for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) { 571 for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) {
552 struct symbol *sym; 572 struct symbol *sym;
@@ -570,10 +590,11 @@ static void print_sym_table(void)
570 if (verbose) 590 if (verbose)
571 printf(" %016llx", sym->start); 591 printf(" %016llx", sym->start);
572 printf(" %-*.*s", sym_width, sym_width, sym->name); 592 printf(" %-*.*s", sym_width, sym_width, sym->name);
573 printf(" %-*.*s", dso_width, dso_width, 593 if (!unique_dso)
574 dso_width >= syme->map->dso->long_name_len ? 594 printf(" %-*.*s", dso_width, dso_width,
575 syme->map->dso->long_name : 595 dso_width >= syme->map->dso->long_name_len ?
576 syme->map->dso->short_name); 596 syme->map->dso->long_name :
597 syme->map->dso->short_name);
577 printf("\n"); 598 printf("\n");
578 } 599 }
579} 600}