aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/ui/browser.c24
-rw-r--r--tools/perf/util/ui/browsers/hists.c41
-rw-r--r--tools/perf/util/ui/browsers/map.c9
3 files changed, 34 insertions, 40 deletions
diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c
index 930c4acaf56..6d0df809a2e 100644
--- a/tools/perf/util/ui/browser.c
+++ b/tools/perf/util/ui/browser.c
@@ -130,13 +130,10 @@ void ui_browser__refresh_dimensions(struct ui_browser *self)
130 int cols, rows; 130 int cols, rows;
131 newtGetScreenSize(&cols, &rows); 131 newtGetScreenSize(&cols, &rows);
132 132
133 if (self->width > cols - 4) 133 self->width = cols - 1;
134 self->width = cols - 4; 134 self->height = rows - 2;
135 self->height = rows - 5; 135 self->y = 1;
136 if (self->height > self->nr_entries) 136 self->x = 0;
137 self->height = self->nr_entries;
138 self->y = (rows - self->height) / 2;
139 self->x = (cols - self->width) / 2;
140} 137}
141 138
142void ui_browser__reset_index(struct ui_browser *self) 139void ui_browser__reset_index(struct ui_browser *self)
@@ -168,22 +165,24 @@ int ui_browser__show(struct ui_browser *self, const char *title,
168 NEWT_KEY_PGDN, NEWT_KEY_HOME, NEWT_KEY_END, ' ', 165 NEWT_KEY_PGDN, NEWT_KEY_HOME, NEWT_KEY_END, ' ',
169 NEWT_KEY_LEFT, NEWT_KEY_ESCAPE, 'q', CTRL('c'), 0 }; 166 NEWT_KEY_LEFT, NEWT_KEY_ESCAPE, 'q', CTRL('c'), 0 };
170 167
171 if (self->form != NULL) { 168 if (self->form != NULL)
172 newtFormDestroy(self->form); 169 newtFormDestroy(self->form);
173 newtPopWindow(); 170
174 }
175 ui_browser__refresh_dimensions(self); 171 ui_browser__refresh_dimensions(self);
176 newtCenteredWindow(self->width, self->height, title);
177 self->form = newtForm(NULL, NULL, 0); 172 self->form = newtForm(NULL, NULL, 0);
178 if (self->form == NULL) 173 if (self->form == NULL)
179 return -1; 174 return -1;
180 175
181 self->sb = newtVerticalScrollbar(self->width, 0, self->height, 176 self->sb = newtVerticalScrollbar(self->width, 1, self->height,
182 HE_COLORSET_NORMAL, 177 HE_COLORSET_NORMAL,
183 HE_COLORSET_SELECTED); 178 HE_COLORSET_SELECTED);
184 if (self->sb == NULL) 179 if (self->sb == NULL)
185 return -1; 180 return -1;
186 181
182 SLsmg_gotorc(0, 0);
183 ui_browser__set_color(self, NEWT_COLORSET_ROOT);
184 slsmg_write_nstring(title, self->width);
185
187 ui_browser__add_exit_keys(self, keys); 186 ui_browser__add_exit_keys(self, keys);
188 newtFormAddComponent(self->form, self->sb); 187 newtFormAddComponent(self->form, self->sb);
189 188
@@ -196,7 +195,6 @@ int ui_browser__show(struct ui_browser *self, const char *title,
196void ui_browser__hide(struct ui_browser *self) 195void ui_browser__hide(struct ui_browser *self)
197{ 196{
198 newtFormDestroy(self->form); 197 newtFormDestroy(self->form);
199 newtPopWindow();
200 self->form = NULL; 198 self->form = NULL;
201 ui_helpline__pop(); 199 ui_helpline__pop();
202} 200}
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c
index 2fc1ba3a468..ebda8c3fde9 100644
--- a/tools/perf/util/ui/browsers/hists.c
+++ b/tools/perf/util/ui/browsers/hists.c
@@ -293,19 +293,12 @@ static int hist_browser__run(struct hist_browser *self, const char *title)
293 int key; 293 int key;
294 int exit_keys[] = { 'a', '?', 'h', 'C', 'd', 'D', 'E', 't', 294 int exit_keys[] = { 'a', '?', 'h', 'C', 'd', 'D', 'E', 't',
295 NEWT_KEY_ENTER, NEWT_KEY_RIGHT, NEWT_KEY_LEFT, 0, }; 295 NEWT_KEY_ENTER, NEWT_KEY_RIGHT, NEWT_KEY_LEFT, 0, };
296 char str[256], unit;
297 unsigned long nr_events = self->hists->stats.nr_events[PERF_RECORD_SAMPLE];
298 296
299 self->b.entries = &self->hists->entries; 297 self->b.entries = &self->hists->entries;
300 self->b.nr_entries = self->hists->nr_entries; 298 self->b.nr_entries = self->hists->nr_entries;
301 299
302 hist_browser__refresh_dimensions(self); 300 hist_browser__refresh_dimensions(self);
303 301
304 nr_events = convert_unit(nr_events, &unit);
305 snprintf(str, sizeof(str), "Events: %lu%c ",
306 nr_events, unit);
307 newtDrawRootText(0, 0, str);
308
309 if (ui_browser__show(&self->b, title, 302 if (ui_browser__show(&self->b, title,
310 "Press '?' for help on key bindings") < 0) 303 "Press '?' for help on key bindings") < 0)
311 return -1; 304 return -1;
@@ -782,21 +775,26 @@ static struct thread *hist_browser__selected_thread(struct hist_browser *self)
782 return self->he_selection->thread; 775 return self->he_selection->thread;
783} 776}
784 777
785static int hist_browser__title(char *bf, size_t size, const char *ev_name, 778static int hists__browser_title(struct hists *self, char *bf, size_t size,
786 const struct dso *dso, const struct thread *thread) 779 const char *ev_name, const struct dso *dso,
780 const struct thread *thread)
787{ 781{
788 int printed = 0; 782 char unit;
783 int printed;
784 unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];
785
786 nr_events = convert_unit(nr_events, &unit);
787 printed = snprintf(bf, size, "Events: %lu%c %s", nr_events, unit, ev_name);
789 788
790 if (thread) 789 if (thread)
791 printed += snprintf(bf + printed, size - printed, 790 printed += snprintf(bf + printed, size - printed,
792 "Thread: %s(%d)", 791 ", Thread: %s(%d)",
793 (thread->comm_set ? thread->comm : ""), 792 (thread->comm_set ? thread->comm : ""),
794 thread->pid); 793 thread->pid);
795 if (dso) 794 if (dso)
796 printed += snprintf(bf + printed, size - printed, 795 printed += snprintf(bf + printed, size - printed,
797 "%sDSO: %s", thread ? " " : "", 796 ", DSO: %s", dso->short_name);
798 dso->short_name); 797 return printed;
799 return printed ?: snprintf(bf, size, "Event: %s", ev_name);
800} 798}
801 799
802int hists__browse(struct hists *self, const char *helpline, const char *ev_name) 800int hists__browse(struct hists *self, const char *helpline, const char *ev_name)
@@ -817,9 +815,8 @@ int hists__browse(struct hists *self, const char *helpline, const char *ev_name)
817 815
818 ui_helpline__push(helpline); 816 ui_helpline__push(helpline);
819 817
820 hist_browser__title(msg, sizeof(msg), ev_name, 818 hists__browser_title(self, msg, sizeof(msg), ev_name,
821 dso_filter, thread_filter); 819 dso_filter, thread_filter);
822
823 while (1) { 820 while (1) {
824 const struct thread *thread; 821 const struct thread *thread;
825 const struct dso *dso; 822 const struct dso *dso;
@@ -957,8 +954,8 @@ zoom_out_dso:
957 pstack__push(fstack, &dso_filter); 954 pstack__push(fstack, &dso_filter);
958 } 955 }
959 hists__filter_by_dso(self, dso_filter); 956 hists__filter_by_dso(self, dso_filter);
960 hist_browser__title(msg, sizeof(msg), ev_name, 957 hists__browser_title(self, msg, sizeof(msg), ev_name,
961 dso_filter, thread_filter); 958 dso_filter, thread_filter);
962 hist_browser__reset(browser); 959 hist_browser__reset(browser);
963 } else if (choice == zoom_thread) { 960 } else if (choice == zoom_thread) {
964zoom_thread: 961zoom_thread:
@@ -975,8 +972,8 @@ zoom_out_thread:
975 pstack__push(fstack, &thread_filter); 972 pstack__push(fstack, &thread_filter);
976 } 973 }
977 hists__filter_by_thread(self, thread_filter); 974 hists__filter_by_thread(self, thread_filter);
978 hist_browser__title(msg, sizeof(msg), ev_name, 975 hists__browser_title(self, msg, sizeof(msg), ev_name,
979 dso_filter, thread_filter); 976 dso_filter, thread_filter);
980 hist_browser__reset(browser); 977 hist_browser__reset(browser);
981 } 978 }
982 } 979 }
diff --git a/tools/perf/util/ui/browsers/map.c b/tools/perf/util/ui/browsers/map.c
index 1bf09796cb3..e35437dfa5b 100644
--- a/tools/perf/util/ui/browsers/map.c
+++ b/tools/perf/util/ui/browsers/map.c
@@ -46,7 +46,6 @@ out_free_form:
46struct map_browser { 46struct map_browser {
47 struct ui_browser b; 47 struct ui_browser b;
48 struct map *map; 48 struct map *map;
49 u16 namelen;
50 u8 addrlen; 49 u8 addrlen;
51}; 50};
52 51
@@ -55,13 +54,16 @@ static void map_browser__write(struct ui_browser *self, void *nd, int row)
55 struct symbol *sym = rb_entry(nd, struct symbol, rb_node); 54 struct symbol *sym = rb_entry(nd, struct symbol, rb_node);
56 struct map_browser *mb = container_of(self, struct map_browser, b); 55 struct map_browser *mb = container_of(self, struct map_browser, b);
57 bool current_entry = ui_browser__is_current_entry(self, row); 56 bool current_entry = ui_browser__is_current_entry(self, row);
57 int width;
58 58
59 ui_browser__set_percent_color(self, 0, current_entry); 59 ui_browser__set_percent_color(self, 0, current_entry);
60 slsmg_printf("%*llx %*llx %c ", 60 slsmg_printf("%*llx %*llx %c ",
61 mb->addrlen, sym->start, mb->addrlen, sym->end, 61 mb->addrlen, sym->start, mb->addrlen, sym->end,
62 sym->binding == STB_GLOBAL ? 'g' : 62 sym->binding == STB_GLOBAL ? 'g' :
63 sym->binding == STB_LOCAL ? 'l' : 'w'); 63 sym->binding == STB_LOCAL ? 'l' : 'w');
64 slsmg_write_nstring(sym->name, mb->namelen); 64 width = self->width - ((mb->addrlen * 2) + 4);
65 if (width > 0)
66 slsmg_write_nstring(sym->name, width);
65} 67}
66 68
67/* FIXME uber-kludgy, see comment on cmd_report... */ 69/* FIXME uber-kludgy, see comment on cmd_report... */
@@ -139,8 +141,6 @@ int map__browse(struct map *self)
139 for (nd = rb_first(mb.b.entries); nd; nd = rb_next(nd)) { 141 for (nd = rb_first(mb.b.entries); nd; nd = rb_next(nd)) {
140 struct symbol *pos = rb_entry(nd, struct symbol, rb_node); 142 struct symbol *pos = rb_entry(nd, struct symbol, rb_node);
141 143
142 if (mb.namelen < pos->namelen)
143 mb.namelen = pos->namelen;
144 if (maxaddr < pos->end) 144 if (maxaddr < pos->end)
145 maxaddr = pos->end; 145 maxaddr = pos->end;
146 if (verbose) { 146 if (verbose) {
@@ -151,6 +151,5 @@ int map__browse(struct map *self)
151 } 151 }
152 152
153 mb.addrlen = snprintf(tmp, sizeof(tmp), "%llx", maxaddr); 153 mb.addrlen = snprintf(tmp, sizeof(tmp), "%llx", maxaddr);
154 mb.b.width += mb.addrlen * 2 + 4 + mb.namelen;
155 return map_browser__run(&mb); 154 return map_browser__run(&mb);
156} 155}