diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-08-20 04:07:57 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-08-20 11:14:58 -0400 |
commit | f4536ddd20d93b70d432b7ca5db873525e23c2c4 (patch) | |
tree | 0fc5caf560491300bfb6b331810f048518119d6d /tools | |
parent | 2bfa152839e5adea66aa6309c94bf3a50a5d5d47 (diff) |
perf hists browser: Factor out hist_browser__show_callchain_entry()
Factor out duplicate callchain printing code into the hist_browser__
show_callchain_entry().
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1408522080-26556-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 2f34c6b6d5dc..d42d8a8f3810 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -477,6 +477,29 @@ static char *callchain_list__sym_name(struct callchain_list *cl, | |||
477 | return bf; | 477 | return bf; |
478 | } | 478 | } |
479 | 479 | ||
480 | static void hist_browser__show_callchain_entry(struct hist_browser *browser, | ||
481 | struct callchain_list *chain, | ||
482 | unsigned short row, int offset, | ||
483 | char folded_sign, const char *str, | ||
484 | bool *is_current_entry) | ||
485 | { | ||
486 | int color, width; | ||
487 | |||
488 | color = HE_COLORSET_NORMAL; | ||
489 | width = browser->b.width - (offset + 2); | ||
490 | if (ui_browser__is_current_entry(&browser->b, row)) { | ||
491 | browser->selection = &chain->ms; | ||
492 | color = HE_COLORSET_SELECTED; | ||
493 | *is_current_entry = true; | ||
494 | } | ||
495 | |||
496 | ui_browser__set_color(&browser->b, color); | ||
497 | hist_browser__gotorc(browser, row, 0); | ||
498 | slsmg_write_nstring(" ", offset); | ||
499 | slsmg_printf("%c ", folded_sign); | ||
500 | slsmg_write_nstring(str, width); | ||
501 | } | ||
502 | |||
480 | #define LEVEL_OFFSET_STEP 3 | 503 | #define LEVEL_OFFSET_STEP 3 |
481 | 504 | ||
482 | static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *browser, | 505 | static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *browser, |
@@ -487,7 +510,7 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *browse | |||
487 | bool *is_current_entry) | 510 | bool *is_current_entry) |
488 | { | 511 | { |
489 | struct rb_node *node; | 512 | struct rb_node *node; |
490 | int first_row = row, width, offset = level * LEVEL_OFFSET_STEP; | 513 | int first_row = row, offset = level * LEVEL_OFFSET_STEP; |
491 | u64 new_total; | 514 | u64 new_total; |
492 | 515 | ||
493 | if (callchain_param.mode == CHAIN_GRAPH_REL) | 516 | if (callchain_param.mode == CHAIN_GRAPH_REL) |
@@ -508,7 +531,6 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *browse | |||
508 | list_for_each_entry(chain, &child->val, list) { | 531 | list_for_each_entry(chain, &child->val, list) { |
509 | char bf[1024], *alloc_str; | 532 | char bf[1024], *alloc_str; |
510 | const char *str; | 533 | const char *str; |
511 | int color; | ||
512 | bool was_first = first; | 534 | bool was_first = first; |
513 | 535 | ||
514 | if (first) | 536 | if (first) |
@@ -534,19 +556,10 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *browse | |||
534 | str = alloc_str; | 556 | str = alloc_str; |
535 | } | 557 | } |
536 | 558 | ||
537 | color = HE_COLORSET_NORMAL; | 559 | hist_browser__show_callchain_entry(browser, chain, row, |
538 | width = browser->b.width - (offset + extra_offset + 2); | 560 | offset + extra_offset, |
539 | if (ui_browser__is_current_entry(&browser->b, row)) { | 561 | folded_sign, str, |
540 | browser->selection = &chain->ms; | 562 | is_current_entry); |
541 | color = HE_COLORSET_SELECTED; | ||
542 | *is_current_entry = true; | ||
543 | } | ||
544 | |||
545 | ui_browser__set_color(&browser->b, color); | ||
546 | hist_browser__gotorc(browser, row, 0); | ||
547 | slsmg_write_nstring(" ", offset + extra_offset); | ||
548 | slsmg_printf("%c ", folded_sign); | ||
549 | slsmg_write_nstring(str, width); | ||
550 | free(alloc_str); | 563 | free(alloc_str); |
551 | 564 | ||
552 | if (++row == browser->b.rows) | 565 | if (++row == browser->b.rows) |
@@ -577,14 +590,12 @@ static int hist_browser__show_callchain_node(struct hist_browser *browser, | |||
577 | bool *is_current_entry) | 590 | bool *is_current_entry) |
578 | { | 591 | { |
579 | struct callchain_list *chain; | 592 | struct callchain_list *chain; |
580 | int first_row = row, | 593 | int first_row = row; |
581 | offset = level * LEVEL_OFFSET_STEP, | 594 | int offset = level * LEVEL_OFFSET_STEP; |
582 | width = browser->b.width - offset; | ||
583 | char folded_sign = ' '; | 595 | char folded_sign = ' '; |
584 | 596 | ||
585 | list_for_each_entry(chain, &node->val, list) { | 597 | list_for_each_entry(chain, &node->val, list) { |
586 | char bf[1024], *s; | 598 | char bf[1024], *s; |
587 | int color; | ||
588 | 599 | ||
589 | folded_sign = callchain_list__folded(chain); | 600 | folded_sign = callchain_list__folded(chain); |
590 | 601 | ||
@@ -593,20 +604,11 @@ static int hist_browser__show_callchain_node(struct hist_browser *browser, | |||
593 | continue; | 604 | continue; |
594 | } | 605 | } |
595 | 606 | ||
596 | color = HE_COLORSET_NORMAL; | ||
597 | if (ui_browser__is_current_entry(&browser->b, row)) { | ||
598 | browser->selection = &chain->ms; | ||
599 | color = HE_COLORSET_SELECTED; | ||
600 | *is_current_entry = true; | ||
601 | } | ||
602 | |||
603 | s = callchain_list__sym_name(chain, bf, sizeof(bf), | 607 | s = callchain_list__sym_name(chain, bf, sizeof(bf), |
604 | browser->show_dso); | 608 | browser->show_dso); |
605 | hist_browser__gotorc(browser, row, 0); | 609 | hist_browser__show_callchain_entry(browser, chain, row, |
606 | ui_browser__set_color(&browser->b, color); | 610 | offset, folded_sign, s, |
607 | slsmg_write_nstring(" ", offset); | 611 | is_current_entry); |
608 | slsmg_printf("%c ", folded_sign); | ||
609 | slsmg_write_nstring(s, width - 2); | ||
610 | 612 | ||
611 | if (++row == browser->b.rows) | 613 | if (++row == browser->b.rows) |
612 | goto out; | 614 | goto out; |