diff options
Diffstat (limited to 'tools/perf/util/newt.c')
-rw-r--r-- | tools/perf/util/newt.c | 80 |
1 files changed, 14 insertions, 66 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c index e283a6e6b6e0..638b519e72b8 100644 --- a/tools/perf/util/newt.c +++ b/tools/perf/util/newt.c | |||
@@ -410,8 +410,8 @@ static void hist_browser__delete(struct hist_browser *self) | |||
410 | free(self); | 410 | free(self); |
411 | } | 411 | } |
412 | 412 | ||
413 | static int hist_browser__populate(struct hist_browser *self, struct rb_root *hists, | 413 | static int hist_browser__populate(struct hist_browser *self, struct hists *hists, |
414 | u64 nr_hists, u64 session_total, const char *title) | 414 | const char *title) |
415 | { | 415 | { |
416 | int max_len = 0, idx, cols, rows; | 416 | int max_len = 0, idx, cols, rows; |
417 | struct ui_progress *progress; | 417 | struct ui_progress *progress; |
@@ -426,7 +426,7 @@ static int hist_browser__populate(struct hist_browser *self, struct rb_root *his | |||
426 | } | 426 | } |
427 | 427 | ||
428 | snprintf(str, sizeof(str), "Samples: %Ld ", | 428 | snprintf(str, sizeof(str), "Samples: %Ld ", |
429 | session_total); | 429 | hists->stats.total); |
430 | newtDrawRootText(0, 0, str); | 430 | newtDrawRootText(0, 0, str); |
431 | 431 | ||
432 | newtGetScreenSize(NULL, &rows); | 432 | newtGetScreenSize(NULL, &rows); |
@@ -442,24 +442,25 @@ static int hist_browser__populate(struct hist_browser *self, struct rb_root *his | |||
442 | newtComponentAddCallback(self->tree, hist_browser__selection, | 442 | newtComponentAddCallback(self->tree, hist_browser__selection, |
443 | &self->selection); | 443 | &self->selection); |
444 | 444 | ||
445 | progress = ui_progress__new("Adding entries to the browser...", nr_hists); | 445 | progress = ui_progress__new("Adding entries to the browser...", |
446 | hists->nr_entries); | ||
446 | if (progress == NULL) | 447 | if (progress == NULL) |
447 | return -1; | 448 | return -1; |
448 | 449 | ||
449 | idx = 0; | 450 | idx = 0; |
450 | for (nd = rb_first(hists); nd; nd = rb_next(nd)) { | 451 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
451 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 452 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
452 | int len; | 453 | int len; |
453 | 454 | ||
454 | if (h->filtered) | 455 | if (h->filtered) |
455 | continue; | 456 | continue; |
456 | 457 | ||
457 | len = hist_entry__append_browser(h, self->tree, session_total); | 458 | len = hist_entry__append_browser(h, self->tree, hists->stats.total); |
458 | if (len > max_len) | 459 | if (len > max_len) |
459 | max_len = len; | 460 | max_len = len; |
460 | if (symbol_conf.use_callchain) | 461 | if (symbol_conf.use_callchain) |
461 | hist_entry__append_callchain_browser(h, self->tree, | 462 | hist_entry__append_callchain_browser(h, self->tree, |
462 | session_total, idx++); | 463 | hists->stats.total, idx++); |
463 | ++curr_hist; | 464 | ++curr_hist; |
464 | if (curr_hist % 5) | 465 | if (curr_hist % 5) |
465 | ui_progress__update(progress, curr_hist); | 466 | ui_progress__update(progress, curr_hist); |
@@ -490,57 +491,6 @@ static int hist_browser__populate(struct hist_browser *self, struct rb_root *his | |||
490 | return 0; | 491 | return 0; |
491 | } | 492 | } |
492 | 493 | ||
493 | enum hist_filter { | ||
494 | HIST_FILTER__DSO, | ||
495 | HIST_FILTER__THREAD, | ||
496 | }; | ||
497 | |||
498 | static u64 hists__filter_by_dso(struct rb_root *hists, const struct dso *dso, | ||
499 | u64 *session_total) | ||
500 | { | ||
501 | struct rb_node *nd; | ||
502 | u64 nr_hists = 0; | ||
503 | |||
504 | *session_total = 0; | ||
505 | |||
506 | for (nd = rb_first(hists); nd; nd = rb_next(nd)) { | ||
507 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | ||
508 | |||
509 | if (dso != NULL && (h->ms.map == NULL || h->ms.map->dso != dso)) { | ||
510 | h->filtered |= (1 << HIST_FILTER__DSO); | ||
511 | continue; | ||
512 | } | ||
513 | h->filtered &= ~(1 << HIST_FILTER__DSO); | ||
514 | ++nr_hists; | ||
515 | *session_total += h->count; | ||
516 | } | ||
517 | |||
518 | return nr_hists; | ||
519 | } | ||
520 | |||
521 | static u64 hists__filter_by_thread(struct rb_root *hists, const struct thread *thread, | ||
522 | u64 *session_total) | ||
523 | { | ||
524 | struct rb_node *nd; | ||
525 | u64 nr_hists = 0; | ||
526 | |||
527 | *session_total = 0; | ||
528 | |||
529 | for (nd = rb_first(hists); nd; nd = rb_next(nd)) { | ||
530 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | ||
531 | |||
532 | if (thread != NULL && h->thread != thread) { | ||
533 | h->filtered |= (1 << HIST_FILTER__THREAD); | ||
534 | continue; | ||
535 | } | ||
536 | h->filtered &= ~(1 << HIST_FILTER__THREAD); | ||
537 | ++nr_hists; | ||
538 | *session_total += h->count; | ||
539 | } | ||
540 | |||
541 | return nr_hists; | ||
542 | } | ||
543 | |||
544 | static struct thread *hist_browser__selected_thread(struct hist_browser *self) | 494 | static struct thread *hist_browser__selected_thread(struct hist_browser *self) |
545 | { | 495 | { |
546 | int *indexes; | 496 | int *indexes; |
@@ -577,9 +527,7 @@ static int hist_browser__title(char *bf, size_t size, const char *input_name, | |||
577 | return printed ?: snprintf(bf, size, "Report: %s", input_name); | 527 | return printed ?: snprintf(bf, size, "Report: %s", input_name); |
578 | } | 528 | } |
579 | 529 | ||
580 | int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, | 530 | int hists__browse(struct hists *self, const char *helpline, const char *input_name) |
581 | u64 session_total, const char *helpline, | ||
582 | const char *input_name) | ||
583 | { | 531 | { |
584 | struct hist_browser *browser = hist_browser__new(); | 532 | struct hist_browser *browser = hist_browser__new(); |
585 | const struct thread *thread_filter = NULL; | 533 | const struct thread *thread_filter = NULL; |
@@ -595,7 +543,7 @@ int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, | |||
595 | 543 | ||
596 | hist_browser__title(msg, sizeof(msg), input_name, | 544 | hist_browser__title(msg, sizeof(msg), input_name, |
597 | dso_filter, thread_filter); | 545 | dso_filter, thread_filter); |
598 | if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0) | 546 | if (hist_browser__populate(browser, self, msg) < 0) |
599 | goto out; | 547 | goto out; |
600 | 548 | ||
601 | while (1) { | 549 | while (1) { |
@@ -672,10 +620,10 @@ do_annotate: | |||
672 | newtPushHelpLine(msg); | 620 | newtPushHelpLine(msg); |
673 | dso_filter = dso; | 621 | dso_filter = dso; |
674 | } | 622 | } |
675 | nr_hists = hists__filter_by_dso(hists, dso_filter, &session_total); | 623 | hists__filter_by_dso(self, dso_filter); |
676 | hist_browser__title(msg, sizeof(msg), input_name, | 624 | hist_browser__title(msg, sizeof(msg), input_name, |
677 | dso_filter, thread_filter); | 625 | dso_filter, thread_filter); |
678 | if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0) | 626 | if (hist_browser__populate(browser, self, msg) < 0) |
679 | goto out; | 627 | goto out; |
680 | } else if (choice == zoom_thread) { | 628 | } else if (choice == zoom_thread) { |
681 | if (thread_filter) { | 629 | if (thread_filter) { |
@@ -689,10 +637,10 @@ do_annotate: | |||
689 | newtPushHelpLine(msg); | 637 | newtPushHelpLine(msg); |
690 | thread_filter = thread; | 638 | thread_filter = thread; |
691 | } | 639 | } |
692 | nr_hists = hists__filter_by_thread(hists, thread_filter, &session_total); | 640 | hists__filter_by_thread(self, thread_filter); |
693 | hist_browser__title(msg, sizeof(msg), input_name, | 641 | hist_browser__title(msg, sizeof(msg), input_name, |
694 | dso_filter, thread_filter); | 642 | dso_filter, thread_filter); |
695 | if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0) | 643 | if (hist_browser__populate(browser, self, msg) < 0) |
696 | goto out; | 644 | goto out; |
697 | } | 645 | } |
698 | } | 646 | } |