2 #include "../../util/util.h" 3 #include "../browser.h" 4 #include "../helpline.h" 7 #include "../../util/annotate.h" 8 #include "../../util/hist.h" 9 #include "../../util/sort.h" 10 #include "../../util/symbol.h" 11 #include "../../util/evsel.h" 12 #include "../../util/evlist.h" 15 #include <linux/kernel.h> 16 #include <linux/string.h> 17 #include <sys/ttydefaults.h> 28 struct rb_root entries;
137 if (!name || !cursor->
ins.
name)
148 unsigned int from, to;
156 if (strstr(sym->
name,
"@plt"))
183 if (target == NULL) {
184 ui_helpline__printf(
"WARN: jump target inconsistency, press 'o', notes->offsets[%#x] = NULL\n",
193 from = (u64)cursor->
al.
idx;
194 to = (u64)target->
idx;
208 to > from ?
true :
false);
240 struct rb_node **p = &root->rb_node;
241 struct rb_node *parent = NULL;
253 rb_link_node(&al->
rb_node, parent, p);
254 rb_insert_color(&al->
rb_node, root);
267 while (browser->
b.
top_idx != 0 && back != 0) {
277 browser->
b.
top = pos;
304 pthread_mutex_lock(¬es->
lock);
309 double max_percent = 0.0;
320 if (max_percent < sample->
percent)
324 if (max_percent < 0.01 && pos->al.ipc == 0) {
330 pthread_mutex_unlock(¬es->
lock);
341 browser->
b.
seek(&browser->
b, offset, SEEK_CUR);
350 browser->
b.
seek(&browser->
b, -offset, SEEK_CUR);
356 browser->
b.
seek(&browser->
b, -offset, SEEK_CUR);
365 browser->
b.
seek(&browser->
b, -offset, SEEK_CUR);
380 #define SYM_TITLE_MAX_SIZE (PATH_MAX + 64) 412 pthread_mutex_lock(¬es->
lock);
415 pthread_mutex_unlock(¬es->
lock);
416 ui__warning(
"Not enough memory for annotating '%s' symbol!\n",
421 pthread_mutex_unlock(¬es->
lock);
430 s64 offset, s64 *idx)
482 list_for_each_entry_continue(al, ¬es->
src->
source,
node) {
488 if (al->
line && strstr(al->
line, s) != NULL)
519 list_for_each_entry_continue_reverse(al, ¬es->
src->
source,
node) {
525 if (al->
line && strstr(al->
line, s) != NULL)
552 "ENTER: OK, ESC: Cancel",
605 sym_title(sym, ms->
map, symbol_dso,
sizeof(symbol_dso));
617 struct rb_node *nd = NULL;
622 const char *help =
"Press 'h' for help on key bindings";
623 int delay_secs = hbt ? hbt->
refresh : 0;
644 if (delay_secs != 0) {
651 if (nd != NULL && RB_EMPTY_NODE(nd))
660 if (delay_secs != 0) {
670 nd = rb_last(&browser->
entries);
678 nd = rb_first(&browser->
entries);
686 "PGDN/SPACE Navigate\n" 687 "q/ESC/CTRL+C Exit\n\n" 688 "ENTER Go to target\n" 690 "H Go to hottest instruction\n" 691 "TAB/shift+TAB Cycle thru hottest instructions\n" 692 "j Toggle showing jump to target arrows\n" 693 "J Toggle showing number of jump sources on targets\n" 694 "n Search next string\n" 695 "o Toggle disassembler output/simplified view\n" 696 "O Bump offset level (jump targets -> +call -> all -> cycle thru)\n" 697 "s Toggle source code view\n" 698 "t Circulate percent, total period, samples view\n" 699 "c Show min/max cycle\n" 701 "k Toggle line numbers\n" 702 "P Print to [symbol_name].annotation file.\n" 703 "r Run available scripts\n" 704 "? Search string backwards\n");
779 ui_helpline__puts(
"Actions are only available for function call/return & jump/branch instructions.");
833 SLang_init_tty(0, 0, 0);
854 .extra_title_lines = 1,
856 .use_navkeypressed =
true,
873 goto out_free_offsets;
static int annotation__pcnt_width(struct annotation *notes)
static bool __annotate_browser__search_reverse(struct annotate_browser *browser)
struct annotation::@40 widths
int symbol__tui_annotate(struct symbol *sym, struct map *map, struct perf_evsel *evsel, struct hist_browser_timer *hbt, struct annotation_options *opts)
void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel)
static int annotation__scnprintf_samples_period(struct annotation *notes, char *bf, size_t size, struct perf_evsel *evsel)
int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel, struct hist_browser_timer *hbt, struct annotation_options *opts)
void annotation__update_column_widths(struct annotation *notes)
void ui_browser__reset_index(struct ui_browser *browser)
int ui__error(const char *format,...)
static bool annotate_browser__search_window(struct annotate_browser *browser, int delay_secs)
#define HE_COLORSET_NORMAL
static void annotate_browser__printf(void *browser, const char *fmt,...)
static struct annotation_line * annotate_browser__find_string(struct annotate_browser *browser, char *s, s64 *idx)
static struct annotation_line * annotate_browser__find_string_reverse(struct annotate_browser *browser, char *s, s64 *idx)
int ui_browser__show(struct ui_browser *browser, const char *title, const char *helpline,...)
static int annotation__cycles_width(struct annotation *notes)
int ui__warning(const char *format,...)
static bool annotate_browser__continue_search_reverse(struct annotate_browser *browser, int delay_secs)
struct annotation_line al
static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
static void annotate_browser__calc_percent(struct annotate_browser *browser, struct perf_evsel *evsel)
static int ui_browser__set_jumps_percent_color(void *browser, int nr, bool current)
bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2)
void ui_browser__show_title(struct ui_browser *browser, const char *title)
static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help)
struct annotation_line * selection
static struct hists * evsel__hists(struct perf_evsel *evsel)
static int annotate_browser__set_color(void *browser, int color)
bool ins__is_jump(const struct ins *ins)
struct annotation_data samples[0]
static struct disasm_line * annotate_browser__find_offset(struct annotate_browser *browser, s64 offset, s64 *idx)
int symbol__strerror_disassemble(struct symbol *sym __maybe_unused, struct map *map, int errnum, char *buf, size_t buflen)
void ui_helpline__push(const char *msg)
struct rb_node * curr_hot
static bool annotate_browser__search_reverse(struct annotate_browser *browser, int delay_secs)
void ui_browser__refresh_dimensions(struct ui_browser *browser)
struct ins_operands::@36::@39 locked
int ui_browser__help_window(struct ui_browser *browser, const char *text)
static void ui_browser__init_asm_mode(struct ui_browser *browser)
void ui_browser__gotorc_title(struct ui_browser *browser, int y, int x)
struct perf_evlist * evlist
struct annotation_options * options
static bool annotate_browser__continue_search(struct annotate_browser *browser, int delay_secs)
bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row)
#define HE_COLORSET_JUMP_ARROWS
static unsigned int annotate_browser__refresh(struct ui_browser *browser)
static bool annotation_line__filter(struct annotation_line *al, struct annotation *notes)
unsigned int ui_browser__list_head_refresh(struct ui_browser *browser)
void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int whence)
static struct disasm_line * disasm_line(struct annotation_line *al)
static bool annotate_browser__search(struct annotate_browser *browser, int delay_secs)
static int entry(u64 ip, struct unwind_info *ui)
struct annotated_source * symbol__hists(struct symbol *sym, int nr_hists)
struct ins_operands::@35 target
void symbol__annotate_decay_histogram(struct symbol *sym, int evidx)
void ui_browser__write_graph(struct ui_browser *browser __maybe_unused, int graph)
static void annotate_browser__set_rb_top(struct annotate_browser *browser, struct rb_node *nd)
void ui_helpline__puts(const char *msg)
static bool annotate_browser__toggle_source(struct annotate_browser *browser)
#define HE_COLORSET_MEDIUM
int ui_browser__input_window(const char *title, const char *text, char *input, const char *exit_msg, int delay_sec)
static struct annotation * symbol__annotation(struct symbol *sym)
int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel, struct hist_browser_timer *hbt, struct annotation_options *opts)
static bool disasm_line__filter(struct ui_browser *browser, void *entry)
static int sym_title(struct symbol *sym, struct map *map, char *title, size_t sz)
bool ins__is_lock(const struct ins *ins)
void ui_helpline__fpush(const char *fmt,...)
unsigned int(* refresh)(struct ui_browser *browser)
static struct annotation * browser__annotation(struct ui_browser *browser)
static int hists__scnprintf_title(struct hists *hists, char *bf, size_t size)
#define SYM_TITLE_MAX_SIZE
void ui_helpline__printf(const char *fmt,...)
void ui_browser__write_nstring(struct ui_browser *browser __maybe_unused, const char *msg, unsigned int width)
static bool is_fused(struct annotate_browser *ab, struct disasm_line *cursor)
static void annotate_browser__write_graph(void *browser, int graph)
bool disasm_line__is_valid_local_jump(struct disasm_line *dl, struct symbol *sym)
static void annotate_browser__set_percent_color(void *browser, double percent, bool current)
void __ui_browser__vline(struct ui_browser *browser, unsigned int column, u16 start, u16 end)
int symbol__annotate2(struct symbol *sym, struct map *map, struct perf_evsel *evsel, struct annotation_options *options, struct arch **parch)
struct annotated_source * src
void ui_helpline__pop(void)
static int sym(yyscan_t scanner, int type, int config)
static void annotate_browser__draw_current_jump(struct ui_browser *browser)
void annotated_source__purge(struct annotated_source *as)
void ui_browser__vprintf(struct ui_browser *browser __maybe_unused, const char *fmt, va_list args)
#define HE_COLORSET_SELECTED
int ui_browser__run(struct ui_browser *browser, int delay_secs)
int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel)
void(* seek)(struct ui_browser *browser, off_t offset, int whence)
static int annotate_browser__run(struct annotate_browser *browser, struct perf_evsel *evsel, struct hist_browser_timer *hbt)
static void annotate_browser__set_top(struct annotate_browser *browser, struct annotation_line *pos, u32 idx)
void ui_browser__hide(struct ui_browser *browser)
static bool annotate_browser__callq(struct annotate_browser *browser, struct perf_evsel *evsel, struct hist_browser_timer *hbt)
int ui_browser__set_color(struct ui_browser *browser, int color)
static bool annotate_browser__jump(struct annotate_browser *browser, struct perf_evsel *evsel, struct hist_browser_timer *hbt)
void ui_browser__set_percent_color(struct ui_browser *browser, double percent, bool current)
void ui_browser__mark_fused(struct ui_browser *browser, unsigned int column, unsigned int row, bool arrow_down)
#define ANNOTATION__MIN_OFFSET_LEVEL
bool ins__is_ret(const struct ins *ins)
void annotation_line__write(struct annotation_line *al, struct annotation *notes, struct annotation_write_ops *ops)
int script_browse(const char *script_opt)
static int ui_browser__jumps_percent_color(struct ui_browser *browser, int nr, bool current)
static int disasm__cmp(struct annotation_line *a, struct annotation_line *b)
void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, u64 start, u64 end)
struct annotation_line ** offsets
struct annotation_options * opts
static bool __annotate_browser__search(struct annotate_browser *browser)
static void disasm_rb_tree__insert(struct rb_root *root, struct annotation_line *al)