Lines Matching refs:browser
72 static bool disasm_line__filter(struct ui_browser *browser __maybe_unused, in disasm_line__filter()
83 static int annotate_browser__jumps_percent_color(struct annotate_browser *browser, in annotate_browser__jumps_percent_color() argument
86 if (current && (!browser->b.use_navkeypressed || browser->b.navkeypressed)) in annotate_browser__jumps_percent_color()
88 if (nr == browser->max_jump_sources) in annotate_browser__jumps_percent_color()
95 static int annotate_browser__set_jumps_percent_color(struct annotate_browser *browser, in annotate_browser__set_jumps_percent_color() argument
98 int color = annotate_browser__jumps_percent_color(browser, nr, current); in annotate_browser__set_jumps_percent_color()
99 return ui_browser__set_color(&browser->b, color); in annotate_browser__set_jumps_percent_color()
111 static void annotate_browser__write(struct ui_browser *browser, void *entry, int row) in annotate_browser__write() argument
113 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); in annotate_browser__write()
116 bool current_entry = ui_browser__is_current_entry(browser, row); in annotate_browser__write()
118 (!current_entry || (browser->use_navkeypressed && in annotate_browser__write()
119 !browser->navkeypressed))); in annotate_browser__write()
120 int width = browser->width, printed; in annotate_browser__write()
133 ui_browser__set_percent_color(browser, in annotate_browser__write()
137 ui_browser__printf(browser, "%6" PRIu64 " ", in annotate_browser__write()
140 ui_browser__printf(browser, "%6.2f ", in annotate_browser__write()
145 ui_browser__write_nstring(browser, " ", 7 * ab->nr_events); in annotate_browser__write()
148 ui_browser__set_percent_color(browser, 0, current_entry); in annotate_browser__write()
149 ui_browser__write_nstring(browser, " ", 7 * ab->nr_events); in annotate_browser__write()
153 ui_browser__printf(browser, "%*.2f ", IPC_WIDTH - 1, dl->ipc); in annotate_browser__write()
155 ui_browser__write_nstring(browser, " ", IPC_WIDTH); in annotate_browser__write()
157 ui_browser__printf(browser, "%*" PRIu64 " ", in annotate_browser__write()
160 ui_browser__write_nstring(browser, " ", CYCLES_WIDTH); in annotate_browser__write()
166 if (!browser->navkeypressed) in annotate_browser__write()
170 ui_browser__write_nstring(browser, " ", width - pcnt_width); in annotate_browser__write()
178 ui_browser__write_nstring(browser, bf, printed); in annotate_browser__write()
179 ui_browser__write_nstring(browser, dl->line, width - printed - pcnt_width + 1); in annotate_browser__write()
198 ui_browser__write_nstring(browser, bf, printed); in annotate_browser__write()
199 ui_browser__set_color(browser, prev); in annotate_browser__write()
211 color = ui_browser__set_color(browser, HE_COLORSET_ADDR); in annotate_browser__write()
212 ui_browser__write_nstring(browser, bf, printed); in annotate_browser__write()
214 ui_browser__set_color(browser, color); in annotate_browser__write()
219 ui_browser__write_graph(browser, fwd ? SLSMG_DARROW_CHAR : in annotate_browser__write()
223 ui_browser__write_graph(browser, SLSMG_RARROW_CHAR); in annotate_browser__write()
226 ui_browser__write_nstring(browser, " ", 2); in annotate_browser__write()
230 ui_browser__write_nstring(browser, " ", 2); in annotate_browser__write()
232 ui_browser__write_graph(browser, SLSMG_LARROW_CHAR); in annotate_browser__write()
238 ui_browser__write_nstring(browser, bf, width - pcnt_width - 3 - printed); in annotate_browser__write()
255 static void annotate_browser__draw_current_jump(struct ui_browser *browser) in annotate_browser__draw_current_jump() argument
257 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); in annotate_browser__draw_current_jump()
287 ui_browser__set_color(browser, HE_COLORSET_CODE); in annotate_browser__draw_current_jump()
288 __ui_browser__line_arrow(browser, pcnt_width + 2 + ab->addr_width, in annotate_browser__draw_current_jump()
292 static unsigned int annotate_browser__refresh(struct ui_browser *browser) in annotate_browser__refresh() argument
294 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); in annotate_browser__refresh()
295 int ret = ui_browser__list_head_refresh(browser); in annotate_browser__refresh()
299 annotate_browser__draw_current_jump(browser); in annotate_browser__refresh()
301 ui_browser__set_color(browser, HE_COLORSET_NORMAL); in annotate_browser__refresh()
302 __ui_browser__vline(browser, pcnt_width, 0, browser->height - 1); in annotate_browser__refresh()
339 static void annotate_browser__set_top(struct annotate_browser *browser, in annotate_browser__set_top() argument
344 ui_browser__refresh_dimensions(&browser->b); in annotate_browser__set_top()
345 back = browser->b.height / 2; in annotate_browser__set_top()
346 browser->b.top_idx = browser->b.index = idx; in annotate_browser__set_top()
348 while (browser->b.top_idx != 0 && back != 0) { in annotate_browser__set_top()
351 if (disasm_line__filter(&browser->b, &pos->node)) in annotate_browser__set_top()
354 --browser->b.top_idx; in annotate_browser__set_top()
358 browser->b.top = pos; in annotate_browser__set_top()
359 browser->b.navkeypressed = true; in annotate_browser__set_top()
362 static void annotate_browser__set_rb_top(struct annotate_browser *browser, in annotate_browser__set_rb_top() argument
374 annotate_browser__set_top(browser, pos, idx); in annotate_browser__set_rb_top()
375 browser->curr_hot = nd; in annotate_browser__set_rb_top()
378 static void annotate_browser__calc_percent(struct annotate_browser *browser, in annotate_browser__calc_percent() argument
381 struct map_symbol *ms = browser->b.priv; in annotate_browser__calc_percent()
387 browser->entries = RB_ROOT; in annotate_browser__calc_percent()
404 for (i = 0; i < browser->nr_events; i++) { in annotate_browser__calc_percent()
422 disasm_rb_tree__insert(&browser->entries, bpos, in annotate_browser__calc_percent()
423 browser->nr_events); in annotate_browser__calc_percent()
427 browser->curr_hot = rb_last(&browser->entries); in annotate_browser__calc_percent()
430 static bool annotate_browser__toggle_source(struct annotate_browser *browser) in annotate_browser__toggle_source() argument
434 off_t offset = browser->b.index - browser->b.top_idx; in annotate_browser__toggle_source()
436 browser->b.seek(&browser->b, offset, SEEK_CUR); in annotate_browser__toggle_source()
437 dl = list_entry(browser->b.top, struct disasm_line, node); in annotate_browser__toggle_source()
444 browser->b.nr_entries = browser->nr_entries; in annotate_browser__toggle_source()
446 browser->b.seek(&browser->b, -offset, SEEK_CUR); in annotate_browser__toggle_source()
447 browser->b.top_idx = bdl->idx - offset; in annotate_browser__toggle_source()
448 browser->b.index = bdl->idx; in annotate_browser__toggle_source()
452 browser->b.seek(&browser->b, -offset, SEEK_CUR); in annotate_browser__toggle_source()
459 browser->b.nr_entries = browser->nr_asm_entries; in annotate_browser__toggle_source()
461 browser->b.seek(&browser->b, -offset, SEEK_CUR); in annotate_browser__toggle_source()
462 browser->b.top_idx = bdl->idx_asm - offset; in annotate_browser__toggle_source()
463 browser->b.index = bdl->idx_asm; in annotate_browser__toggle_source()
469 static void annotate_browser__init_asm_mode(struct annotate_browser *browser) in annotate_browser__init_asm_mode() argument
471 ui_browser__reset_index(&browser->b); in annotate_browser__init_asm_mode()
472 browser->b.nr_entries = browser->nr_asm_entries; in annotate_browser__init_asm_mode()
483 static bool annotate_browser__callq(struct annotate_browser *browser, in annotate_browser__callq() argument
487 struct map_symbol *ms = browser->b.priv; in annotate_browser__callq()
488 struct disasm_line *dl = browser->selection; in annotate_browser__callq()
520 ui_browser__show_title(&browser->b, title); in annotate_browser__callq()
525 struct disasm_line *annotate_browser__find_offset(struct annotate_browser *browser, in annotate_browser__find_offset() argument
528 struct map_symbol *ms = browser->b.priv; in annotate_browser__find_offset()
537 if (!disasm_line__filter(&browser->b, &pos->node)) in annotate_browser__find_offset()
544 static bool annotate_browser__jump(struct annotate_browser *browser) in annotate_browser__jump() argument
546 struct disasm_line *dl = browser->selection; in annotate_browser__jump()
552 dl = annotate_browser__find_offset(browser, dl->ops.target.offset, &idx); in annotate_browser__jump()
558 annotate_browser__set_top(browser, dl, idx); in annotate_browser__jump()
564 struct disasm_line *annotate_browser__find_string(struct annotate_browser *browser, in annotate_browser__find_string() argument
567 struct map_symbol *ms = browser->b.priv; in annotate_browser__find_string()
570 struct disasm_line *pos = browser->selection; in annotate_browser__find_string()
572 *idx = browser->b.index; in annotate_browser__find_string()
574 if (disasm_line__filter(&browser->b, &pos->node)) in annotate_browser__find_string()
586 static bool __annotate_browser__search(struct annotate_browser *browser) in __annotate_browser__search() argument
591 dl = annotate_browser__find_string(browser, browser->search_bf, &idx); in __annotate_browser__search()
597 annotate_browser__set_top(browser, dl, idx); in __annotate_browser__search()
598 browser->searching_backwards = false; in __annotate_browser__search()
603 struct disasm_line *annotate_browser__find_string_reverse(struct annotate_browser *browser, in annotate_browser__find_string_reverse() argument
606 struct map_symbol *ms = browser->b.priv; in annotate_browser__find_string_reverse()
609 struct disasm_line *pos = browser->selection; in annotate_browser__find_string_reverse()
611 *idx = browser->b.index; in annotate_browser__find_string_reverse()
613 if (disasm_line__filter(&browser->b, &pos->node)) in annotate_browser__find_string_reverse()
625 static bool __annotate_browser__search_reverse(struct annotate_browser *browser) in __annotate_browser__search_reverse() argument
630 dl = annotate_browser__find_string_reverse(browser, browser->search_bf, &idx); in __annotate_browser__search_reverse()
636 annotate_browser__set_top(browser, dl, idx); in __annotate_browser__search_reverse()
637 browser->searching_backwards = true; in __annotate_browser__search_reverse()
641 static bool annotate_browser__search_window(struct annotate_browser *browser, in annotate_browser__search_window() argument
644 if (ui_browser__input_window("Search", "String: ", browser->search_bf, in annotate_browser__search_window()
647 !*browser->search_bf) in annotate_browser__search_window()
653 static bool annotate_browser__search(struct annotate_browser *browser, int delay_secs) in annotate_browser__search() argument
655 if (annotate_browser__search_window(browser, delay_secs)) in annotate_browser__search()
656 return __annotate_browser__search(browser); in annotate_browser__search()
661 static bool annotate_browser__continue_search(struct annotate_browser *browser, in annotate_browser__continue_search() argument
664 if (!*browser->search_bf) in annotate_browser__continue_search()
665 return annotate_browser__search(browser, delay_secs); in annotate_browser__continue_search()
667 return __annotate_browser__search(browser); in annotate_browser__continue_search()
670 static bool annotate_browser__search_reverse(struct annotate_browser *browser, in annotate_browser__search_reverse() argument
673 if (annotate_browser__search_window(browser, delay_secs)) in annotate_browser__search_reverse()
674 return __annotate_browser__search_reverse(browser); in annotate_browser__search_reverse()
680 bool annotate_browser__continue_search_reverse(struct annotate_browser *browser, in annotate_browser__continue_search_reverse() argument
683 if (!*browser->search_bf) in annotate_browser__continue_search_reverse()
684 return annotate_browser__search_reverse(browser, delay_secs); in annotate_browser__continue_search_reverse()
686 return __annotate_browser__search_reverse(browser); in annotate_browser__continue_search_reverse()
689 static void annotate_browser__update_addr_width(struct annotate_browser *browser) in annotate_browser__update_addr_width() argument
692 browser->target_width = browser->min_addr_width; in annotate_browser__update_addr_width()
694 browser->target_width = browser->max_addr_width; in annotate_browser__update_addr_width()
696 browser->addr_width = browser->target_width; in annotate_browser__update_addr_width()
699 browser->addr_width += browser->jumps_width + 1; in annotate_browser__update_addr_width()
702 static int annotate_browser__run(struct annotate_browser *browser, in annotate_browser__run() argument
707 struct map_symbol *ms = browser->b.priv; in annotate_browser__run()
715 if (ui_browser__show(&browser->b, title, help) < 0) in annotate_browser__run()
718 annotate_browser__calc_percent(browser, evsel); in annotate_browser__run()
720 if (browser->curr_hot) { in annotate_browser__run()
721 annotate_browser__set_rb_top(browser, browser->curr_hot); in annotate_browser__run()
722 browser->b.navkeypressed = false; in annotate_browser__run()
725 nd = browser->curr_hot; in annotate_browser__run()
728 key = ui_browser__run(&browser->b, delay_secs); in annotate_browser__run()
731 annotate_browser__calc_percent(browser, evsel); in annotate_browser__run()
753 nd = rb_last(&browser->entries); in annotate_browser__run()
755 nd = browser->curr_hot; in annotate_browser__run()
761 nd = rb_first(&browser->entries); in annotate_browser__run()
763 nd = browser->curr_hot; in annotate_browser__run()
767 ui_browser__help_window(&browser->b, in annotate_browser__run()
795 nd = browser->curr_hot; in annotate_browser__run()
798 if (annotate_browser__toggle_source(browser)) in annotate_browser__run()
803 annotate_browser__update_addr_width(browser); in annotate_browser__run()
810 annotate_browser__update_addr_width(browser); in annotate_browser__run()
813 if (annotate_browser__search(browser, delay_secs)) { in annotate_browser__run()
819 if (browser->searching_backwards ? in annotate_browser__run()
820 annotate_browser__continue_search_reverse(browser, delay_secs) : in annotate_browser__run()
821 annotate_browser__continue_search(browser, delay_secs)) in annotate_browser__run()
825 if (annotate_browser__search_reverse(browser, delay_secs)) in annotate_browser__run()
832 seq++, browser->b.nr_entries, in annotate_browser__run()
833 browser->b.height, in annotate_browser__run()
834 browser->b.index, in annotate_browser__run()
835 browser->b.top_idx, in annotate_browser__run()
836 browser->nr_asm_entries); in annotate_browser__run()
841 if (browser->selection == NULL) in annotate_browser__run()
843 else if (browser->selection->offset == -1) in annotate_browser__run()
845 else if (!browser->selection->ins) { in annotate_browser__run()
846 if (strcmp(browser->selection->name, "retq")) in annotate_browser__run()
849 } else if (!(annotate_browser__jump(browser) || in annotate_browser__run()
850 annotate_browser__callq(browser, evsel, hbt))) { in annotate_browser__run()
858 annotate_browser__update_addr_width(browser); in annotate_browser__run()
870 annotate_browser__set_rb_top(browser, nd); in annotate_browser__run()
873 ui_browser__hide(&browser->b); in annotate_browser__run()
898 static unsigned count_insn(struct annotate_browser *browser, u64 start, u64 end) in count_insn() argument
904 if (browser->offsets[offset]) in count_insn()
910 static void count_and_fill(struct annotate_browser *browser, u64 start, u64 end, in count_and_fill() argument
916 n_insn = count_insn(browser, start, end); in count_and_fill()
925 struct disasm_line *dl = browser->offsets[offset]; in count_and_fill()
938 static void annotate__compute_ipc(struct annotate_browser *browser, size_t size, in annotate__compute_ipc() argument
956 count_and_fill(browser, ch->start, offset, ch); in annotate__compute_ipc()
957 dl = browser->offsets[offset]; in annotate__compute_ipc()
960 browser->have_cycles = true; in annotate__compute_ipc()
966 static void annotate_browser__mark_jump_targets(struct annotate_browser *browser, in annotate_browser__mark_jump_targets() argument
970 struct map_symbol *ms = browser->b.priv; in annotate_browser__mark_jump_targets()
978 struct disasm_line *dl = browser->offsets[offset], *dlt; in annotate_browser__mark_jump_targets()
984 dlt = browser->offsets[dl->ops.target.offset]; in annotate_browser__mark_jump_targets()
993 if (++bdlt->jump_sources > browser->max_jump_sources) in annotate_browser__mark_jump_targets()
994 browser->max_jump_sources = bdlt->jump_sources; in annotate_browser__mark_jump_targets()
996 ++browser->nr_jumps; in annotate_browser__mark_jump_targets()
1020 struct annotate_browser browser = { in symbol__tui_annotate() local
1042 browser.offsets = zalloc(size * sizeof(struct disasm_line *)); in symbol__tui_annotate()
1043 if (browser.offsets == NULL) { in symbol__tui_annotate()
1062 browser.start = map__rip_2objdump(map, sym->start); in symbol__tui_annotate()
1068 if (browser.b.width < line_len) in symbol__tui_annotate()
1069 browser.b.width = line_len; in symbol__tui_annotate()
1071 bpos->idx = browser.nr_entries++; in symbol__tui_annotate()
1073 bpos->idx_asm = browser.nr_asm_entries++; in symbol__tui_annotate()
1082 browser.offsets[pos->offset] = pos; in symbol__tui_annotate()
1087 annotate_browser__mark_jump_targets(&browser, size); in symbol__tui_annotate()
1088 annotate__compute_ipc(&browser, size, sym); in symbol__tui_annotate()
1090 browser.addr_width = browser.target_width = browser.min_addr_width = hex_width(size); in symbol__tui_annotate()
1091 browser.max_addr_width = hex_width(sym->end); in symbol__tui_annotate()
1092 browser.jumps_width = width_jumps(browser.max_jump_sources); in symbol__tui_annotate()
1093 browser.nr_events = nr_pcnt; in symbol__tui_annotate()
1094 browser.b.nr_entries = browser.nr_entries; in symbol__tui_annotate()
1095 browser.b.entries = ¬es->src->source, in symbol__tui_annotate()
1096 browser.b.width += 18; /* Percentage */ in symbol__tui_annotate()
1099 annotate_browser__init_asm_mode(&browser); in symbol__tui_annotate()
1101 annotate_browser__update_addr_width(&browser); in symbol__tui_annotate()
1103 ret = annotate_browser__run(&browser, evsel, hbt); in symbol__tui_annotate()
1110 free(browser.offsets); in symbol__tui_annotate()