diff options
Diffstat (limited to 'tools/perf/ui')
-rw-r--r-- | tools/perf/ui/browser.c | 4 | ||||
-rw-r--r-- | tools/perf/ui/browser.h | 32 | ||||
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 24 | ||||
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 23 | ||||
-rw-r--r-- | tools/perf/ui/browsers/map.c | 40 | ||||
-rw-r--r-- | tools/perf/ui/browsers/map.h | 2 | ||||
-rw-r--r-- | tools/perf/ui/browsers/scripts.c | 8 | ||||
-rw-r--r-- | tools/perf/ui/gtk/annotate.c | 13 | ||||
-rw-r--r-- | tools/perf/ui/gtk/browser.c | 2 | ||||
-rw-r--r-- | tools/perf/ui/gtk/gtk.h | 22 | ||||
-rw-r--r-- | tools/perf/ui/gtk/progress.c | 20 | ||||
-rw-r--r-- | tools/perf/ui/gtk/setup.c | 2 | ||||
-rw-r--r-- | tools/perf/ui/gtk/util.c | 4 | ||||
-rw-r--r-- | tools/perf/ui/hist.c | 2 | ||||
-rw-r--r-- | tools/perf/ui/progress.c | 32 | ||||
-rw-r--r-- | tools/perf/ui/progress.h | 19 | ||||
-rw-r--r-- | tools/perf/ui/setup.c | 61 | ||||
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 14 | ||||
-rw-r--r-- | tools/perf/ui/tui/progress.c | 18 | ||||
-rw-r--r-- | tools/perf/ui/tui/setup.c | 3 | ||||
-rw-r--r-- | tools/perf/ui/tui/tui.h | 6 | ||||
-rw-r--r-- | tools/perf/ui/ui.h | 14 |
22 files changed, 135 insertions, 230 deletions
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index cbaa7af..bbc782e 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c @@ -569,7 +569,7 @@ void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence) browser->top = browser->top + browser->top_idx + offset; break; case SEEK_END: - browser->top = browser->top + browser->nr_entries - 1 + offset; + browser->top = browser->top + browser->nr_entries + offset; break; default: return; @@ -680,7 +680,7 @@ static void __ui_browser__line_arrow_down(struct ui_browser *browser, if (end >= browser->top_idx + browser->height) end_row = browser->height - 1; else - end_row = end - browser->top_idx; + end_row = end - browser->top_idx;; ui_browser__gotorc(browser, row, column); SLsmg_draw_vline(end_row - row + 1); diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h index 7d45d2f..404ff66a 100644 --- a/tools/perf/ui/browser.h +++ b/tools/perf/ui/browser.h @@ -21,32 +21,32 @@ struct ui_browser { void *priv; const char *title; char *helpline; - unsigned int (*refresh)(struct ui_browser *browser); - void (*write)(struct ui_browser *browser, void *entry, int row); - void (*seek)(struct ui_browser *browser, off_t offset, int whence); - bool (*filter)(struct ui_browser *browser, void *entry); + unsigned int (*refresh)(struct ui_browser *self); + void (*write)(struct ui_browser *self, void *entry, int row); + void (*seek)(struct ui_browser *self, off_t offset, int whence); + bool (*filter)(struct ui_browser *self, void *entry); u32 nr_entries; bool navkeypressed; bool use_navkeypressed; }; int ui_browser__set_color(struct ui_browser *browser, int color); -void ui_browser__set_percent_color(struct ui_browser *browser, +void ui_browser__set_percent_color(struct ui_browser *self, double percent, bool current); -bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row); -void ui_browser__refresh_dimensions(struct ui_browser *browser); -void ui_browser__reset_index(struct ui_browser *browser); +bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row); +void ui_browser__refresh_dimensions(struct ui_browser *self); +void ui_browser__reset_index(struct ui_browser *self); -void ui_browser__gotorc(struct ui_browser *browser, int y, int x); +void ui_browser__gotorc(struct ui_browser *self, int y, int x); void ui_browser__write_graph(struct ui_browser *browser, int graph); void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, u64 start, u64 end); void __ui_browser__show_title(struct ui_browser *browser, const char *title); void ui_browser__show_title(struct ui_browser *browser, const char *title); -int ui_browser__show(struct ui_browser *browser, const char *title, +int ui_browser__show(struct ui_browser *self, const char *title, const char *helpline, ...); -void ui_browser__hide(struct ui_browser *browser); -int ui_browser__refresh(struct ui_browser *browser); +void ui_browser__hide(struct ui_browser *self); +int ui_browser__refresh(struct ui_browser *self); int ui_browser__run(struct ui_browser *browser, int delay_secs); void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries); void ui_browser__handle_resize(struct ui_browser *browser); @@ -63,11 +63,11 @@ int ui_browser__input_window(const char *title, const char *text, char *input, void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence); unsigned int ui_browser__argv_refresh(struct ui_browser *browser); -void ui_browser__rb_tree_seek(struct ui_browser *browser, off_t offset, int whence); -unsigned int ui_browser__rb_tree_refresh(struct ui_browser *browser); +void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence); +unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self); -void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int whence); -unsigned int ui_browser__list_head_refresh(struct ui_browser *browser); +void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whence); +unsigned int ui_browser__list_head_refresh(struct ui_browser *self); void ui_browser__init(void); void annotate_browser__init(void); diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index f0697a3..08545ae 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -442,37 +442,35 @@ static bool annotate_browser__callq(struct annotate_browser *browser, { struct map_symbol *ms = browser->b.priv; struct disasm_line *dl = browser->selection; + struct symbol *sym = ms->sym; struct annotation *notes; - struct addr_map_symbol target = { - .map = ms->map, - .addr = map__objdump_2mem(ms->map, dl->ops.target.addr), - }; + struct symbol *target; + u64 ip; char title[SYM_TITLE_MAX_SIZE]; if (!ins__is_call(dl->ins)) return false; - if (map_groups__find_ams(&target, NULL) || - map__rip_2objdump(target.map, target.map->map_ip(target.map, - target.addr)) != - dl->ops.target.addr) { + ip = ms->map->map_ip(ms->map, dl->ops.target.addr); + target = map__find_symbol(ms->map, ip, NULL); + if (target == NULL) { ui_helpline__puts("The called function was not found."); return true; } - notes = symbol__annotation(target.sym); + notes = symbol__annotation(target); pthread_mutex_lock(¬es->lock); - if (notes->src == NULL && symbol__alloc_hist(target.sym) < 0) { + if (notes->src == NULL && symbol__alloc_hist(target) < 0) { pthread_mutex_unlock(¬es->lock); ui__warning("Not enough memory for annotating '%s' symbol!\n", - target.sym->name); + target->name); return true; } pthread_mutex_unlock(¬es->lock); - symbol__tui_annotate(target.sym, target.map, evsel, hbt); - sym_title(ms->sym, ms->map, title, sizeof(title)); + symbol__tui_annotate(target, ms->map, evsel, hbt); + sym_title(sym, ms->map, title, sizeof(title)); ui_browser__show_title(&browser->b, title); return true; } diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index a440e03..7ef36c3 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -1255,7 +1255,7 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size, if (thread) printed += scnprintf(bf + printed, size - printed, ", Thread: %s(%d)", - (thread->comm_set ? thread__comm_str(thread) : ""), + (thread->comm_set ? thread->comm : ""), thread->tid); if (dso) printed += scnprintf(bf + printed, size - printed, @@ -1578,7 +1578,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, if (thread != NULL && asprintf(&options[nr_options], "Zoom %s %s(%d) thread", (browser->hists->thread_filter ? "out of" : "into"), - (thread->comm_set ? thread__comm_str(thread) : ""), + (thread->comm_set ? thread->comm : ""), thread->tid) > 0) zoom_thread = nr_options++; @@ -1598,7 +1598,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, struct symbol *sym; if (asprintf(&options[nr_options], "Run scripts for samples of thread [%s]", - thread__comm_str(browser->he_selection->thread)) > 0) + browser->he_selection->thread->comm) > 0) scripts_comm = nr_options++; sym = browser->he_selection->ms.sym; @@ -1701,7 +1701,7 @@ zoom_out_thread: sort_thread.elide = false; } else { ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"", - thread->comm_set ? thread__comm_str(thread) : "", + thread->comm_set ? thread->comm : "", thread->tid); browser->hists->thread_filter = thread; sort_thread.elide = true; @@ -1717,7 +1717,7 @@ do_scripts: memset(script_opt, 0, 64); if (choice == scripts_comm) - sprintf(script_opt, " -c %s ", thread__comm_str(browser->he_selection->thread)); + sprintf(script_opt, " -c %s ", browser->he_selection->thread->comm); if (choice == scripts_symbol) sprintf(script_opt, " -S %s ", browser->he_selection->ms.sym->name); @@ -1847,15 +1847,15 @@ browse_hists: switch (key) { case K_TAB: if (pos->node.next == &evlist->entries) - pos = perf_evlist__first(evlist); + pos = list_entry(evlist->entries.next, struct perf_evsel, node); else - pos = perf_evsel__next(pos); + pos = list_entry(pos->node.next, struct perf_evsel, node); goto browse_hists; case K_UNTAB: if (pos->node.prev == &evlist->entries) - pos = perf_evlist__last(evlist); + pos = list_entry(evlist->entries.prev, struct perf_evsel, node); else - pos = perf_evsel__prev(pos); + pos = list_entry(pos->node.prev, struct perf_evsel, node); goto browse_hists; case K_ESC: if (!ui_browser__dialog_yesno(&menu->b, @@ -1889,7 +1889,7 @@ out: return key; } -static bool filter_group_entries(struct ui_browser *browser __maybe_unused, +static bool filter_group_entries(struct ui_browser *self __maybe_unused, void *entry) { struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node); @@ -1943,7 +1943,8 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, single_entry: if (nr_entries == 1) { - struct perf_evsel *first = perf_evlist__first(evlist); + struct perf_evsel *first = list_entry(evlist->entries.next, + struct perf_evsel, node); const char *ev_name = perf_evsel__name(first); return perf_evsel__hists_browse(first, nr_entries, help, diff --git a/tools/perf/ui/browsers/map.c b/tools/perf/ui/browsers/map.c index b11639f..95c7cfb 100644 --- a/tools/perf/ui/browsers/map.c +++ b/tools/perf/ui/browsers/map.c @@ -18,30 +18,30 @@ struct map_browser { u8 addrlen; }; -static void map_browser__write(struct ui_browser *browser, void *nd, int row) +static void map_browser__write(struct ui_browser *self, void *nd, int row) { struct symbol *sym = rb_entry(nd, struct symbol, rb_node); - struct map_browser *mb = container_of(browser, struct map_browser, b); - bool current_entry = ui_browser__is_current_entry(browser, row); + struct map_browser *mb = container_of(self, struct map_browser, b); + bool current_entry = ui_browser__is_current_entry(self, row); int width; - ui_browser__set_percent_color(browser, 0, current_entry); + ui_browser__set_percent_color(self, 0, current_entry); slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ", mb->addrlen, sym->start, mb->addrlen, sym->end, sym->binding == STB_GLOBAL ? 'g' : sym->binding == STB_LOCAL ? 'l' : 'w'); - width = browser->width - ((mb->addrlen * 2) + 4); + width = self->width - ((mb->addrlen * 2) + 4); if (width > 0) slsmg_write_nstring(sym->name, width); } /* FIXME uber-kludgy, see comment on cmd_report... */ -static u32 *symbol__browser_index(struct symbol *browser) +static u32 *symbol__browser_index(struct symbol *self) { - return ((void *)browser) - sizeof(struct rb_node) - sizeof(u32); + return ((void *)self) - sizeof(struct rb_node) - sizeof(u32); } -static int map_browser__search(struct map_browser *browser) +static int map_browser__search(struct map_browser *self) { char target[512]; struct symbol *sym; @@ -53,37 +53,37 @@ static int map_browser__search(struct map_browser *browser) if (target[0] == '0' && tolower(target[1]) == 'x') { u64 addr = strtoull(target, NULL, 16); - sym = map__find_symbol(browser->map, addr, NULL); + sym = map__find_symbol(self->map, addr, NULL); } else - sym = map__find_symbol_by_name(browser->map, target, NULL); + sym = map__find_symbol_by_name(self->map, target, NULL); if (sym != NULL) { u32 *idx = symbol__browser_index(sym); - browser->b.top = &sym->rb_node; - browser->b.index = browser->b.top_idx = *idx; + self->b.top = &sym->rb_node; + self->b.index = self->b.top_idx = *idx; } else ui_helpline__fpush("%s not found!", target); return 0; } -static int map_browser__run(struct map_browser *browser) +static int map_browser__run(struct map_browser *self) { int key; - if (ui_browser__show(&browser->b, browser->map->dso->long_name, + if (ui_browser__show(&self->b, self->map->dso->long_name, "Press <- or ESC to exit, %s / to search", verbose ? "" : "restart with -v to use") < 0) return -1; while (1) { - key = ui_browser__run(&browser->b, 0); + key = ui_browser__run(&self->b, 0); switch (key) { case '/': if (verbose) - map_browser__search(browser); + map_browser__search(self); default: break; case K_LEFT: @@ -94,20 +94,20 @@ static int map_browser__run(struct map_browser *browser) } } out: - ui_browser__hide(&browser->b); + ui_browser__hide(&self->b); return key; } -int map__browse(struct map *map) +int map__browse(struct map *self) { struct map_browser mb = { .b = { - .entries = &map->dso->symbols[map->type], + .entries = &self->dso->symbols[self->type], .refresh = ui_browser__rb_tree_refresh, .seek = ui_browser__rb_tree_seek, .write = map_browser__write, }, - .map = map, + .map = self, }; struct rb_node *nd; char tmp[BITS_PER_LONG / 4]; diff --git a/tools/perf/ui/browsers/map.h b/tools/perf/ui/browsers/map.h index 2d58e4b..df8581a 100644 --- a/tools/perf/ui/browsers/map.h +++ b/tools/perf/ui/browsers/map.h @@ -2,5 +2,5 @@ #define _PERF_UI_MAP_BROWSER_H_ 1 struct map; -int map__browse(struct map *map); +int map__browse(struct map *self); #endif /* _PERF_UI_MAP_BROWSER_H_ */ diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index d63c68e..12f009e 100644 --- a/tools/perf/ui/browsers/scripts.c +++ b/tools/perf/ui/browsers/scripts.c @@ -84,22 +84,22 @@ static void script_browser__write(struct ui_browser *browser, slsmg_write_nstring(sline->line, browser->width); } -static int script_browser__run(struct perf_script_browser *browser) +static int script_browser__run(struct perf_script_browser *self) { int key; - if (ui_browser__show(&browser->b, browser->script_name, + if (ui_browser__show(&self->b, self->script_name, "Press <- or ESC to exit") < 0) return -1; while (1) { - key = ui_browser__run(&browser->b, 0); + key = ui_browser__run(&self->b, 0); /* We can add some special key handling here if needed */ break; } - ui_browser__hide(&browser->b); + ui_browser__hide(&self->b); return key; } diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c index 9c7ff8d..f538794 100644 --- a/tools/perf/ui/gtk/annotate.c +++ b/tools/perf/ui/gtk/annotate.c @@ -154,9 +154,9 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym, return 0; } -static int symbol__gtk_annotate(struct symbol *sym, struct map *map, - struct perf_evsel *evsel, - struct hist_browser_timer *hbt) +int symbol__gtk_annotate(struct symbol *sym, struct map *map, + struct perf_evsel *evsel, + struct hist_browser_timer *hbt) { GtkWidget *window; GtkWidget *notebook; @@ -226,13 +226,6 @@ static int symbol__gtk_annotate(struct symbol *sym, struct map *map, return 0; } -int hist_entry__gtk_annotate(struct hist_entry *he, - struct perf_evsel *evsel, - struct hist_browser_timer *hbt) -{ - return symbol__gtk_annotate(he->ms.sym, he->ms.map, evsel, hbt); -} - void perf_gtk__show_annotations(void) { GtkWidget *window; diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c index c24d912..c95012c 100644 --- a/tools/perf/ui/gtk/browser.c +++ b/tools/perf/ui/gtk/browser.c @@ -43,7 +43,7 @@ const char *perf_gtk__get_percent_color(double percent) return NULL; } -#ifdef HAVE_GTK_INFO_BAR_SUPPORT +#ifdef HAVE_GTK_INFO_BAR GtkWidget *perf_gtk__setup_info_bar(void) { GtkWidget *info_bar; diff --git a/tools/perf/ui/gtk/gtk.h b/tools/perf/ui/gtk/gtk.h index 0a9173f..3d96785 100644 --- a/tools/perf/ui/gtk/gtk.h +++ b/tools/perf/ui/gtk/gtk.h @@ -12,7 +12,7 @@ struct perf_gtk_context { GtkWidget *main_window; GtkWidget *notebook; -#ifdef HAVE_GTK_INFO_BAR_SUPPORT +#ifdef HAVE_GTK_INFO_BAR GtkWidget *info_bar; GtkWidget *message_label; #endif @@ -20,9 +20,6 @@ struct perf_gtk_context { guint statbar_ctx_id; }; -int perf_gtk__init(void); -void perf_gtk__exit(bool wait_for_ok); - extern struct perf_gtk_context *pgctx; static inline bool perf_gtk__is_active_context(struct perf_gtk_context *ctx) @@ -34,7 +31,7 @@ struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window); int perf_gtk__deactivate_context(struct perf_gtk_context **ctx); void perf_gtk__init_helpline(void); -void gtk_ui_progress__init(void); +void perf_gtk__init_progress(void); void perf_gtk__init_hpp(void); void perf_gtk__signal(int sig); @@ -42,7 +39,7 @@ void perf_gtk__resize_window(GtkWidget *window); const char *perf_gtk__get_percent_color(double percent); GtkWidget *perf_gtk__setup_statusbar(void); -#ifdef HAVE_GTK_INFO_BAR_SUPPORT +#ifdef HAVE_GTK_INFO_BAR GtkWidget *perf_gtk__setup_info_bar(void); #else static inline GtkWidget *perf_gtk__setup_info_bar(void) @@ -51,17 +48,4 @@ static inline GtkWidget *perf_gtk__setup_info_bar(void) } #endif -struct perf_evsel; -struct perf_evlist; -struct hist_entry; -struct hist_browser_timer; - -int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help, - struct hist_browser_timer *hbt, - float min_pcnt); -int hist_entry__gtk_annotate(struct hist_entry *he, - struct perf_evsel *evsel, - struct hist_browser_timer *hbt); -void perf_gtk__show_annotations(void); - #endif /* _PERF_GTK_H_ */ diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c index b656655..482bcf3 100644 --- a/tools/perf/ui/gtk/progress.c +++ b/tools/perf/ui/gtk/progress.c @@ -7,14 +7,14 @@ static GtkWidget *dialog; static GtkWidget *progress; -static void gtk_ui_progress__update(struct ui_progress *p) +static void gtk_progress_update(u64 curr, u64 total, const char *title) { - double fraction = p->total ? 1.0 * p->curr / p->total : 0.0; + double fraction = total ? 1.0 * curr / total : 0.0; char buf[1024]; if (dialog == NULL) { GtkWidget *vbox = gtk_vbox_new(TRUE, 5); - GtkWidget *label = gtk_label_new(p->title); + GtkWidget *label = gtk_label_new(title); dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); progress = gtk_progress_bar_new(); @@ -32,7 +32,7 @@ static void gtk_ui_progress__update(struct ui_progress *p) } gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), fraction); - snprintf(buf, sizeof(buf), "%"PRIu64" / %"PRIu64, p->curr, p->total); + snprintf(buf, sizeof(buf), "%"PRIu64" / %"PRIu64, curr, total); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), buf); /* we didn't call gtk_main yet, so do it manually */ @@ -40,7 +40,7 @@ static void gtk_ui_progress__update(struct ui_progress *p) gtk_main_iteration(); } -static void gtk_ui_progress__finish(void) +static void gtk_progress_finish(void) { /* this will also destroy all of its children */ gtk_widget_destroy(dialog); @@ -48,12 +48,12 @@ static void gtk_ui_progress__finish(void) dialog = NULL; } -static struct ui_progress_ops gtk_ui_progress__ops = { - .update = gtk_ui_progress__update, - .finish = gtk_ui_progress__finish, +static struct ui_progress gtk_progress_fns = { + .update = gtk_progress_update, + .finish = gtk_progress_finish, }; -void gtk_ui_progress__init(void) +void perf_gtk__init_progress(void) { - ui_progress__ops = >k_ui_progress__ops; + progress_fns = >k_progress_fns; } diff --git a/tools/perf/ui/gtk/setup.c b/tools/perf/ui/gtk/setup.c index 1d57676..6c2dd2e 100644 --- a/tools/perf/ui/gtk/setup.c +++ b/tools/perf/ui/gtk/setup.c @@ -8,7 +8,7 @@ int perf_gtk__init(void) { perf_error__register(&perf_gtk_eops); perf_gtk__init_helpline(); - gtk_ui_progress__init(); + perf_gtk__init_progress(); perf_gtk__init_hpp(); return gtk_init_check(NULL, NULL) ? 0 : -1; diff --git a/tools/perf/ui/gtk/util.c b/tools/perf/ui/gtk/util.c index 696c1fb..c06942a 100644 --- a/tools/perf/ui/gtk/util.c +++ b/tools/perf/ui/gtk/util.c @@ -53,7 +53,7 @@ static int perf_gtk__error(const char *format, va_list args) return 0; } -#ifdef HAVE_GTK_INFO_BAR_SUPPORT +#ifdef HAVE_GTK_INFO_BAR static int perf_gtk__warning_info_bar(const char *format, va_list args) { char *msg; @@ -105,7 +105,7 @@ static int perf_gtk__warning_statusbar(const char *format, va_list args) struct perf_error_ops perf_gtk_eops = { .error = perf_gtk__error, -#ifdef HAVE_GTK_INFO_BAR_SUPPORT +#ifdef HAVE_GTK_INFO_BAR .warning = perf_gtk__warning_info_bar, #else .warning = perf_gtk__warning_statusbar, diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 78f4c92..0a19328 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -117,7 +117,7 @@ static int hpp__color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ struct perf_hpp *hpp, struct hist_entry *he) \ { \ return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \ - percent_color_snprintf, true); \ + (hpp_snprint_fn)percent_color_snprintf, true); \ } #define __HPP_ENTRY_PERCENT_FN(_type, _field) \ diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c index a0f24c7..3ec69560 100644 --- a/tools/perf/ui/progress.c +++ b/tools/perf/ui/progress.c @@ -1,38 +1,26 @@ #include "../cache.h" #include "progress.h" -static void null_progress__update(struct ui_progress *p __maybe_unused) +static void nop_progress_update(u64 curr __maybe_unused, + u64 total __maybe_unused, + const char *title __maybe_unused) { } -static struct ui_progress_ops null_progress__ops = +static struct ui_progress default_progress_fns = { - .update = null_progress__update, + .update = nop_progress_update, }; -struct ui_progress_ops *ui_progress__ops = &null_progress__ops; +struct ui_progress *progress_fns = &default_progress_fns; -void ui_progress__update(struct ui_progress *p, u64 adv) +void ui_progress__update(u64 curr, u64 total, const char *title) { - p->curr += adv; - - if (p->curr >= p->next) { - p->next += p->step; - ui_progress__ops->update(p); - } -} - -void ui_progress__init(struct ui_progress *p, u64 total, const char *title) -{ - p->curr = 0; - p->next = p->step = total / 16; - p->total = total; - p->title = title; - + return progress_fns->update(curr, total, title); } void ui_progress__finish(void) { - if (ui_progress__ops->finish) - ui_progress__ops->finish(); + if (progress_fns->finish) + progress_fns->finish(); } diff --git a/tools/perf/ui/progress.h b/tools/perf/ui/progress.h index 29ec8ef..257cc22 100644 --- a/tools/perf/ui/progress.h +++ b/tools/perf/ui/progress.h @@ -3,21 +3,16 @@ #include <../types.h> -void ui_progress__finish(void); - struct ui_progress { - const char *title; - u64 curr, next, step, total; -}; - -void ui_progress__init(struct ui_progress *p, u64 total, const char *title); -void ui_progress__update(struct ui_progress *p, u64 adv); - -struct ui_progress_ops { - void (*update)(struct ui_progress *p); + void (*update)(u64, u64, const char *); void (*finish)(void); }; -extern struct ui_progress_ops *ui_progress__ops; +extern struct ui_progress *progress_fns; + +void ui_progress__init(void); + +void ui_progress__update(u64 curr, u64 total, const char *title); +void ui_progress__finish(void); #endif diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c index 5df5140..47d9a57 100644 --- a/tools/perf/ui/setup.c +++ b/tools/perf/ui/setup.c @@ -1,64 +1,10 @@ #include <pthread.h> -#include <dlfcn.h> #include "../util/cache.h" #include "../util/debug.h" #include "../util/hist.h" pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; -void *perf_gtk_handle; - -#ifdef HAVE_GTK2_SUPPORT -static int setup_gtk_browser(void) -{ - int (*perf_ui_init)(void); - - if (perf_gtk_handle) - return 0; - - perf_gtk_handle = dlopen(PERF_GTK_DSO, RTLD_LAZY); - if (perf_gtk_handle == NULL) { - char buf[PATH_MAX]; - scnprintf(buf, sizeof(buf), "%s/%s", LIBDIR, PERF_GTK_DSO); - perf_gtk_handle = dlopen(buf, RTLD_LAZY); - } - if (perf_gtk_handle == NULL) - return -1; - - perf_ui_init = dlsym(perf_gtk_handle, "perf_gtk__init"); - if (perf_ui_init == NULL) - goto out_close; - - if (perf_ui_init() == 0) - return 0; - -out_close: - dlclose(perf_gtk_handle); - return -1; -} - -static void exit_gtk_browser(bool wait_for_ok) -{ - void (*perf_ui_exit)(bool); - - if (perf_gtk_handle == NULL) - return; - - perf_ui_exit = dlsym(perf_gtk_handle, "perf_gtk__exit"); - if (perf_ui_exit == NULL) - goto out_close; - - perf_ui_exit(wait_for_ok); - -out_close: - dlclose(perf_gtk_handle); - - perf_gtk_handle = NULL; -} -#else -static inline int setup_gtk_browser(void) { return -1; } -static inline void exit_gtk_browser(bool wait_for_ok __maybe_unused) {} -#endif void setup_browser(bool fallback_to_pager) { @@ -71,11 +17,8 @@ void setup_browser(bool fallback_to_pager) switch (use_browser) { case 2: - if (setup_gtk_browser() == 0) + if (perf_gtk__init() == 0) break; - printf("GTK browser requested but could not find %s\n", - PERF_GTK_DSO); - sleep(1); /* fall through */ case 1: use_browser = 1; @@ -96,7 +39,7 @@ void exit_browser(bool wait_for_ok) { switch (use_browser) { case 2: - exit_gtk_browser(wait_for_ok); + perf_gtk__exit(wait_for_ok); break; case 1: diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index c244cb5..6c15268 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -213,19 +213,20 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root, return ret; } -static size_t __callchain__fprintf_flat(FILE *fp, struct callchain_node *node, +static size_t __callchain__fprintf_flat(FILE *fp, + struct callchain_node *self, u64 total_samples) { struct callchain_list *chain; size_t ret = 0; - if (!node) + if (!self) return 0; - ret += __callchain__fprintf_flat(fp, node->parent, total_samples); + ret += __callchain__fprintf_flat(fp, self->parent, total_samples); - list_for_each_entry(chain, &node->val, list) { + list_for_each_entry(chain, &self->val, list) { if (chain->ip >= PERF_CONTEXT_MAX) continue; if (chain->ms.sym) @@ -238,14 +239,15 @@ static size_t __callchain__fprintf_flat(FILE *fp, struct callchain_node *node, return ret; } -static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *tree, +static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *self, u64 total_samples) { size_t ret = 0; u32 entries_printed = 0; + struct rb_node *rb_node; struct callchain_node *chain; - struct rb_node *rb_node = rb_first(tree); + rb_node = rb_first(self); while (rb_node) { double percent; diff --git a/tools/perf/ui/tui/progress.c b/tools/perf/ui/tui/progress.c index c61d14b..6c2184d 100644 --- a/tools/perf/ui/tui/progress.c +++ b/tools/perf/ui/tui/progress.c @@ -2,10 +2,9 @@ #include "../progress.h" #include "../libslang.h" #include "../ui.h" -#include "tui.h" #include "../browser.h" -static void tui_progress__update(struct ui_progress *p) +static void tui_progress__update(u64 curr, u64 total, const char *title) { int bar, y; /* @@ -15,30 +14,29 @@ static void tui_progress__update(struct ui_progress *p) if (use_browser <= 0) return; - if (p->total == 0) + if (total == 0) return; - ui__refresh_dimensions(false); + ui__refresh_dimensions(true); pthread_mutex_lock(&ui__lock); y = SLtt_Screen_Rows / 2 - 2; SLsmg_set_color(0); SLsmg_draw_box(y, 0, 3, SLtt_Screen_Cols); SLsmg_gotorc(y++, 1); - SLsmg_write_string((char *)p->title); - SLsmg_fill_region(y, 1, 1, SLtt_Screen_Cols - 2, ' '); + SLsmg_write_string((char *)title); SLsmg_set_color(HE_COLORSET_SELECTED); - bar = ((SLtt_Screen_Cols - 2) * p->curr) / p->total; + bar = ((SLtt_Screen_Cols - 2) * curr) / total; SLsmg_fill_region(y, 1, 1, bar, ' '); SLsmg_refresh(); pthread_mutex_unlock(&ui__lock); } -static struct ui_progress_ops tui_progress__ops = +static struct ui_progress tui_progress_fns = { .update = tui_progress__update, }; -void tui_progress__init(void) +void ui_progress__init(void) { - ui_progress__ops = &tui_progress__ops; + progress_fns = &tui_progress_fns; } diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c index 2f61256..b940148 100644 --- a/tools/perf/ui/tui/setup.c +++ b/tools/perf/ui/tui/setup.c @@ -9,7 +9,6 @@ #include "../util.h" #include "../libslang.h" #include "../keysyms.h" -#include "tui.h" static volatile int ui__need_resize; @@ -120,7 +119,7 @@ int ui__init(void) ui_helpline__init(); ui_browser__init(); - tui_progress__init(); + ui_progress__init(); signal(SIGSEGV, ui__signal); signal(SIGFPE, ui__signal); diff --git a/tools/perf/ui/tui/tui.h b/tools/perf/ui/tui/tui.h deleted file mode 100644 index 18961c7..0000000 --- a/tools/perf/ui/tui/tui.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _PERF_TUI_H_ -#define _PERF_TUI_H_ 1 - -void tui_progress__init(void); - -#endif /* _PERF_TUI_H_ */ diff --git a/tools/perf/ui/ui.h b/tools/perf/ui/ui.h index ab88383..70cb0d4 100644 --- a/tools/perf/ui/ui.h +++ b/tools/perf/ui/ui.h @@ -6,14 +6,13 @@ #include <linux/compiler.h> extern pthread_mutex_t ui__lock; -extern void *perf_gtk_handle; extern int use_browser; void setup_browser(bool fallback_to_pager); void exit_browser(bool wait_for_ok); -#ifdef HAVE_SLANG_SUPPORT +#ifdef SLANG_SUPPORT int ui__init(void); void ui__exit(bool wait_for_ok); #else @@ -24,6 +23,17 @@ static inline int ui__init(void) static inline void ui__exit(bool wait_for_ok __maybe_unused) {} #endif +#ifdef GTK2_SUPPORT +int perf_gtk__init(void); +void perf_gtk__exit(bool wait_for_ok); +#else +static inline int perf_gtk__init(void) +{ + return -1; +} +static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {} +#endif + void ui__refresh_dimensions(bool force); #endif /* _PERF_UI_H_ */ |