aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/ui')
-rw-r--r--tools/perf/ui/browser.c4
-rw-r--r--tools/perf/ui/browser.h32
-rw-r--r--tools/perf/ui/browsers/annotate.c24
-rw-r--r--tools/perf/ui/browsers/hists.c23
-rw-r--r--tools/perf/ui/browsers/map.c40
-rw-r--r--tools/perf/ui/browsers/map.h2
-rw-r--r--tools/perf/ui/browsers/scripts.c8
-rw-r--r--tools/perf/ui/gtk/annotate.c13
-rw-r--r--tools/perf/ui/gtk/browser.c2
-rw-r--r--tools/perf/ui/gtk/gtk.h22
-rw-r--r--tools/perf/ui/gtk/progress.c20
-rw-r--r--tools/perf/ui/gtk/setup.c2
-rw-r--r--tools/perf/ui/gtk/util.c4
-rw-r--r--tools/perf/ui/hist.c2
-rw-r--r--tools/perf/ui/progress.c32
-rw-r--r--tools/perf/ui/progress.h19
-rw-r--r--tools/perf/ui/setup.c61
-rw-r--r--tools/perf/ui/stdio/hist.c23
-rw-r--r--tools/perf/ui/tui/progress.c18
-rw-r--r--tools/perf/ui/tui/setup.c3
-rw-r--r--tools/perf/ui/tui/tui.h6
-rw-r--r--tools/perf/ui/ui.h14
22 files changed, 234 insertions, 140 deletions
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index bbc782e364b0..cbaa7af45513 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)
569 browser->top = browser->top + browser->top_idx + offset; 569 browser->top = browser->top + browser->top_idx + offset;
570 break; 570 break;
571 case SEEK_END: 571 case SEEK_END:
572 browser->top = browser->top + browser->nr_entries + offset; 572 browser->top = browser->top + browser->nr_entries - 1 + offset;
573 break; 573 break;
574 default: 574 default:
575 return; 575 return;
@@ -680,7 +680,7 @@ static void __ui_browser__line_arrow_down(struct ui_browser *browser,
680 if (end >= browser->top_idx + browser->height) 680 if (end >= browser->top_idx + browser->height)
681 end_row = browser->height - 1; 681 end_row = browser->height - 1;
682 else 682 else
683 end_row = end - browser->top_idx;; 683 end_row = end - browser->top_idx;
684 684
685 ui_browser__gotorc(browser, row, column); 685 ui_browser__gotorc(browser, row, column);
686 SLsmg_draw_vline(end_row - row + 1); 686 SLsmg_draw_vline(end_row - row + 1);
diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h
index 404ff66a3e36..7d45d2f53601 100644
--- a/tools/perf/ui/browser.h
+++ b/tools/perf/ui/browser.h
@@ -21,32 +21,32 @@ struct ui_browser {
21 void *priv; 21 void *priv;
22 const char *title; 22 const char *title;
23 char *helpline; 23 char *helpline;
24 unsigned int (*refresh)(struct ui_browser *self); 24 unsigned int (*refresh)(struct ui_browser *browser);
25 void (*write)(struct ui_browser *self, void *entry, int row); 25 void (*write)(struct ui_browser *browser, void *entry, int row);
26 void (*seek)(struct ui_browser *self, off_t offset, int whence); 26 void (*seek)(struct ui_browser *browser, off_t offset, int whence);
27 bool (*filter)(struct ui_browser *self, void *entry); 27 bool (*filter)(struct ui_browser *browser, void *entry);
28 u32 nr_entries; 28 u32 nr_entries;
29 bool navkeypressed; 29 bool navkeypressed;
30 bool use_navkeypressed; 30 bool use_navkeypressed;
31}; 31};
32 32
33int ui_browser__set_color(struct ui_browser *browser, int color); 33int ui_browser__set_color(struct ui_browser *browser, int color);
34void ui_browser__set_percent_color(struct ui_browser *self, 34void ui_browser__set_percent_color(struct ui_browser *browser,
35 double percent, bool current); 35 double percent, bool current);
36bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row); 36bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row);
37void ui_browser__refresh_dimensions(struct ui_browser *self); 37void ui_browser__refresh_dimensions(struct ui_browser *browser);
38void ui_browser__reset_index(struct ui_browser *self); 38void ui_browser__reset_index(struct ui_browser *browser);
39 39
40void ui_browser__gotorc(struct ui_browser *self, int y, int x); 40void ui_browser__gotorc(struct ui_browser *browser, int y, int x);
41void ui_browser__write_graph(struct ui_browser *browser, int graph); 41void ui_browser__write_graph(struct ui_browser *browser, int graph);
42void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column, 42void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column,
43 u64 start, u64 end); 43 u64 start, u64 end);
44void __ui_browser__show_title(struct ui_browser *browser, const char *title); 44void __ui_browser__show_title(struct ui_browser *browser, const char *title);
45void ui_browser__show_title(struct ui_browser *browser, const char *title); 45void ui_browser__show_title(struct ui_browser *browser, const char *title);
46int ui_browser__show(struct ui_browser *self, const char *title, 46int ui_browser__show(struct ui_browser *browser, const char *title,
47 const char *helpline, ...); 47 const char *helpline, ...);
48void ui_browser__hide(struct ui_browser *self); 48void ui_browser__hide(struct ui_browser *browser);
49int ui_browser__refresh(struct ui_browser *self); 49int ui_browser__refresh(struct ui_browser *browser);
50int ui_browser__run(struct ui_browser *browser, int delay_secs); 50int ui_browser__run(struct ui_browser *browser, int delay_secs);
51void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries); 51void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries);
52void ui_browser__handle_resize(struct ui_browser *browser); 52void 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,
63void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence); 63void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence);
64unsigned int ui_browser__argv_refresh(struct ui_browser *browser); 64unsigned int ui_browser__argv_refresh(struct ui_browser *browser);
65 65
66void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence); 66void ui_browser__rb_tree_seek(struct ui_browser *browser, off_t offset, int whence);
67unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self); 67unsigned int ui_browser__rb_tree_refresh(struct ui_browser *browser);
68 68
69void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whence); 69void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int whence);
70unsigned int ui_browser__list_head_refresh(struct ui_browser *self); 70unsigned int ui_browser__list_head_refresh(struct ui_browser *browser);
71 71
72void ui_browser__init(void); 72void ui_browser__init(void);
73void annotate_browser__init(void); 73void annotate_browser__init(void);
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 08545ae46992..f0697a3aede0 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -442,35 +442,37 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
442{ 442{
443 struct map_symbol *ms = browser->b.priv; 443 struct map_symbol *ms = browser->b.priv;
444 struct disasm_line *dl = browser->selection; 444 struct disasm_line *dl = browser->selection;
445 struct symbol *sym = ms->sym;
446 struct annotation *notes; 445 struct annotation *notes;
447 struct symbol *target; 446 struct addr_map_symbol target = {
448 u64 ip; 447 .map = ms->map,
448 .addr = map__objdump_2mem(ms->map, dl->ops.target.addr),
449 };
449 char title[SYM_TITLE_MAX_SIZE]; 450 char title[SYM_TITLE_MAX_SIZE];
450 451
451 if (!ins__is_call(dl->ins)) 452 if (!ins__is_call(dl->ins))
452 return false; 453 return false;
453 454
454 ip = ms->map->map_ip(ms->map, dl->ops.target.addr); 455 if (map_groups__find_ams(&target, NULL) ||
455 target = map__find_symbol(ms->map, ip, NULL); 456 map__rip_2objdump(target.map, target.map->map_ip(target.map,
456 if (target == NULL) { 457 target.addr)) !=
458 dl->ops.target.addr) {
457 ui_helpline__puts("The called function was not found."); 459 ui_helpline__puts("The called function was not found.");
458 return true; 460 return true;
459 } 461 }
460 462
461 notes = symbol__annotation(target); 463 notes = symbol__annotation(target.sym);
462 pthread_mutex_lock(&notes->lock); 464 pthread_mutex_lock(&notes->lock);
463 465
464 if (notes->src == NULL && symbol__alloc_hist(target) < 0) { 466 if (notes->src == NULL && symbol__alloc_hist(target.sym) < 0) {
465 pthread_mutex_unlock(&notes->lock); 467 pthread_mutex_unlock(&notes->lock);
466 ui__warning("Not enough memory for annotating '%s' symbol!\n", 468 ui__warning("Not enough memory for annotating '%s' symbol!\n",
467 target->name); 469 target.sym->name);
468 return true; 470 return true;
469 } 471 }
470 472
471 pthread_mutex_unlock(&notes->lock); 473 pthread_mutex_unlock(&notes->lock);
472 symbol__tui_annotate(target, ms->map, evsel, hbt); 474 symbol__tui_annotate(target.sym, target.map, evsel, hbt);
473 sym_title(sym, ms->map, title, sizeof(title)); 475 sym_title(ms->sym, ms->map, title, sizeof(title));
474 ui_browser__show_title(&browser->b, title); 476 ui_browser__show_title(&browser->b, title);
475 return true; 477 return true;
476} 478}
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 7ef36c360471..a440e03cd8c2 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,
1255 if (thread) 1255 if (thread)
1256 printed += scnprintf(bf + printed, size - printed, 1256 printed += scnprintf(bf + printed, size - printed,
1257 ", Thread: %s(%d)", 1257 ", Thread: %s(%d)",
1258 (thread->comm_set ? thread->comm : ""), 1258 (thread->comm_set ? thread__comm_str(thread) : ""),
1259 thread->tid); 1259 thread->tid);
1260 if (dso) 1260 if (dso)
1261 printed += scnprintf(bf + printed, size - printed, 1261 printed += scnprintf(bf + printed, size - printed,
@@ -1578,7 +1578,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1578 if (thread != NULL && 1578 if (thread != NULL &&
1579 asprintf(&options[nr_options], "Zoom %s %s(%d) thread", 1579 asprintf(&options[nr_options], "Zoom %s %s(%d) thread",
1580 (browser->hists->thread_filter ? "out of" : "into"), 1580 (browser->hists->thread_filter ? "out of" : "into"),
1581 (thread->comm_set ? thread->comm : ""), 1581 (thread->comm_set ? thread__comm_str(thread) : ""),
1582 thread->tid) > 0) 1582 thread->tid) > 0)
1583 zoom_thread = nr_options++; 1583 zoom_thread = nr_options++;
1584 1584
@@ -1598,7 +1598,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1598 struct symbol *sym; 1598 struct symbol *sym;
1599 1599
1600 if (asprintf(&options[nr_options], "Run scripts for samples of thread [%s]", 1600 if (asprintf(&options[nr_options], "Run scripts for samples of thread [%s]",
1601 browser->he_selection->thread->comm) > 0) 1601 thread__comm_str(browser->he_selection->thread)) > 0)
1602 scripts_comm = nr_options++; 1602 scripts_comm = nr_options++;
1603 1603
1604 sym = browser->he_selection->ms.sym; 1604 sym = browser->he_selection->ms.sym;
@@ -1701,7 +1701,7 @@ zoom_out_thread:
1701 sort_thread.elide = false; 1701 sort_thread.elide = false;
1702 } else { 1702 } else {
1703 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"", 1703 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"",
1704 thread->comm_set ? thread->comm : "", 1704 thread->comm_set ? thread__comm_str(thread) : "",
1705 thread->tid); 1705 thread->tid);
1706 browser->hists->thread_filter = thread; 1706 browser->hists->thread_filter = thread;
1707 sort_thread.elide = true; 1707 sort_thread.elide = true;
@@ -1717,7 +1717,7 @@ do_scripts:
1717 memset(script_opt, 0, 64); 1717 memset(script_opt, 0, 64);
1718 1718
1719 if (choice == scripts_comm) 1719 if (choice == scripts_comm)
1720 sprintf(script_opt, " -c %s ", browser->he_selection->thread->comm); 1720 sprintf(script_opt, " -c %s ", thread__comm_str(browser->he_selection->thread));
1721 1721
1722 if (choice == scripts_symbol) 1722 if (choice == scripts_symbol)
1723 sprintf(script_opt, " -S %s ", browser->he_selection->ms.sym->name); 1723 sprintf(script_opt, " -S %s ", browser->he_selection->ms.sym->name);
@@ -1847,15 +1847,15 @@ browse_hists:
1847 switch (key) { 1847 switch (key) {
1848 case K_TAB: 1848 case K_TAB:
1849 if (pos->node.next == &evlist->entries) 1849 if (pos->node.next == &evlist->entries)
1850 pos = list_entry(evlist->entries.next, struct perf_evsel, node); 1850 pos = perf_evlist__first(evlist);
1851 else 1851 else
1852 pos = list_entry(pos->node.next, struct perf_evsel, node); 1852 pos = perf_evsel__next(pos);
1853 goto browse_hists; 1853 goto browse_hists;
1854 case K_UNTAB: 1854 case K_UNTAB:
1855 if (pos->node.prev == &evlist->entries) 1855 if (pos->node.prev == &evlist->entries)
1856 pos = list_entry(evlist->entries.prev, struct perf_evsel, node); 1856 pos = perf_evlist__last(evlist);
1857 else 1857 else
1858 pos = list_entry(pos->node.prev, struct perf_evsel, node); 1858 pos = perf_evsel__prev(pos);
1859 goto browse_hists; 1859 goto browse_hists;
1860 case K_ESC: 1860 case K_ESC:
1861 if (!ui_browser__dialog_yesno(&menu->b, 1861 if (!ui_browser__dialog_yesno(&menu->b,
@@ -1889,7 +1889,7 @@ out:
1889 return key; 1889 return key;
1890} 1890}
1891 1891
1892static bool filter_group_entries(struct ui_browser *self __maybe_unused, 1892static bool filter_group_entries(struct ui_browser *browser __maybe_unused,
1893 void *entry) 1893 void *entry)
1894{ 1894{
1895 struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node); 1895 struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node);
@@ -1943,8 +1943,7 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
1943 1943
1944single_entry: 1944single_entry:
1945 if (nr_entries == 1) { 1945 if (nr_entries == 1) {
1946 struct perf_evsel *first = list_entry(evlist->entries.next, 1946 struct perf_evsel *first = perf_evlist__first(evlist);
1947 struct perf_evsel, node);
1948 const char *ev_name = perf_evsel__name(first); 1947 const char *ev_name = perf_evsel__name(first);
1949 1948
1950 return perf_evsel__hists_browse(first, nr_entries, help, 1949 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 95c7cfb8f2c6..b11639f33682 100644
--- a/tools/perf/ui/browsers/map.c
+++ b/tools/perf/ui/browsers/map.c
@@ -18,30 +18,30 @@ struct map_browser {
18 u8 addrlen; 18 u8 addrlen;
19}; 19};
20 20
21static void map_browser__write(struct ui_browser *self, void *nd, int row) 21static void map_browser__write(struct ui_browser *browser, void *nd, int row)
22{ 22{
23 struct symbol *sym = rb_entry(nd, struct symbol, rb_node); 23 struct symbol *sym = rb_entry(nd, struct symbol, rb_node);
24 struct map_browser *mb = container_of(self, struct map_browser, b); 24 struct map_browser *mb = container_of(browser, struct map_browser, b);
25 bool current_entry = ui_browser__is_current_entry(self, row); 25 bool current_entry = ui_browser__is_current_entry(browser, row);
26 int width; 26 int width;
27 27
28 ui_browser__set_percent_color(self, 0, current_entry); 28 ui_browser__set_percent_color(browser, 0, current_entry);
29 slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ", 29 slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ",
30 mb->addrlen, sym->start, mb->addrlen, sym->end, 30 mb->addrlen, sym->start, mb->addrlen, sym->end,
31 sym->binding == STB_GLOBAL ? 'g' : 31 sym->binding == STB_GLOBAL ? 'g' :
32 sym->binding == STB_LOCAL ? 'l' : 'w'); 32 sym->binding == STB_LOCAL ? 'l' : 'w');
33 width = self->width - ((mb->addrlen * 2) + 4); 33 width = browser->width - ((mb->addrlen * 2) + 4);
34 if (width > 0) 34 if (width > 0)
35 slsmg_write_nstring(sym->name, width); 35 slsmg_write_nstring(sym->name, width);
36} 36}
37 37
38/* FIXME uber-kludgy, see comment on cmd_report... */ 38/* FIXME uber-kludgy, see comment on cmd_report... */
39static u32 *symbol__browser_index(struct symbol *self) 39static u32 *symbol__browser_index(struct symbol *browser)
40{ 40{
41 return ((void *)self) - sizeof(struct rb_node) - sizeof(u32); 41 return ((void *)browser) - sizeof(struct rb_node) - sizeof(u32);
42} 42}
43 43
44static int map_browser__search(struct map_browser *self) 44static int map_browser__search(struct map_browser *browser)
45{ 45{
46 char target[512]; 46 char target[512];
47 struct symbol *sym; 47 struct symbol *sym;
@@ -53,37 +53,37 @@ static int map_browser__search(struct map_browser *self)
53 53
54 if (target[0] == '0' && tolower(target[1]) == 'x') { 54 if (target[0] == '0' && tolower(target[1]) == 'x') {
55 u64 addr = strtoull(target, NULL, 16); 55 u64 addr = strtoull(target, NULL, 16);
56 sym = map__find_symbol(self->map, addr, NULL); 56 sym = map__find_symbol(browser->map, addr, NULL);
57 } else 57 } else
58 sym = map__find_symbol_by_name(self->map, target, NULL); 58 sym = map__find_symbol_by_name(browser->map, target, NULL);
59 59
60 if (sym != NULL) { 60 if (sym != NULL) {
61 u32 *idx = symbol__browser_index(sym); 61 u32 *idx = symbol__browser_index(sym);
62 62
63 self->b.top = &sym->rb_node; 63 browser->b.top = &sym->rb_node;
64 self->b.index = self->b.top_idx = *idx; 64 browser->b.index = browser->b.top_idx = *idx;
65 } else 65 } else
66 ui_helpline__fpush("%s not found!", target); 66 ui_helpline__fpush("%s not found!", target);
67 67
68 return 0; 68 return 0;
69} 69}
70 70
71static int map_browser__run(struct map_browser *self) 71static int map_browser__run(struct map_browser *browser)
72{ 72{
73 int key; 73 int key;
74 74
75 if (ui_browser__show(&self->b, self->map->dso->long_name, 75 if (ui_browser__show(&browser->b, browser->map->dso->long_name,
76 "Press <- or ESC to exit, %s / to search", 76 "Press <- or ESC to exit, %s / to search",
77 verbose ? "" : "restart with -v to use") < 0) 77 verbose ? "" : "restart with -v to use") < 0)
78 return -1; 78 return -1;
79 79
80 while (1) { 80 while (1) {
81 key = ui_browser__run(&self->b, 0); 81 key = ui_browser__run(&browser->b, 0);
82 82
83 switch (key) { 83 switch (key) {
84 case '/': 84 case '/':
85 if (verbose) 85 if (verbose)
86 map_browser__search(self); 86 map_browser__search(browser);
87 default: 87 default:
88 break; 88 break;
89 case K_LEFT: 89 case K_LEFT:
@@ -94,20 +94,20 @@ static int map_browser__run(struct map_browser *self)
94 } 94 }
95 } 95 }
96out: 96out:
97 ui_browser__hide(&self->b); 97 ui_browser__hide(&browser->b);
98 return key; 98 return key;
99} 99}
100 100
101int map__browse(struct map *self) 101int map__browse(struct map *map)
102{ 102{
103 struct map_browser mb = { 103 struct map_browser mb = {
104 .b = { 104 .b = {
105 .entries = &self->dso->symbols[self->type], 105 .entries = &map->dso->symbols[map->type],
106 .refresh = ui_browser__rb_tree_refresh, 106 .refresh = ui_browser__rb_tree_refresh,
107 .seek = ui_browser__rb_tree_seek, 107 .seek = ui_browser__rb_tree_seek,
108 .write = map_browser__write, 108 .write = map_browser__write,
109 }, 109 },
110 .map = self, 110 .map = map,
111 }; 111 };
112 struct rb_node *nd; 112 struct rb_node *nd;
113 char tmp[BITS_PER_LONG / 4]; 113 char tmp[BITS_PER_LONG / 4];
diff --git a/tools/perf/ui/browsers/map.h b/tools/perf/ui/browsers/map.h
index df8581a43e17..2d58e4b3eb6f 100644
--- a/tools/perf/ui/browsers/map.h
+++ b/tools/perf/ui/browsers/map.h
@@ -2,5 +2,5 @@
2#define _PERF_UI_MAP_BROWSER_H_ 1 2#define _PERF_UI_MAP_BROWSER_H_ 1
3struct map; 3struct map;
4 4
5int map__browse(struct map *self); 5int map__browse(struct map *map);
6#endif /* _PERF_UI_MAP_BROWSER_H_ */ 6#endif /* _PERF_UI_MAP_BROWSER_H_ */
diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
index 12f009e61e94..d63c68ea02a8 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,
84 slsmg_write_nstring(sline->line, browser->width); 84 slsmg_write_nstring(sline->line, browser->width);
85} 85}
86 86
87static int script_browser__run(struct perf_script_browser *self) 87static int script_browser__run(struct perf_script_browser *browser)
88{ 88{
89 int key; 89 int key;
90 90
91 if (ui_browser__show(&self->b, self->script_name, 91 if (ui_browser__show(&browser->b, browser->script_name,
92 "Press <- or ESC to exit") < 0) 92 "Press <- or ESC to exit") < 0)
93 return -1; 93 return -1;
94 94
95 while (1) { 95 while (1) {
96 key = ui_browser__run(&self->b, 0); 96 key = ui_browser__run(&browser->b, 0);
97 97
98 /* We can add some special key handling here if needed */ 98 /* We can add some special key handling here if needed */
99 break; 99 break;
100 } 100 }
101 101
102 ui_browser__hide(&self->b); 102 ui_browser__hide(&browser->b);
103 return key; 103 return key;
104} 104}
105 105
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
index f538794615db..9c7ff8d31b27 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,
154 return 0; 154 return 0;
155} 155}
156 156
157int symbol__gtk_annotate(struct symbol *sym, struct map *map, 157static int symbol__gtk_annotate(struct symbol *sym, struct map *map,
158 struct perf_evsel *evsel, 158 struct perf_evsel *evsel,
159 struct hist_browser_timer *hbt) 159 struct hist_browser_timer *hbt)
160{ 160{
161 GtkWidget *window; 161 GtkWidget *window;
162 GtkWidget *notebook; 162 GtkWidget *notebook;
@@ -226,6 +226,13 @@ int symbol__gtk_annotate(struct symbol *sym, struct map *map,
226 return 0; 226 return 0;
227} 227}
228 228
229int hist_entry__gtk_annotate(struct hist_entry *he,
230 struct perf_evsel *evsel,
231 struct hist_browser_timer *hbt)
232{
233 return symbol__gtk_annotate(he->ms.sym, he->ms.map, evsel, hbt);
234}
235
229void perf_gtk__show_annotations(void) 236void perf_gtk__show_annotations(void)
230{ 237{
231 GtkWidget *window; 238 GtkWidget *window;
diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c
index c95012cdb438..c24d91221290 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)
43 return NULL; 43 return NULL;
44} 44}
45 45
46#ifdef HAVE_GTK_INFO_BAR 46#ifdef HAVE_GTK_INFO_BAR_SUPPORT
47GtkWidget *perf_gtk__setup_info_bar(void) 47GtkWidget *perf_gtk__setup_info_bar(void)
48{ 48{
49 GtkWidget *info_bar; 49 GtkWidget *info_bar;
diff --git a/tools/perf/ui/gtk/gtk.h b/tools/perf/ui/gtk/gtk.h
index 3d96785ef155..0a9173ff9a61 100644
--- a/tools/perf/ui/gtk/gtk.h
+++ b/tools/perf/ui/gtk/gtk.h
@@ -12,7 +12,7 @@ struct perf_gtk_context {
12 GtkWidget *main_window; 12 GtkWidget *main_window;
13 GtkWidget *notebook; 13 GtkWidget *notebook;
14 14
15#ifdef HAVE_GTK_INFO_BAR 15#ifdef HAVE_GTK_INFO_BAR_SUPPORT
16 GtkWidget *info_bar; 16 GtkWidget *info_bar;
17 GtkWidget *message_label; 17 GtkWidget *message_label;
18#endif 18#endif
@@ -20,6 +20,9 @@ struct perf_gtk_context {
20 guint statbar_ctx_id; 20 guint statbar_ctx_id;
21}; 21};
22 22
23int perf_gtk__init(void);
24void perf_gtk__exit(bool wait_for_ok);
25
23extern struct perf_gtk_context *pgctx; 26extern struct perf_gtk_context *pgctx;
24 27
25static inline bool perf_gtk__is_active_context(struct perf_gtk_context *ctx) 28static inline bool perf_gtk__is_active_context(struct perf_gtk_context *ctx)
@@ -31,7 +34,7 @@ struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window);
31int perf_gtk__deactivate_context(struct perf_gtk_context **ctx); 34int perf_gtk__deactivate_context(struct perf_gtk_context **ctx);
32 35
33void perf_gtk__init_helpline(void); 36void perf_gtk__init_helpline(void);
34void perf_gtk__init_progress(void); 37void gtk_ui_progress__init(void);
35void perf_gtk__init_hpp(void); 38void perf_gtk__init_hpp(void);
36 39
37void perf_gtk__signal(int sig); 40void perf_gtk__signal(int sig);
@@ -39,7 +42,7 @@ void perf_gtk__resize_window(GtkWidget *window);
39const char *perf_gtk__get_percent_color(double percent); 42const char *perf_gtk__get_percent_color(double percent);
40GtkWidget *perf_gtk__setup_statusbar(void); 43GtkWidget *perf_gtk__setup_statusbar(void);
41 44
42#ifdef HAVE_GTK_INFO_BAR 45#ifdef HAVE_GTK_INFO_BAR_SUPPORT
43GtkWidget *perf_gtk__setup_info_bar(void); 46GtkWidget *perf_gtk__setup_info_bar(void);
44#else 47#else
45static inline GtkWidget *perf_gtk__setup_info_bar(void) 48static inline GtkWidget *perf_gtk__setup_info_bar(void)
@@ -48,4 +51,17 @@ static inline GtkWidget *perf_gtk__setup_info_bar(void)
48} 51}
49#endif 52#endif
50 53
54struct perf_evsel;
55struct perf_evlist;
56struct hist_entry;
57struct hist_browser_timer;
58
59int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help,
60 struct hist_browser_timer *hbt,
61 float min_pcnt);
62int hist_entry__gtk_annotate(struct hist_entry *he,
63 struct perf_evsel *evsel,
64 struct hist_browser_timer *hbt);
65void perf_gtk__show_annotations(void);
66
51#endif /* _PERF_GTK_H_ */ 67#endif /* _PERF_GTK_H_ */
diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c
index 482bcf3df9b7..b656655fbc39 100644
--- a/tools/perf/ui/gtk/progress.c
+++ b/tools/perf/ui/gtk/progress.c
@@ -7,14 +7,14 @@
7static GtkWidget *dialog; 7static GtkWidget *dialog;
8static GtkWidget *progress; 8static GtkWidget *progress;
9 9
10static void gtk_progress_update(u64 curr, u64 total, const char *title) 10static void gtk_ui_progress__update(struct ui_progress *p)
11{ 11{
12 double fraction = total ? 1.0 * curr / total : 0.0; 12 double fraction = p->total ? 1.0 * p->curr / p->total : 0.0;
13 char buf[1024]; 13 char buf[1024];
14 14
15 if (dialog == NULL) { 15 if (dialog == NULL) {
16 GtkWidget *vbox = gtk_vbox_new(TRUE, 5); 16 GtkWidget *vbox = gtk_vbox_new(TRUE, 5);
17 GtkWidget *label = gtk_label_new(title); 17 GtkWidget *label = gtk_label_new(p->title);
18 18
19 dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); 19 dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
20 progress = gtk_progress_bar_new(); 20 progress = gtk_progress_bar_new();
@@ -32,7 +32,7 @@ static void gtk_progress_update(u64 curr, u64 total, const char *title)
32 } 32 }
33 33
34 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), fraction); 34 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), fraction);
35 snprintf(buf, sizeof(buf), "%"PRIu64" / %"PRIu64, curr, total); 35 snprintf(buf, sizeof(buf), "%"PRIu64" / %"PRIu64, p->curr, p->total);
36 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), buf); 36 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), buf);
37 37
38 /* we didn't call gtk_main yet, so do it manually */ 38 /* we didn't call gtk_main yet, so do it manually */
@@ -40,7 +40,7 @@ static void gtk_progress_update(u64 curr, u64 total, const char *title)
40 gtk_main_iteration(); 40 gtk_main_iteration();
41} 41}
42 42
43static void gtk_progress_finish(void) 43static void gtk_ui_progress__finish(void)
44{ 44{
45 /* this will also destroy all of its children */ 45 /* this will also destroy all of its children */
46 gtk_widget_destroy(dialog); 46 gtk_widget_destroy(dialog);
@@ -48,12 +48,12 @@ static void gtk_progress_finish(void)
48 dialog = NULL; 48 dialog = NULL;
49} 49}
50 50
51static struct ui_progress gtk_progress_fns = { 51static struct ui_progress_ops gtk_ui_progress__ops = {
52 .update = gtk_progress_update, 52 .update = gtk_ui_progress__update,
53 .finish = gtk_progress_finish, 53 .finish = gtk_ui_progress__finish,
54}; 54};
55 55
56void perf_gtk__init_progress(void) 56void gtk_ui_progress__init(void)
57{ 57{
58 progress_fns = &gtk_progress_fns; 58 ui_progress__ops = &gtk_ui_progress__ops;
59} 59}
diff --git a/tools/perf/ui/gtk/setup.c b/tools/perf/ui/gtk/setup.c
index 6c2dd2e423f3..1d57676f8212 100644
--- a/tools/perf/ui/gtk/setup.c
+++ b/tools/perf/ui/gtk/setup.c
@@ -8,7 +8,7 @@ int perf_gtk__init(void)
8{ 8{
9 perf_error__register(&perf_gtk_eops); 9 perf_error__register(&perf_gtk_eops);
10 perf_gtk__init_helpline(); 10 perf_gtk__init_helpline();
11 perf_gtk__init_progress(); 11 gtk_ui_progress__init();
12 perf_gtk__init_hpp(); 12 perf_gtk__init_hpp();
13 13
14 return gtk_init_check(NULL, NULL) ? 0 : -1; 14 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 c06942a41c78..696c1fbe4248 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)
53 return 0; 53 return 0;
54} 54}
55 55
56#ifdef HAVE_GTK_INFO_BAR 56#ifdef HAVE_GTK_INFO_BAR_SUPPORT
57static int perf_gtk__warning_info_bar(const char *format, va_list args) 57static int perf_gtk__warning_info_bar(const char *format, va_list args)
58{ 58{
59 char *msg; 59 char *msg;
@@ -105,7 +105,7 @@ static int perf_gtk__warning_statusbar(const char *format, va_list args)
105 105
106struct perf_error_ops perf_gtk_eops = { 106struct perf_error_ops perf_gtk_eops = {
107 .error = perf_gtk__error, 107 .error = perf_gtk__error,
108#ifdef HAVE_GTK_INFO_BAR 108#ifdef HAVE_GTK_INFO_BAR_SUPPORT
109 .warning = perf_gtk__warning_info_bar, 109 .warning = perf_gtk__warning_info_bar,
110#else 110#else
111 .warning = perf_gtk__warning_statusbar, 111 .warning = perf_gtk__warning_statusbar,
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 0a193281eba8..78f4c92e9b73 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, \
117 struct perf_hpp *hpp, struct hist_entry *he) \ 117 struct perf_hpp *hpp, struct hist_entry *he) \
118{ \ 118{ \
119 return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \ 119 return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \
120 (hpp_snprint_fn)percent_color_snprintf, true); \ 120 percent_color_snprintf, true); \
121} 121}
122 122
123#define __HPP_ENTRY_PERCENT_FN(_type, _field) \ 123#define __HPP_ENTRY_PERCENT_FN(_type, _field) \
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c
index 3ec695607a4d..a0f24c7115c5 100644
--- a/tools/perf/ui/progress.c
+++ b/tools/perf/ui/progress.c
@@ -1,26 +1,38 @@
1#include "../cache.h" 1#include "../cache.h"
2#include "progress.h" 2#include "progress.h"
3 3
4static void nop_progress_update(u64 curr __maybe_unused, 4static void null_progress__update(struct ui_progress *p __maybe_unused)
5 u64 total __maybe_unused,
6 const char *title __maybe_unused)
7{ 5{
8} 6}
9 7
10static struct ui_progress default_progress_fns = 8static struct ui_progress_ops null_progress__ops =
11{ 9{
12 .update = nop_progress_update, 10 .update = null_progress__update,
13}; 11};
14 12
15struct ui_progress *progress_fns = &default_progress_fns; 13struct ui_progress_ops *ui_progress__ops = &null_progress__ops;
16 14
17void ui_progress__update(u64 curr, u64 total, const char *title) 15void ui_progress__update(struct ui_progress *p, u64 adv)
18{ 16{
19 return progress_fns->update(curr, total, title); 17 p->curr += adv;
18
19 if (p->curr >= p->next) {
20 p->next += p->step;
21 ui_progress__ops->update(p);
22 }
23}
24
25void ui_progress__init(struct ui_progress *p, u64 total, const char *title)
26{
27 p->curr = 0;
28 p->next = p->step = total / 16;
29 p->total = total;
30 p->title = title;
31
20} 32}
21 33
22void ui_progress__finish(void) 34void ui_progress__finish(void)
23{ 35{
24 if (progress_fns->finish) 36 if (ui_progress__ops->finish)
25 progress_fns->finish(); 37 ui_progress__ops->finish();
26} 38}
diff --git a/tools/perf/ui/progress.h b/tools/perf/ui/progress.h
index 257cc224f9cf..29ec8efffefb 100644
--- a/tools/perf/ui/progress.h
+++ b/tools/perf/ui/progress.h
@@ -3,16 +3,21 @@
3 3
4#include <../types.h> 4#include <../types.h>
5 5
6void ui_progress__finish(void);
7
6struct ui_progress { 8struct ui_progress {
7 void (*update)(u64, u64, const char *); 9 const char *title;
8 void (*finish)(void); 10 u64 curr, next, step, total;
9}; 11};
12
13void ui_progress__init(struct ui_progress *p, u64 total, const char *title);
14void ui_progress__update(struct ui_progress *p, u64 adv);
10 15
11extern struct ui_progress *progress_fns; 16struct ui_progress_ops {
12 17 void (*update)(struct ui_progress *p);
13void ui_progress__init(void); 18 void (*finish)(void);
19};
14 20
15void ui_progress__update(u64 curr, u64 total, const char *title); 21extern struct ui_progress_ops *ui_progress__ops;
16void ui_progress__finish(void);
17 22
18#endif 23#endif
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 47d9a571f261..5df5140a9f29 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -1,10 +1,64 @@
1#include <pthread.h> 1#include <pthread.h>
2#include <dlfcn.h>
2 3
3#include "../util/cache.h" 4#include "../util/cache.h"
4#include "../util/debug.h" 5#include "../util/debug.h"
5#include "../util/hist.h" 6#include "../util/hist.h"
6 7
7pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; 8pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
9void *perf_gtk_handle;
10
11#ifdef HAVE_GTK2_SUPPORT
12static int setup_gtk_browser(void)
13{
14 int (*perf_ui_init)(void);
15
16 if (perf_gtk_handle)
17 return 0;
18
19 perf_gtk_handle = dlopen(PERF_GTK_DSO, RTLD_LAZY);
20 if (perf_gtk_handle == NULL) {
21 char buf[PATH_MAX];
22 scnprintf(buf, sizeof(buf), "%s/%s", LIBDIR, PERF_GTK_DSO);
23 perf_gtk_handle = dlopen(buf, RTLD_LAZY);
24 }
25 if (perf_gtk_handle == NULL)
26 return -1;
27
28 perf_ui_init = dlsym(perf_gtk_handle, "perf_gtk__init");
29 if (perf_ui_init == NULL)
30 goto out_close;
31
32 if (perf_ui_init() == 0)
33 return 0;
34
35out_close:
36 dlclose(perf_gtk_handle);
37 return -1;
38}
39
40static void exit_gtk_browser(bool wait_for_ok)
41{
42 void (*perf_ui_exit)(bool);
43
44 if (perf_gtk_handle == NULL)
45 return;
46
47 perf_ui_exit = dlsym(perf_gtk_handle, "perf_gtk__exit");
48 if (perf_ui_exit == NULL)
49 goto out_close;
50
51 perf_ui_exit(wait_for_ok);
52
53out_close:
54 dlclose(perf_gtk_handle);
55
56 perf_gtk_handle = NULL;
57}
58#else
59static inline int setup_gtk_browser(void) { return -1; }
60static inline void exit_gtk_browser(bool wait_for_ok __maybe_unused) {}
61#endif
8 62
9void setup_browser(bool fallback_to_pager) 63void setup_browser(bool fallback_to_pager)
10{ 64{
@@ -17,8 +71,11 @@ void setup_browser(bool fallback_to_pager)
17 71
18 switch (use_browser) { 72 switch (use_browser) {
19 case 2: 73 case 2:
20 if (perf_gtk__init() == 0) 74 if (setup_gtk_browser() == 0)
21 break; 75 break;
76 printf("GTK browser requested but could not find %s\n",
77 PERF_GTK_DSO);
78 sleep(1);
22 /* fall through */ 79 /* fall through */
23 case 1: 80 case 1:
24 use_browser = 1; 81 use_browser = 1;
@@ -39,7 +96,7 @@ void exit_browser(bool wait_for_ok)
39{ 96{
40 switch (use_browser) { 97 switch (use_browser) {
41 case 2: 98 case 2:
42 perf_gtk__exit(wait_for_ok); 99 exit_gtk_browser(wait_for_ok);
43 break; 100 break;
44 101
45 case 1: 102 case 1:
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 194e2f42ff5d..c244cb524ef2 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -213,20 +213,19 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
213 return ret; 213 return ret;
214} 214}
215 215
216static size_t __callchain__fprintf_flat(FILE *fp, 216static size_t __callchain__fprintf_flat(FILE *fp, struct callchain_node *node,
217 struct callchain_node *self,
218 u64 total_samples) 217 u64 total_samples)
219{ 218{
220 struct callchain_list *chain; 219 struct callchain_list *chain;
221 size_t ret = 0; 220 size_t ret = 0;
222 221
223 if (!self) 222 if (!node)
224 return 0; 223 return 0;
225 224
226 ret += __callchain__fprintf_flat(fp, self->parent, total_samples); 225 ret += __callchain__fprintf_flat(fp, node->parent, total_samples);
227 226
228 227
229 list_for_each_entry(chain, &self->val, list) { 228 list_for_each_entry(chain, &node->val, list) {
230 if (chain->ip >= PERF_CONTEXT_MAX) 229 if (chain->ip >= PERF_CONTEXT_MAX)
231 continue; 230 continue;
232 if (chain->ms.sym) 231 if (chain->ms.sym)
@@ -239,15 +238,14 @@ static size_t __callchain__fprintf_flat(FILE *fp,
239 return ret; 238 return ret;
240} 239}
241 240
242static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *self, 241static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *tree,
243 u64 total_samples) 242 u64 total_samples)
244{ 243{
245 size_t ret = 0; 244 size_t ret = 0;
246 u32 entries_printed = 0; 245 u32 entries_printed = 0;
247 struct rb_node *rb_node;
248 struct callchain_node *chain; 246 struct callchain_node *chain;
247 struct rb_node *rb_node = rb_first(tree);
249 248
250 rb_node = rb_first(self);
251 while (rb_node) { 249 while (rb_node) {
252 double percent; 250 double percent;
253 251
@@ -315,8 +313,7 @@ static inline void advance_hpp(struct perf_hpp *hpp, int inc)
315} 313}
316 314
317static int hist_entry__period_snprintf(struct perf_hpp *hpp, 315static int hist_entry__period_snprintf(struct perf_hpp *hpp,
318 struct hist_entry *he, 316 struct hist_entry *he)
319 bool color)
320{ 317{
321 const char *sep = symbol_conf.field_sep; 318 const char *sep = symbol_conf.field_sep;
322 struct perf_hpp_fmt *fmt; 319 struct perf_hpp_fmt *fmt;
@@ -338,7 +335,7 @@ static int hist_entry__period_snprintf(struct perf_hpp *hpp,
338 } else 335 } else
339 first = false; 336 first = false;
340 337
341 if (color && fmt->color) 338 if (perf_hpp__use_color() && fmt->color)
342 ret = fmt->color(fmt, hpp, he); 339 ret = fmt->color(fmt, hpp, he);
343 else 340 else
344 ret = fmt->entry(fmt, hpp, he); 341 ret = fmt->entry(fmt, hpp, he);
@@ -358,12 +355,11 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
358 .buf = bf, 355 .buf = bf,
359 .size = size, 356 .size = size,
360 }; 357 };
361 bool color = !symbol_conf.field_sep;
362 358
363 if (size == 0 || size > bfsz) 359 if (size == 0 || size > bfsz)
364 size = hpp.size = bfsz; 360 size = hpp.size = bfsz;
365 361
366 ret = hist_entry__period_snprintf(&hpp, he, color); 362 ret = hist_entry__period_snprintf(&hpp, he);
367 hist_entry__sort_snprintf(he, bf + ret, size - ret, hists); 363 hist_entry__sort_snprintf(he, bf + ret, size - ret, hists);
368 364
369 ret = fprintf(fp, "%s\n", bf); 365 ret = fprintf(fp, "%s\n", bf);
@@ -482,6 +478,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
482 478
483print_entries: 479print_entries:
484 linesz = hists__sort_list_width(hists) + 3 + 1; 480 linesz = hists__sort_list_width(hists) + 3 + 1;
481 linesz += perf_hpp__color_overhead();
485 line = malloc(linesz); 482 line = malloc(linesz);
486 if (line == NULL) { 483 if (line == NULL) {
487 ret = -1; 484 ret = -1;
diff --git a/tools/perf/ui/tui/progress.c b/tools/perf/ui/tui/progress.c
index 6c2184d53cbf..c61d14b101e0 100644
--- a/tools/perf/ui/tui/progress.c
+++ b/tools/perf/ui/tui/progress.c
@@ -2,9 +2,10 @@
2#include "../progress.h" 2#include "../progress.h"
3#include "../libslang.h" 3#include "../libslang.h"
4#include "../ui.h" 4#include "../ui.h"
5#include "tui.h"
5#include "../browser.h" 6#include "../browser.h"
6 7
7static void tui_progress__update(u64 curr, u64 total, const char *title) 8static void tui_progress__update(struct ui_progress *p)
8{ 9{
9 int bar, y; 10 int bar, y;
10 /* 11 /*
@@ -14,29 +15,30 @@ static void tui_progress__update(u64 curr, u64 total, const char *title)
14 if (use_browser <= 0) 15 if (use_browser <= 0)
15 return; 16 return;
16 17
17 if (total == 0) 18 if (p->total == 0)
18 return; 19 return;
19 20
20 ui__refresh_dimensions(true); 21 ui__refresh_dimensions(false);
21 pthread_mutex_lock(&ui__lock); 22 pthread_mutex_lock(&ui__lock);
22 y = SLtt_Screen_Rows / 2 - 2; 23 y = SLtt_Screen_Rows / 2 - 2;
23 SLsmg_set_color(0); 24 SLsmg_set_color(0);
24 SLsmg_draw_box(y, 0, 3, SLtt_Screen_Cols); 25 SLsmg_draw_box(y, 0, 3, SLtt_Screen_Cols);
25 SLsmg_gotorc(y++, 1); 26 SLsmg_gotorc(y++, 1);
26 SLsmg_write_string((char *)title); 27 SLsmg_write_string((char *)p->title);
28 SLsmg_fill_region(y, 1, 1, SLtt_Screen_Cols - 2, ' ');
27 SLsmg_set_color(HE_COLORSET_SELECTED); 29 SLsmg_set_color(HE_COLORSET_SELECTED);
28 bar = ((SLtt_Screen_Cols - 2) * curr) / total; 30 bar = ((SLtt_Screen_Cols - 2) * p->curr) / p->total;
29 SLsmg_fill_region(y, 1, 1, bar, ' '); 31 SLsmg_fill_region(y, 1, 1, bar, ' ');
30 SLsmg_refresh(); 32 SLsmg_refresh();
31 pthread_mutex_unlock(&ui__lock); 33 pthread_mutex_unlock(&ui__lock);
32} 34}
33 35
34static struct ui_progress tui_progress_fns = 36static struct ui_progress_ops tui_progress__ops =
35{ 37{
36 .update = tui_progress__update, 38 .update = tui_progress__update,
37}; 39};
38 40
39void ui_progress__init(void) 41void tui_progress__init(void)
40{ 42{
41 progress_fns = &tui_progress_fns; 43 ui_progress__ops = &tui_progress__ops;
42} 44}
diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
index b9401482d110..2f612562978c 100644
--- a/tools/perf/ui/tui/setup.c
+++ b/tools/perf/ui/tui/setup.c
@@ -9,6 +9,7 @@
9#include "../util.h" 9#include "../util.h"
10#include "../libslang.h" 10#include "../libslang.h"
11#include "../keysyms.h" 11#include "../keysyms.h"
12#include "tui.h"
12 13
13static volatile int ui__need_resize; 14static volatile int ui__need_resize;
14 15
@@ -119,7 +120,7 @@ int ui__init(void)
119 120
120 ui_helpline__init(); 121 ui_helpline__init();
121 ui_browser__init(); 122 ui_browser__init();
122 ui_progress__init(); 123 tui_progress__init();
123 124
124 signal(SIGSEGV, ui__signal); 125 signal(SIGSEGV, ui__signal);
125 signal(SIGFPE, ui__signal); 126 signal(SIGFPE, ui__signal);
diff --git a/tools/perf/ui/tui/tui.h b/tools/perf/ui/tui/tui.h
new file mode 100644
index 000000000000..18961c7b6ec5
--- /dev/null
+++ b/tools/perf/ui/tui/tui.h
@@ -0,0 +1,6 @@
1#ifndef _PERF_TUI_H_
2#define _PERF_TUI_H_ 1
3
4void tui_progress__init(void);
5
6#endif /* _PERF_TUI_H_ */
diff --git a/tools/perf/ui/ui.h b/tools/perf/ui/ui.h
index 70cb0d4eb8aa..ab88383f8be8 100644
--- a/tools/perf/ui/ui.h
+++ b/tools/perf/ui/ui.h
@@ -6,13 +6,14 @@
6#include <linux/compiler.h> 6#include <linux/compiler.h>
7 7
8extern pthread_mutex_t ui__lock; 8extern pthread_mutex_t ui__lock;
9extern void *perf_gtk_handle;
9 10
10extern int use_browser; 11extern int use_browser;
11 12
12void setup_browser(bool fallback_to_pager); 13void setup_browser(bool fallback_to_pager);
13void exit_browser(bool wait_for_ok); 14void exit_browser(bool wait_for_ok);
14 15
15#ifdef SLANG_SUPPORT 16#ifdef HAVE_SLANG_SUPPORT
16int ui__init(void); 17int ui__init(void);
17void ui__exit(bool wait_for_ok); 18void ui__exit(bool wait_for_ok);
18#else 19#else
@@ -23,17 +24,6 @@ static inline int ui__init(void)
23static inline void ui__exit(bool wait_for_ok __maybe_unused) {} 24static inline void ui__exit(bool wait_for_ok __maybe_unused) {}
24#endif 25#endif
25 26
26#ifdef GTK2_SUPPORT
27int perf_gtk__init(void);
28void perf_gtk__exit(bool wait_for_ok);
29#else
30static inline int perf_gtk__init(void)
31{
32 return -1;
33}
34static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {}
35#endif
36
37void ui__refresh_dimensions(bool force); 27void ui__refresh_dimensions(bool force);
38 28
39#endif /* _PERF_UI_H_ */ 29#endif /* _PERF_UI_H_ */