aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-05-29 21:42:18 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-05-29 21:42:18 -0400
commit05e8b0804ec423a440882e7adecb36e7ac43e56f (patch)
tree1cefdeac3112e790afc275d9e57cd56674084fa4 /tools
parentc323cf0400c1fed853738e6d81e83c6ac7ff5105 (diff)
perf ui browser: Stop using 'self'
Stop using this python/OOP convention, doesn't really helps. Will do more from time to time till we get it cleaned up in all of /perf. Suggested-by: Thomas Gleixner <tglx@linutronix.de> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-5dyxyb8o0gf4yndk27kafbd1@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/ui/browser.c180
-rw-r--r--tools/perf/ui/browsers/annotate.c122
-rw-r--r--tools/perf/ui/browsers/hists.c338
3 files changed, 320 insertions, 320 deletions
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index c3a769ad90c5..1818a531f1d3 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -35,16 +35,16 @@ int ui_browser__set_color(struct ui_browser *browser, int color)
35 return ret; 35 return ret;
36} 36}
37 37
38void ui_browser__set_percent_color(struct ui_browser *self, 38void ui_browser__set_percent_color(struct ui_browser *browser,
39 double percent, bool current) 39 double percent, bool current)
40{ 40{
41 int color = ui_browser__percent_color(self, percent, current); 41 int color = ui_browser__percent_color(browser, percent, current);
42 ui_browser__set_color(self, color); 42 ui_browser__set_color(browser, color);
43} 43}
44 44
45void ui_browser__gotorc(struct ui_browser *self, int y, int x) 45void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
46{ 46{
47 SLsmg_gotorc(self->y + y, self->x + x); 47 SLsmg_gotorc(browser->y + y, browser->x + x);
48} 48}
49 49
50static struct list_head * 50static struct list_head *
@@ -73,23 +73,23 @@ ui_browser__list_head_filter_prev_entries(struct ui_browser *browser,
73 return NULL; 73 return NULL;
74} 74}
75 75
76void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whence) 76void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int whence)
77{ 77{
78 struct list_head *head = self->entries; 78 struct list_head *head = browser->entries;
79 struct list_head *pos; 79 struct list_head *pos;
80 80
81 if (self->nr_entries == 0) 81 if (browser->nr_entries == 0)
82 return; 82 return;
83 83
84 switch (whence) { 84 switch (whence) {
85 case SEEK_SET: 85 case SEEK_SET:
86 pos = ui_browser__list_head_filter_entries(self, head->next); 86 pos = ui_browser__list_head_filter_entries(browser, head->next);
87 break; 87 break;
88 case SEEK_CUR: 88 case SEEK_CUR:
89 pos = self->top; 89 pos = browser->top;
90 break; 90 break;
91 case SEEK_END: 91 case SEEK_END:
92 pos = ui_browser__list_head_filter_prev_entries(self, head->prev); 92 pos = ui_browser__list_head_filter_prev_entries(browser, head->prev);
93 break; 93 break;
94 default: 94 default:
95 return; 95 return;
@@ -99,18 +99,18 @@ void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whenc
99 99
100 if (offset > 0) { 100 if (offset > 0) {
101 while (offset-- != 0) 101 while (offset-- != 0)
102 pos = ui_browser__list_head_filter_entries(self, pos->next); 102 pos = ui_browser__list_head_filter_entries(browser, pos->next);
103 } else { 103 } else {
104 while (offset++ != 0) 104 while (offset++ != 0)
105 pos = ui_browser__list_head_filter_prev_entries(self, pos->prev); 105 pos = ui_browser__list_head_filter_prev_entries(browser, pos->prev);
106 } 106 }
107 107
108 self->top = pos; 108 browser->top = pos;
109} 109}
110 110
111void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence) 111void ui_browser__rb_tree_seek(struct ui_browser *browser, off_t offset, int whence)
112{ 112{
113 struct rb_root *root = self->entries; 113 struct rb_root *root = browser->entries;
114 struct rb_node *nd; 114 struct rb_node *nd;
115 115
116 switch (whence) { 116 switch (whence) {
@@ -118,7 +118,7 @@ void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence)
118 nd = rb_first(root); 118 nd = rb_first(root);
119 break; 119 break;
120 case SEEK_CUR: 120 case SEEK_CUR:
121 nd = self->top; 121 nd = browser->top;
122 break; 122 break;
123 case SEEK_END: 123 case SEEK_END:
124 nd = rb_last(root); 124 nd = rb_last(root);
@@ -135,23 +135,23 @@ void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence)
135 nd = rb_prev(nd); 135 nd = rb_prev(nd);
136 } 136 }
137 137
138 self->top = nd; 138 browser->top = nd;
139} 139}
140 140
141unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self) 141unsigned int ui_browser__rb_tree_refresh(struct ui_browser *browser)
142{ 142{
143 struct rb_node *nd; 143 struct rb_node *nd;
144 int row = 0; 144 int row = 0;
145 145
146 if (self->top == NULL) 146 if (browser->top == NULL)
147 self->top = rb_first(self->entries); 147 browser->top = rb_first(browser->entries);
148 148
149 nd = self->top; 149 nd = browser->top;
150 150
151 while (nd != NULL) { 151 while (nd != NULL) {
152 ui_browser__gotorc(self, row, 0); 152 ui_browser__gotorc(browser, row, 0);
153 self->write(self, nd, row); 153 browser->write(browser, nd, row);
154 if (++row == self->height) 154 if (++row == browser->height)
155 break; 155 break;
156 nd = rb_next(nd); 156 nd = rb_next(nd);
157 } 157 }
@@ -159,17 +159,17 @@ unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self)
159 return row; 159 return row;
160} 160}
161 161
162bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row) 162bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row)
163{ 163{
164 return self->top_idx + row == self->index; 164 return browser->top_idx + row == browser->index;
165} 165}
166 166
167void ui_browser__refresh_dimensions(struct ui_browser *self) 167void ui_browser__refresh_dimensions(struct ui_browser *browser)
168{ 168{
169 self->width = SLtt_Screen_Cols - 1; 169 browser->width = SLtt_Screen_Cols - 1;
170 self->height = SLtt_Screen_Rows - 2; 170 browser->height = SLtt_Screen_Rows - 2;
171 self->y = 1; 171 browser->y = 1;
172 self->x = 0; 172 browser->x = 0;
173} 173}
174 174
175void ui_browser__handle_resize(struct ui_browser *browser) 175void ui_browser__handle_resize(struct ui_browser *browser)
@@ -225,10 +225,10 @@ bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text)
225 return key == K_ENTER || toupper(key) == 'Y'; 225 return key == K_ENTER || toupper(key) == 'Y';
226} 226}
227 227
228void ui_browser__reset_index(struct ui_browser *self) 228void ui_browser__reset_index(struct ui_browser *browser)
229{ 229{
230 self->index = self->top_idx = 0; 230 browser->index = browser->top_idx = 0;
231 self->seek(self, 0, SEEK_SET); 231 browser->seek(browser, 0, SEEK_SET);
232} 232}
233 233
234void __ui_browser__show_title(struct ui_browser *browser, const char *title) 234void __ui_browser__show_title(struct ui_browser *browser, const char *title)
@@ -245,26 +245,26 @@ void ui_browser__show_title(struct ui_browser *browser, const char *title)
245 pthread_mutex_unlock(&ui__lock); 245 pthread_mutex_unlock(&ui__lock);
246} 246}
247 247
248int ui_browser__show(struct ui_browser *self, const char *title, 248int ui_browser__show(struct ui_browser *browser, const char *title,
249 const char *helpline, ...) 249 const char *helpline, ...)
250{ 250{
251 int err; 251 int err;
252 va_list ap; 252 va_list ap;
253 253
254 ui_browser__refresh_dimensions(self); 254 ui_browser__refresh_dimensions(browser);
255 255
256 pthread_mutex_lock(&ui__lock); 256 pthread_mutex_lock(&ui__lock);
257 __ui_browser__show_title(self, title); 257 __ui_browser__show_title(browser, title);
258 258
259 self->title = title; 259 browser->title = title;
260 free(self->helpline); 260 free(browser->helpline);
261 self->helpline = NULL; 261 browser->helpline = NULL;
262 262
263 va_start(ap, helpline); 263 va_start(ap, helpline);
264 err = vasprintf(&self->helpline, helpline, ap); 264 err = vasprintf(&browser->helpline, helpline, ap);
265 va_end(ap); 265 va_end(ap);
266 if (err > 0) 266 if (err > 0)
267 ui_helpline__push(self->helpline); 267 ui_helpline__push(browser->helpline);
268 pthread_mutex_unlock(&ui__lock); 268 pthread_mutex_unlock(&ui__lock);
269 return err ? 0 : -1; 269 return err ? 0 : -1;
270} 270}
@@ -350,7 +350,7 @@ void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries)
350 browser->seek(browser, browser->top_idx, SEEK_SET); 350 browser->seek(browser, browser->top_idx, SEEK_SET);
351} 351}
352 352
353int ui_browser__run(struct ui_browser *self, int delay_secs) 353int ui_browser__run(struct ui_browser *browser, int delay_secs)
354{ 354{
355 int err, key; 355 int err, key;
356 356
@@ -358,7 +358,7 @@ int ui_browser__run(struct ui_browser *self, int delay_secs)
358 off_t offset; 358 off_t offset;
359 359
360 pthread_mutex_lock(&ui__lock); 360 pthread_mutex_lock(&ui__lock);
361 err = __ui_browser__refresh(self); 361 err = __ui_browser__refresh(browser);
362 SLsmg_refresh(); 362 SLsmg_refresh();
363 pthread_mutex_unlock(&ui__lock); 363 pthread_mutex_unlock(&ui__lock);
364 if (err < 0) 364 if (err < 0)
@@ -368,18 +368,18 @@ int ui_browser__run(struct ui_browser *self, int delay_secs)
368 368
369 if (key == K_RESIZE) { 369 if (key == K_RESIZE) {
370 ui__refresh_dimensions(false); 370 ui__refresh_dimensions(false);
371 ui_browser__refresh_dimensions(self); 371 ui_browser__refresh_dimensions(browser);
372 __ui_browser__show_title(self, self->title); 372 __ui_browser__show_title(browser, browser->title);
373 ui_helpline__puts(self->helpline); 373 ui_helpline__puts(browser->helpline);
374 continue; 374 continue;
375 } 375 }
376 376
377 if (self->use_navkeypressed && !self->navkeypressed) { 377 if (browser->use_navkeypressed && !browser->navkeypressed) {
378 if (key == K_DOWN || key == K_UP || 378 if (key == K_DOWN || key == K_UP ||
379 key == K_PGDN || key == K_PGUP || 379 key == K_PGDN || key == K_PGUP ||
380 key == K_HOME || key == K_END || 380 key == K_HOME || key == K_END ||
381 key == ' ') { 381 key == ' ') {
382 self->navkeypressed = true; 382 browser->navkeypressed = true;
383 continue; 383 continue;
384 } else 384 } else
385 return key; 385 return key;
@@ -387,59 +387,59 @@ int ui_browser__run(struct ui_browser *self, int delay_secs)
387 387
388 switch (key) { 388 switch (key) {
389 case K_DOWN: 389 case K_DOWN:
390 if (self->index == self->nr_entries - 1) 390 if (browser->index == browser->nr_entries - 1)
391 break; 391 break;
392 ++self->index; 392 ++browser->index;
393 if (self->index == self->top_idx + self->height) { 393 if (browser->index == browser->top_idx + browser->height) {
394 ++self->top_idx; 394 ++browser->top_idx;
395 self->seek(self, +1, SEEK_CUR); 395 browser->seek(browser, +1, SEEK_CUR);
396 } 396 }
397 break; 397 break;
398 case K_UP: 398 case K_UP:
399 if (self->index == 0) 399 if (browser->index == 0)
400 break; 400 break;
401 --self->index; 401 --browser->index;
402 if (self->index < self->top_idx) { 402 if (browser->index < browser->top_idx) {
403 --self->top_idx; 403 --browser->top_idx;
404 self->seek(self, -1, SEEK_CUR); 404 browser->seek(browser, -1, SEEK_CUR);
405 } 405 }
406 break; 406 break;
407 case K_PGDN: 407 case K_PGDN:
408 case ' ': 408 case ' ':
409 if (self->top_idx + self->height > self->nr_entries - 1) 409 if (browser->top_idx + browser->height > browser->nr_entries - 1)
410 break; 410 break;
411 411
412 offset = self->height; 412 offset = browser->height;
413 if (self->index + offset > self->nr_entries - 1) 413 if (browser->index + offset > browser->nr_entries - 1)
414 offset = self->nr_entries - 1 - self->index; 414 offset = browser->nr_entries - 1 - browser->index;
415 self->index += offset; 415 browser->index += offset;
416 self->top_idx += offset; 416 browser->top_idx += offset;
417 self->seek(self, +offset, SEEK_CUR); 417 browser->seek(browser, +offset, SEEK_CUR);
418 break; 418 break;
419 case K_PGUP: 419 case K_PGUP:
420 if (self->top_idx == 0) 420 if (browser->top_idx == 0)
421 break; 421 break;
422 422
423 if (self->top_idx < self->height) 423 if (browser->top_idx < browser->height)
424 offset = self->top_idx; 424 offset = browser->top_idx;
425 else 425 else
426 offset = self->height; 426 offset = browser->height;
427 427
428 self->index -= offset; 428 browser->index -= offset;
429 self->top_idx -= offset; 429 browser->top_idx -= offset;
430 self->seek(self, -offset, SEEK_CUR); 430 browser->seek(browser, -offset, SEEK_CUR);
431 break; 431 break;
432 case K_HOME: 432 case K_HOME:
433 ui_browser__reset_index(self); 433 ui_browser__reset_index(browser);
434 break; 434 break;
435 case K_END: 435 case K_END:
436 offset = self->height - 1; 436 offset = browser->height - 1;
437 if (offset >= self->nr_entries) 437 if (offset >= browser->nr_entries)
438 offset = self->nr_entries - 1; 438 offset = browser->nr_entries - 1;
439 439
440 self->index = self->nr_entries - 1; 440 browser->index = browser->nr_entries - 1;
441 self->top_idx = self->index - offset; 441 browser->top_idx = browser->index - offset;
442 self->seek(self, -offset, SEEK_END); 442 browser->seek(browser, -offset, SEEK_END);
443 break; 443 break;
444 default: 444 default:
445 return key; 445 return key;
@@ -448,22 +448,22 @@ int ui_browser__run(struct ui_browser *self, int delay_secs)
448 return -1; 448 return -1;
449} 449}
450 450
451unsigned int ui_browser__list_head_refresh(struct ui_browser *self) 451unsigned int ui_browser__list_head_refresh(struct ui_browser *browser)
452{ 452{
453 struct list_head *pos; 453 struct list_head *pos;
454 struct list_head *head = self->entries; 454 struct list_head *head = browser->entries;
455 int row = 0; 455 int row = 0;
456 456
457 if (self->top == NULL || self->top == self->entries) 457 if (browser->top == NULL || browser->top == browser->entries)
458 self->top = ui_browser__list_head_filter_entries(self, head->next); 458 browser->top = ui_browser__list_head_filter_entries(browser, head->next);
459 459
460 pos = self->top; 460 pos = browser->top;
461 461
462 list_for_each_from(pos, head) { 462 list_for_each_from(pos, head) {
463 if (!self->filter || !self->filter(self, pos)) { 463 if (!browser->filter || !browser->filter(browser, pos)) {
464 ui_browser__gotorc(self, row, 0); 464 ui_browser__gotorc(browser, row, 0);
465 self->write(self, pos, row); 465 browser->write(browser, pos, row);
466 if (++row == self->height) 466 if (++row == browser->height)
467 break; 467 break;
468 } 468 }
469 } 469 }
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 77b5b1280834..4deea6aaf927 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -83,30 +83,30 @@ static int annotate_browser__set_jumps_percent_color(struct annotate_browser *br
83 return ui_browser__set_color(&browser->b, color); 83 return ui_browser__set_color(&browser->b, color);
84} 84}
85 85
86static void annotate_browser__write(struct ui_browser *self, void *entry, int row) 86static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
87{ 87{
88 struct annotate_browser *ab = container_of(self, struct annotate_browser, b); 88 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
89 struct disasm_line *dl = list_entry(entry, struct disasm_line, node); 89 struct disasm_line *dl = list_entry(entry, struct disasm_line, node);
90 struct browser_disasm_line *bdl = disasm_line__browser(dl); 90 struct browser_disasm_line *bdl = disasm_line__browser(dl);
91 bool current_entry = ui_browser__is_current_entry(self, row); 91 bool current_entry = ui_browser__is_current_entry(browser, row);
92 bool change_color = (!annotate_browser__opts.hide_src_code && 92 bool change_color = (!annotate_browser__opts.hide_src_code &&
93 (!current_entry || (self->use_navkeypressed && 93 (!current_entry || (browser->use_navkeypressed &&
94 !self->navkeypressed))); 94 !browser->navkeypressed)));
95 int width = self->width, printed; 95 int width = browser->width, printed;
96 char bf[256]; 96 char bf[256];
97 97
98 if (dl->offset != -1 && bdl->percent != 0.0) { 98 if (dl->offset != -1 && bdl->percent != 0.0) {
99 ui_browser__set_percent_color(self, bdl->percent, current_entry); 99 ui_browser__set_percent_color(browser, bdl->percent, current_entry);
100 slsmg_printf("%6.2f ", bdl->percent); 100 slsmg_printf("%6.2f ", bdl->percent);
101 } else { 101 } else {
102 ui_browser__set_percent_color(self, 0, current_entry); 102 ui_browser__set_percent_color(browser, 0, current_entry);
103 slsmg_write_nstring(" ", 7); 103 slsmg_write_nstring(" ", 7);
104 } 104 }
105 105
106 SLsmg_write_char(' '); 106 SLsmg_write_char(' ');
107 107
108 /* The scroll bar isn't being used */ 108 /* The scroll bar isn't being used */
109 if (!self->navkeypressed) 109 if (!browser->navkeypressed)
110 width += 1; 110 width += 1;
111 111
112 if (!*dl->line) 112 if (!*dl->line)
@@ -135,7 +135,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
135 prev = annotate_browser__set_jumps_percent_color(ab, bdl->jump_sources, 135 prev = annotate_browser__set_jumps_percent_color(ab, bdl->jump_sources,
136 current_entry); 136 current_entry);
137 slsmg_write_nstring(bf, printed); 137 slsmg_write_nstring(bf, printed);
138 ui_browser__set_color(self, prev); 138 ui_browser__set_color(browser, prev);
139 } 139 }
140 140
141 printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ", 141 printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ",
@@ -147,19 +147,19 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
147 } 147 }
148 148
149 if (change_color) 149 if (change_color)
150 color = ui_browser__set_color(self, HE_COLORSET_ADDR); 150 color = ui_browser__set_color(browser, HE_COLORSET_ADDR);
151 slsmg_write_nstring(bf, printed); 151 slsmg_write_nstring(bf, printed);
152 if (change_color) 152 if (change_color)
153 ui_browser__set_color(self, color); 153 ui_browser__set_color(browser, color);
154 if (dl->ins && dl->ins->ops->scnprintf) { 154 if (dl->ins && dl->ins->ops->scnprintf) {
155 if (ins__is_jump(dl->ins)) { 155 if (ins__is_jump(dl->ins)) {
156 bool fwd = dl->ops.target.offset > (u64)dl->offset; 156 bool fwd = dl->ops.target.offset > (u64)dl->offset;
157 157
158 ui_browser__write_graph(self, fwd ? SLSMG_DARROW_CHAR : 158 ui_browser__write_graph(browser, fwd ? SLSMG_DARROW_CHAR :
159 SLSMG_UARROW_CHAR); 159 SLSMG_UARROW_CHAR);
160 SLsmg_write_char(' '); 160 SLsmg_write_char(' ');
161 } else if (ins__is_call(dl->ins)) { 161 } else if (ins__is_call(dl->ins)) {
162 ui_browser__write_graph(self, SLSMG_RARROW_CHAR); 162 ui_browser__write_graph(browser, SLSMG_RARROW_CHAR);
163 SLsmg_write_char(' '); 163 SLsmg_write_char(' ');
164 } else { 164 } else {
165 slsmg_write_nstring(" ", 2); 165 slsmg_write_nstring(" ", 2);
@@ -168,7 +168,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
168 if (strcmp(dl->name, "retq")) { 168 if (strcmp(dl->name, "retq")) {
169 slsmg_write_nstring(" ", 2); 169 slsmg_write_nstring(" ", 2);
170 } else { 170 } else {
171 ui_browser__write_graph(self, SLSMG_LARROW_CHAR); 171 ui_browser__write_graph(browser, SLSMG_LARROW_CHAR);
172 SLsmg_write_char(' '); 172 SLsmg_write_char(' ');
173 } 173 }
174 } 174 }
@@ -275,27 +275,27 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_l
275 rb_insert_color(&bdl->rb_node, root); 275 rb_insert_color(&bdl->rb_node, root);
276} 276}
277 277
278static void annotate_browser__set_top(struct annotate_browser *self, 278static void annotate_browser__set_top(struct annotate_browser *browser,
279 struct disasm_line *pos, u32 idx) 279 struct disasm_line *pos, u32 idx)
280{ 280{
281 unsigned back; 281 unsigned back;
282 282
283 ui_browser__refresh_dimensions(&self->b); 283 ui_browser__refresh_dimensions(&browser->b);
284 back = self->b.height / 2; 284 back = browser->b.height / 2;
285 self->b.top_idx = self->b.index = idx; 285 browser->b.top_idx = browser->b.index = idx;
286 286
287 while (self->b.top_idx != 0 && back != 0) { 287 while (browser->b.top_idx != 0 && back != 0) {
288 pos = list_entry(pos->node.prev, struct disasm_line, node); 288 pos = list_entry(pos->node.prev, struct disasm_line, node);
289 289
290 if (disasm_line__filter(&self->b, &pos->node)) 290 if (disasm_line__filter(&browser->b, &pos->node))
291 continue; 291 continue;
292 292
293 --self->b.top_idx; 293 --browser->b.top_idx;
294 --back; 294 --back;
295 } 295 }
296 296
297 self->b.top = pos; 297 browser->b.top = pos;
298 self->b.navkeypressed = true; 298 browser->b.navkeypressed = true;
299} 299}
300 300
301static void annotate_browser__set_rb_top(struct annotate_browser *browser, 301static void annotate_browser__set_rb_top(struct annotate_browser *browser,
@@ -600,33 +600,33 @@ static void annotate_browser__update_addr_width(struct annotate_browser *browser
600 browser->addr_width += browser->jumps_width + 1; 600 browser->addr_width += browser->jumps_width + 1;
601} 601}
602 602
603static int annotate_browser__run(struct annotate_browser *self, int evidx, 603static int annotate_browser__run(struct annotate_browser *browser, int evidx,
604 void(*timer)(void *arg), 604 void(*timer)(void *arg),
605 void *arg, int delay_secs) 605 void *arg, int delay_secs)
606{ 606{
607 struct rb_node *nd = NULL; 607 struct rb_node *nd = NULL;
608 struct map_symbol *ms = self->b.priv; 608 struct map_symbol *ms = browser->b.priv;
609 struct symbol *sym = ms->sym; 609 struct symbol *sym = ms->sym;
610 const char *help = "Press 'h' for help on key bindings"; 610 const char *help = "Press 'h' for help on key bindings";
611 int key; 611 int key;
612 612
613 if (ui_browser__show(&self->b, sym->name, help) < 0) 613 if (ui_browser__show(&browser->b, sym->name, help) < 0)
614 return -1; 614 return -1;
615 615
616 annotate_browser__calc_percent(self, evidx); 616 annotate_browser__calc_percent(browser, evidx);
617 617
618 if (self->curr_hot) { 618 if (browser->curr_hot) {
619 annotate_browser__set_rb_top(self, self->curr_hot); 619 annotate_browser__set_rb_top(browser, browser->curr_hot);
620 self->b.navkeypressed = false; 620 browser->b.navkeypressed = false;
621 } 621 }
622 622
623 nd = self->curr_hot; 623 nd = browser->curr_hot;
624 624
625 while (1) { 625 while (1) {
626 key = ui_browser__run(&self->b, delay_secs); 626 key = ui_browser__run(&browser->b, delay_secs);
627 627
628 if (delay_secs != 0) { 628 if (delay_secs != 0) {
629 annotate_browser__calc_percent(self, evidx); 629 annotate_browser__calc_percent(browser, evidx);
630 /* 630 /*
631 * Current line focus got out of the list of most active 631 * Current line focus got out of the list of most active
632 * lines, NULL it so that if TAB|UNTAB is pressed, we 632 * lines, NULL it so that if TAB|UNTAB is pressed, we
@@ -648,21 +648,21 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
648 if (nd != NULL) { 648 if (nd != NULL) {
649 nd = rb_prev(nd); 649 nd = rb_prev(nd);
650 if (nd == NULL) 650 if (nd == NULL)
651 nd = rb_last(&self->entries); 651 nd = rb_last(&browser->entries);
652 } else 652 } else
653 nd = self->curr_hot; 653 nd = browser->curr_hot;
654 break; 654 break;
655 case K_UNTAB: 655 case K_UNTAB:
656 if (nd != NULL) 656 if (nd != NULL)
657 nd = rb_next(nd); 657 nd = rb_next(nd);
658 if (nd == NULL) 658 if (nd == NULL)
659 nd = rb_first(&self->entries); 659 nd = rb_first(&browser->entries);
660 else 660 else
661 nd = self->curr_hot; 661 nd = browser->curr_hot;
662 break; 662 break;
663 case K_F1: 663 case K_F1:
664 case 'h': 664 case 'h':
665 ui_browser__help_window(&self->b, 665 ui_browser__help_window(&browser->b,
666 "UP/DOWN/PGUP\n" 666 "UP/DOWN/PGUP\n"
667 "PGDN/SPACE Navigate\n" 667 "PGDN/SPACE Navigate\n"
668 "q/ESC/CTRL+C Exit\n\n" 668 "q/ESC/CTRL+C Exit\n\n"
@@ -678,62 +678,62 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
678 "? Search previous string\n"); 678 "? Search previous string\n");
679 continue; 679 continue;
680 case 'H': 680 case 'H':
681 nd = self->curr_hot; 681 nd = browser->curr_hot;
682 break; 682 break;
683 case 's': 683 case 's':
684 if (annotate_browser__toggle_source(self)) 684 if (annotate_browser__toggle_source(browser))
685 ui_helpline__puts(help); 685 ui_helpline__puts(help);
686 continue; 686 continue;
687 case 'o': 687 case 'o':
688 annotate_browser__opts.use_offset = !annotate_browser__opts.use_offset; 688 annotate_browser__opts.use_offset = !annotate_browser__opts.use_offset;
689 annotate_browser__update_addr_width(self); 689 annotate_browser__update_addr_width(browser);
690 continue; 690 continue;
691 case 'j': 691 case 'j':
692 annotate_browser__opts.jump_arrows = !annotate_browser__opts.jump_arrows; 692 annotate_browser__opts.jump_arrows = !annotate_browser__opts.jump_arrows;
693 continue; 693 continue;
694 case 'J': 694 case 'J':
695 annotate_browser__opts.show_nr_jumps = !annotate_browser__opts.show_nr_jumps; 695 annotate_browser__opts.show_nr_jumps = !annotate_browser__opts.show_nr_jumps;
696 annotate_browser__update_addr_width(self); 696 annotate_browser__update_addr_width(browser);
697 continue; 697 continue;
698 case '/': 698 case '/':
699 if (annotate_browser__search(self, delay_secs)) { 699 if (annotate_browser__search(browser, delay_secs)) {
700show_help: 700show_help:
701 ui_helpline__puts(help); 701 ui_helpline__puts(help);
702 } 702 }
703 continue; 703 continue;
704 case 'n': 704 case 'n':
705 if (self->searching_backwards ? 705 if (browser->searching_backwards ?
706 annotate_browser__continue_search_reverse(self, delay_secs) : 706 annotate_browser__continue_search_reverse(browser, delay_secs) :
707 annotate_browser__continue_search(self, delay_secs)) 707 annotate_browser__continue_search(browser, delay_secs))
708 goto show_help; 708 goto show_help;
709 continue; 709 continue;
710 case '?': 710 case '?':
711 if (annotate_browser__search_reverse(self, delay_secs)) 711 if (annotate_browser__search_reverse(browser, delay_secs))
712 goto show_help; 712 goto show_help;
713 continue; 713 continue;
714 case 'D': { 714 case 'D': {
715 static int seq; 715 static int seq;
716 ui_helpline__pop(); 716 ui_helpline__pop();
717 ui_helpline__fpush("%d: nr_ent=%d, height=%d, idx=%d, top_idx=%d, nr_asm_entries=%d", 717 ui_helpline__fpush("%d: nr_ent=%d, height=%d, idx=%d, top_idx=%d, nr_asm_entries=%d",
718 seq++, self->b.nr_entries, 718 seq++, browser->b.nr_entries,
719 self->b.height, 719 browser->b.height,
720 self->b.index, 720 browser->b.index,
721 self->b.top_idx, 721 browser->b.top_idx,
722 self->nr_asm_entries); 722 browser->nr_asm_entries);
723 } 723 }
724 continue; 724 continue;
725 case K_ENTER: 725 case K_ENTER:
726 case K_RIGHT: 726 case K_RIGHT:
727 if (self->selection == NULL) 727 if (browser->selection == NULL)
728 ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org"); 728 ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org");
729 else if (self->selection->offset == -1) 729 else if (browser->selection->offset == -1)
730 ui_helpline__puts("Actions are only available for assembly lines."); 730 ui_helpline__puts("Actions are only available for assembly lines.");
731 else if (!self->selection->ins) { 731 else if (!browser->selection->ins) {
732 if (strcmp(self->selection->name, "retq")) 732 if (strcmp(browser->selection->name, "retq"))
733 goto show_sup_ins; 733 goto show_sup_ins;
734 goto out; 734 goto out;
735 } else if (!(annotate_browser__jump(self) || 735 } else if (!(annotate_browser__jump(browser) ||
736 annotate_browser__callq(self, evidx, timer, arg, delay_secs))) { 736 annotate_browser__callq(browser, evidx, timer, arg, delay_secs))) {
737show_sup_ins: 737show_sup_ins:
738 ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions."); 738 ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions.");
739 } 739 }
@@ -748,10 +748,10 @@ show_sup_ins:
748 } 748 }
749 749
750 if (nd != NULL) 750 if (nd != NULL)
751 annotate_browser__set_rb_top(self, nd); 751 annotate_browser__set_rb_top(browser, nd);
752 } 752 }
753out: 753out:
754 ui_browser__hide(&self->b); 754 ui_browser__hide(&browser->b);
755 return key; 755 return key;
756} 756}
757 757
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index a372a4b02635..53f6697d014e 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -26,21 +26,21 @@ struct hist_browser {
26 bool has_symbols; 26 bool has_symbols;
27}; 27};
28 28
29static int hists__browser_title(struct hists *self, char *bf, size_t size, 29static int hists__browser_title(struct hists *hists, char *bf, size_t size,
30 const char *ev_name); 30 const char *ev_name);
31 31
32static void hist_browser__refresh_dimensions(struct hist_browser *self) 32static void hist_browser__refresh_dimensions(struct hist_browser *browser)
33{ 33{
34 /* 3 == +/- toggle symbol before actual hist_entry rendering */ 34 /* 3 == +/- toggle symbol before actual hist_entry rendering */
35 self->b.width = 3 + (hists__sort_list_width(self->hists) + 35 browser->b.width = 3 + (hists__sort_list_width(browser->hists) +
36 sizeof("[k]")); 36 sizeof("[k]"));
37} 37}
38 38
39static void hist_browser__reset(struct hist_browser *self) 39static void hist_browser__reset(struct hist_browser *browser)
40{ 40{
41 self->b.nr_entries = self->hists->nr_entries; 41 browser->b.nr_entries = browser->hists->nr_entries;
42 hist_browser__refresh_dimensions(self); 42 hist_browser__refresh_dimensions(browser);
43 ui_browser__reset_index(&self->b); 43 ui_browser__reset_index(&browser->b);
44} 44}
45 45
46static char tree__folded_sign(bool unfolded) 46static char tree__folded_sign(bool unfolded)
@@ -48,32 +48,32 @@ static char tree__folded_sign(bool unfolded)
48 return unfolded ? '-' : '+'; 48 return unfolded ? '-' : '+';
49} 49}
50 50
51static char map_symbol__folded(const struct map_symbol *self) 51static char map_symbol__folded(const struct map_symbol *ms)
52{ 52{
53 return self->has_children ? tree__folded_sign(self->unfolded) : ' '; 53 return ms->has_children ? tree__folded_sign(ms->unfolded) : ' ';
54} 54}
55 55
56static char hist_entry__folded(const struct hist_entry *self) 56static char hist_entry__folded(const struct hist_entry *he)
57{ 57{
58 return map_symbol__folded(&self->ms); 58 return map_symbol__folded(&he->ms);
59} 59}
60 60
61static char callchain_list__folded(const struct callchain_list *self) 61static char callchain_list__folded(const struct callchain_list *cl)
62{ 62{
63 return map_symbol__folded(&self->ms); 63 return map_symbol__folded(&cl->ms);
64} 64}
65 65
66static void map_symbol__set_folding(struct map_symbol *self, bool unfold) 66static void map_symbol__set_folding(struct map_symbol *ms, bool unfold)
67{ 67{
68 self->unfolded = unfold ? self->has_children : false; 68 ms->unfolded = unfold ? ms->has_children : false;
69} 69}
70 70
71static int callchain_node__count_rows_rb_tree(struct callchain_node *self) 71static int callchain_node__count_rows_rb_tree(struct callchain_node *node)
72{ 72{
73 int n = 0; 73 int n = 0;
74 struct rb_node *nd; 74 struct rb_node *nd;
75 75
76 for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) { 76 for (nd = rb_first(&node->rb_root); nd; nd = rb_next(nd)) {
77 struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); 77 struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node);
78 struct callchain_list *chain; 78 struct callchain_list *chain;
79 char folded_sign = ' '; /* No children */ 79 char folded_sign = ' '; /* No children */
@@ -123,23 +123,23 @@ static int callchain__count_rows(struct rb_root *chain)
123 return n; 123 return n;
124} 124}
125 125
126static bool map_symbol__toggle_fold(struct map_symbol *self) 126static bool map_symbol__toggle_fold(struct map_symbol *ms)
127{ 127{
128 if (!self) 128 if (!ms)
129 return false; 129 return false;
130 130
131 if (!self->has_children) 131 if (!ms->has_children)
132 return false; 132 return false;
133 133
134 self->unfolded = !self->unfolded; 134 ms->unfolded = !ms->unfolded;
135 return true; 135 return true;
136} 136}
137 137
138static void callchain_node__init_have_children_rb_tree(struct callchain_node *self) 138static void callchain_node__init_have_children_rb_tree(struct callchain_node *node)
139{ 139{
140 struct rb_node *nd = rb_first(&self->rb_root); 140 struct rb_node *nd = rb_first(&node->rb_root);
141 141
142 for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) { 142 for (nd = rb_first(&node->rb_root); nd; nd = rb_next(nd)) {
143 struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); 143 struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node);
144 struct callchain_list *chain; 144 struct callchain_list *chain;
145 bool first = true; 145 bool first = true;
@@ -158,49 +158,49 @@ static void callchain_node__init_have_children_rb_tree(struct callchain_node *se
158 } 158 }
159} 159}
160 160
161static void callchain_node__init_have_children(struct callchain_node *self) 161static void callchain_node__init_have_children(struct callchain_node *node)
162{ 162{
163 struct callchain_list *chain; 163 struct callchain_list *chain;
164 164
165 list_for_each_entry(chain, &self->val, list) 165 list_for_each_entry(chain, &node->val, list)
166 chain->ms.has_children = !RB_EMPTY_ROOT(&self->rb_root); 166 chain->ms.has_children = !RB_EMPTY_ROOT(&node->rb_root);
167 167
168 callchain_node__init_have_children_rb_tree(self); 168 callchain_node__init_have_children_rb_tree(node);
169} 169}
170 170
171static void callchain__init_have_children(struct rb_root *self) 171static void callchain__init_have_children(struct rb_root *root)
172{ 172{
173 struct rb_node *nd; 173 struct rb_node *nd;
174 174
175 for (nd = rb_first(self); nd; nd = rb_next(nd)) { 175 for (nd = rb_first(root); nd; nd = rb_next(nd)) {
176 struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node); 176 struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node);
177 callchain_node__init_have_children(node); 177 callchain_node__init_have_children(node);
178 } 178 }
179} 179}
180 180
181static void hist_entry__init_have_children(struct hist_entry *self) 181static void hist_entry__init_have_children(struct hist_entry *he)
182{ 182{
183 if (!self->init_have_children) { 183 if (!he->init_have_children) {
184 self->ms.has_children = !RB_EMPTY_ROOT(&self->sorted_chain); 184 he->ms.has_children = !RB_EMPTY_ROOT(&he->sorted_chain);
185 callchain__init_have_children(&self->sorted_chain); 185 callchain__init_have_children(&he->sorted_chain);
186 self->init_have_children = true; 186 he->init_have_children = true;
187 } 187 }
188} 188}
189 189
190static bool hist_browser__toggle_fold(struct hist_browser *self) 190static bool hist_browser__toggle_fold(struct hist_browser *browser)
191{ 191{
192 if (map_symbol__toggle_fold(self->selection)) { 192 if (map_symbol__toggle_fold(browser->selection)) {
193 struct hist_entry *he = self->he_selection; 193 struct hist_entry *he = browser->he_selection;
194 194
195 hist_entry__init_have_children(he); 195 hist_entry__init_have_children(he);
196 self->hists->nr_entries -= he->nr_rows; 196 browser->hists->nr_entries -= he->nr_rows;
197 197
198 if (he->ms.unfolded) 198 if (he->ms.unfolded)
199 he->nr_rows = callchain__count_rows(&he->sorted_chain); 199 he->nr_rows = callchain__count_rows(&he->sorted_chain);
200 else 200 else
201 he->nr_rows = 0; 201 he->nr_rows = 0;
202 self->hists->nr_entries += he->nr_rows; 202 browser->hists->nr_entries += he->nr_rows;
203 self->b.nr_entries = self->hists->nr_entries; 203 browser->b.nr_entries = browser->hists->nr_entries;
204 204
205 return true; 205 return true;
206 } 206 }
@@ -209,12 +209,12 @@ static bool hist_browser__toggle_fold(struct hist_browser *self)
209 return false; 209 return false;
210} 210}
211 211
212static int callchain_node__set_folding_rb_tree(struct callchain_node *self, bool unfold) 212static int callchain_node__set_folding_rb_tree(struct callchain_node *node, bool unfold)
213{ 213{
214 int n = 0; 214 int n = 0;
215 struct rb_node *nd; 215 struct rb_node *nd;
216 216
217 for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) { 217 for (nd = rb_first(&node->rb_root); nd; nd = rb_next(nd)) {
218 struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); 218 struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node);
219 struct callchain_list *chain; 219 struct callchain_list *chain;
220 bool has_children = false; 220 bool has_children = false;
@@ -263,37 +263,37 @@ static int callchain__set_folding(struct rb_root *chain, bool unfold)
263 return n; 263 return n;
264} 264}
265 265
266static void hist_entry__set_folding(struct hist_entry *self, bool unfold) 266static void hist_entry__set_folding(struct hist_entry *he, bool unfold)
267{ 267{
268 hist_entry__init_have_children(self); 268 hist_entry__init_have_children(he);
269 map_symbol__set_folding(&self->ms, unfold); 269 map_symbol__set_folding(&he->ms, unfold);
270 270
271 if (self->ms.has_children) { 271 if (he->ms.has_children) {
272 int n = callchain__set_folding(&self->sorted_chain, unfold); 272 int n = callchain__set_folding(&he->sorted_chain, unfold);
273 self->nr_rows = unfold ? n : 0; 273 he->nr_rows = unfold ? n : 0;
274 } else 274 } else
275 self->nr_rows = 0; 275 he->nr_rows = 0;
276} 276}
277 277
278static void hists__set_folding(struct hists *self, bool unfold) 278static void hists__set_folding(struct hists *hists, bool unfold)
279{ 279{
280 struct rb_node *nd; 280 struct rb_node *nd;
281 281
282 self->nr_entries = 0; 282 hists->nr_entries = 0;
283 283
284 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { 284 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
285 struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node); 285 struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
286 hist_entry__set_folding(he, unfold); 286 hist_entry__set_folding(he, unfold);
287 self->nr_entries += 1 + he->nr_rows; 287 hists->nr_entries += 1 + he->nr_rows;
288 } 288 }
289} 289}
290 290
291static void hist_browser__set_folding(struct hist_browser *self, bool unfold) 291static void hist_browser__set_folding(struct hist_browser *browser, bool unfold)
292{ 292{
293 hists__set_folding(self->hists, unfold); 293 hists__set_folding(browser->hists, unfold);
294 self->b.nr_entries = self->hists->nr_entries; 294 browser->b.nr_entries = browser->hists->nr_entries;
295 /* Go to the start, we may be way after valid entries after a collapse */ 295 /* Go to the start, we may be way after valid entries after a collapse */
296 ui_browser__reset_index(&self->b); 296 ui_browser__reset_index(&browser->b);
297} 297}
298 298
299static void ui_browser__warn_lost_events(struct ui_browser *browser) 299static void ui_browser__warn_lost_events(struct ui_browser *browser)
@@ -305,64 +305,64 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser)
305 "Or reduce the sampling frequency."); 305 "Or reduce the sampling frequency.");
306} 306}
307 307
308static int hist_browser__run(struct hist_browser *self, const char *ev_name, 308static int hist_browser__run(struct hist_browser *browser, const char *ev_name,
309 void(*timer)(void *arg), void *arg, int delay_secs) 309 void(*timer)(void *arg), void *arg, int delay_secs)
310{ 310{
311 int key; 311 int key;
312 char title[160]; 312 char title[160];
313 313
314 self->b.entries = &self->hists->entries; 314 browser->b.entries = &browser->hists->entries;
315 self->b.nr_entries = self->hists->nr_entries; 315 browser->b.nr_entries = browser->hists->nr_entries;
316 316
317 hist_browser__refresh_dimensions(self); 317 hist_browser__refresh_dimensions(browser);
318 hists__browser_title(self->hists, title, sizeof(title), ev_name); 318 hists__browser_title(browser->hists, title, sizeof(title), ev_name);
319 319
320 if (ui_browser__show(&self->b, title, 320 if (ui_browser__show(&browser->b, title,
321 "Press '?' for help on key bindings") < 0) 321 "Press '?' for help on key bindings") < 0)
322 return -1; 322 return -1;
323 323
324 while (1) { 324 while (1) {
325 key = ui_browser__run(&self->b, delay_secs); 325 key = ui_browser__run(&browser->b, delay_secs);
326 326
327 switch (key) { 327 switch (key) {
328 case K_TIMER: 328 case K_TIMER:
329 timer(arg); 329 timer(arg);
330 ui_browser__update_nr_entries(&self->b, self->hists->nr_entries); 330 ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries);
331 331
332 if (self->hists->stats.nr_lost_warned != 332 if (browser->hists->stats.nr_lost_warned !=
333 self->hists->stats.nr_events[PERF_RECORD_LOST]) { 333 browser->hists->stats.nr_events[PERF_RECORD_LOST]) {
334 self->hists->stats.nr_lost_warned = 334 browser->hists->stats.nr_lost_warned =
335 self->hists->stats.nr_events[PERF_RECORD_LOST]; 335 browser->hists->stats.nr_events[PERF_RECORD_LOST];
336 ui_browser__warn_lost_events(&self->b); 336 ui_browser__warn_lost_events(&browser->b);
337 } 337 }
338 338
339 hists__browser_title(self->hists, title, sizeof(title), ev_name); 339 hists__browser_title(browser->hists, title, sizeof(title), ev_name);
340 ui_browser__show_title(&self->b, title); 340 ui_browser__show_title(&browser->b, title);
341 continue; 341 continue;
342 case 'D': { /* Debug */ 342 case 'D': { /* Debug */
343 static int seq; 343 static int seq;
344 struct hist_entry *h = rb_entry(self->b.top, 344 struct hist_entry *h = rb_entry(browser->b.top,
345 struct hist_entry, rb_node); 345 struct hist_entry, rb_node);
346 ui_helpline__pop(); 346 ui_helpline__pop();
347 ui_helpline__fpush("%d: nr_ent=(%d,%d), height=%d, idx=%d, fve: idx=%d, row_off=%d, nrows=%d", 347 ui_helpline__fpush("%d: nr_ent=(%d,%d), height=%d, idx=%d, fve: idx=%d, row_off=%d, nrows=%d",
348 seq++, self->b.nr_entries, 348 seq++, browser->b.nr_entries,
349 self->hists->nr_entries, 349 browser->hists->nr_entries,
350 self->b.height, 350 browser->b.height,
351 self->b.index, 351 browser->b.index,
352 self->b.top_idx, 352 browser->b.top_idx,
353 h->row_offset, h->nr_rows); 353 h->row_offset, h->nr_rows);
354 } 354 }
355 break; 355 break;
356 case 'C': 356 case 'C':
357 /* Collapse the whole world. */ 357 /* Collapse the whole world. */
358 hist_browser__set_folding(self, false); 358 hist_browser__set_folding(browser, false);
359 break; 359 break;
360 case 'E': 360 case 'E':
361 /* Expand the whole world. */ 361 /* Expand the whole world. */
362 hist_browser__set_folding(self, true); 362 hist_browser__set_folding(browser, true);
363 break; 363 break;
364 case K_ENTER: 364 case K_ENTER:
365 if (hist_browser__toggle_fold(self)) 365 if (hist_browser__toggle_fold(browser))
366 break; 366 break;
367 /* fall thru */ 367 /* fall thru */
368 default: 368 default:
@@ -370,23 +370,23 @@ static int hist_browser__run(struct hist_browser *self, const char *ev_name,
370 } 370 }
371 } 371 }
372out: 372out:
373 ui_browser__hide(&self->b); 373 ui_browser__hide(&browser->b);
374 return key; 374 return key;
375} 375}
376 376
377static char *callchain_list__sym_name(struct callchain_list *self, 377static char *callchain_list__sym_name(struct callchain_list *cl,
378 char *bf, size_t bfsize) 378 char *bf, size_t bfsize)
379{ 379{
380 if (self->ms.sym) 380 if (cl->ms.sym)
381 return self->ms.sym->name; 381 return cl->ms.sym->name;
382 382
383 snprintf(bf, bfsize, "%#" PRIx64, self->ip); 383 snprintf(bf, bfsize, "%#" PRIx64, cl->ip);
384 return bf; 384 return bf;
385} 385}
386 386
387#define LEVEL_OFFSET_STEP 3 387#define LEVEL_OFFSET_STEP 3
388 388
389static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self, 389static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *browser,
390 struct callchain_node *chain_node, 390 struct callchain_node *chain_node,
391 u64 total, int level, 391 u64 total, int level,
392 unsigned short row, 392 unsigned short row,
@@ -444,21 +444,21 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self,
444 } 444 }
445 445
446 color = HE_COLORSET_NORMAL; 446 color = HE_COLORSET_NORMAL;
447 width = self->b.width - (offset + extra_offset + 2); 447 width = browser->b.width - (offset + extra_offset + 2);
448 if (ui_browser__is_current_entry(&self->b, row)) { 448 if (ui_browser__is_current_entry(&browser->b, row)) {
449 self->selection = &chain->ms; 449 browser->selection = &chain->ms;
450 color = HE_COLORSET_SELECTED; 450 color = HE_COLORSET_SELECTED;
451 *is_current_entry = true; 451 *is_current_entry = true;
452 } 452 }
453 453
454 ui_browser__set_color(&self->b, color); 454 ui_browser__set_color(&browser->b, color);
455 ui_browser__gotorc(&self->b, row, 0); 455 ui_browser__gotorc(&browser->b, row, 0);
456 slsmg_write_nstring(" ", offset + extra_offset); 456 slsmg_write_nstring(" ", offset + extra_offset);
457 slsmg_printf("%c ", folded_sign); 457 slsmg_printf("%c ", folded_sign);
458 slsmg_write_nstring(str, width); 458 slsmg_write_nstring(str, width);
459 free(alloc_str); 459 free(alloc_str);
460 460
461 if (++row == self->b.height) 461 if (++row == browser->b.height)
462 goto out; 462 goto out;
463do_next: 463do_next:
464 if (folded_sign == '+') 464 if (folded_sign == '+')
@@ -467,11 +467,11 @@ do_next:
467 467
468 if (folded_sign == '-') { 468 if (folded_sign == '-') {
469 const int new_level = level + (extra_offset ? 2 : 1); 469 const int new_level = level + (extra_offset ? 2 : 1);
470 row += hist_browser__show_callchain_node_rb_tree(self, child, new_total, 470 row += hist_browser__show_callchain_node_rb_tree(browser, child, new_total,
471 new_level, row, row_offset, 471 new_level, row, row_offset,
472 is_current_entry); 472 is_current_entry);
473 } 473 }
474 if (row == self->b.height) 474 if (row == browser->b.height)
475 goto out; 475 goto out;
476 node = next; 476 node = next;
477 } 477 }
@@ -479,7 +479,7 @@ out:
479 return row - first_row; 479 return row - first_row;
480} 480}
481 481
482static int hist_browser__show_callchain_node(struct hist_browser *self, 482static int hist_browser__show_callchain_node(struct hist_browser *browser,
483 struct callchain_node *node, 483 struct callchain_node *node,
484 int level, unsigned short row, 484 int level, unsigned short row,
485 off_t *row_offset, 485 off_t *row_offset,
@@ -488,7 +488,7 @@ static int hist_browser__show_callchain_node(struct hist_browser *self,
488 struct callchain_list *chain; 488 struct callchain_list *chain;
489 int first_row = row, 489 int first_row = row,
490 offset = level * LEVEL_OFFSET_STEP, 490 offset = level * LEVEL_OFFSET_STEP,
491 width = self->b.width - offset; 491 width = browser->b.width - offset;
492 char folded_sign = ' '; 492 char folded_sign = ' ';
493 493
494 list_for_each_entry(chain, &node->val, list) { 494 list_for_each_entry(chain, &node->val, list) {
@@ -503,26 +503,26 @@ static int hist_browser__show_callchain_node(struct hist_browser *self,
503 } 503 }
504 504
505 color = HE_COLORSET_NORMAL; 505 color = HE_COLORSET_NORMAL;
506 if (ui_browser__is_current_entry(&self->b, row)) { 506 if (ui_browser__is_current_entry(&browser->b, row)) {
507 self->selection = &chain->ms; 507 browser->selection = &chain->ms;
508 color = HE_COLORSET_SELECTED; 508 color = HE_COLORSET_SELECTED;
509 *is_current_entry = true; 509 *is_current_entry = true;
510 } 510 }
511 511
512 s = callchain_list__sym_name(chain, ipstr, sizeof(ipstr)); 512 s = callchain_list__sym_name(chain, ipstr, sizeof(ipstr));
513 ui_browser__gotorc(&self->b, row, 0); 513 ui_browser__gotorc(&browser->b, row, 0);
514 ui_browser__set_color(&self->b, color); 514 ui_browser__set_color(&browser->b, color);
515 slsmg_write_nstring(" ", offset); 515 slsmg_write_nstring(" ", offset);
516 slsmg_printf("%c ", folded_sign); 516 slsmg_printf("%c ", folded_sign);
517 slsmg_write_nstring(s, width - 2); 517 slsmg_write_nstring(s, width - 2);
518 518
519 if (++row == self->b.height) 519 if (++row == browser->b.height)
520 goto out; 520 goto out;
521 } 521 }
522 522
523 if (folded_sign == '-') 523 if (folded_sign == '-')
524 row += hist_browser__show_callchain_node_rb_tree(self, node, 524 row += hist_browser__show_callchain_node_rb_tree(browser, node,
525 self->hists->stats.total_period, 525 browser->hists->stats.total_period,
526 level + 1, row, 526 level + 1, row,
527 row_offset, 527 row_offset,
528 is_current_entry); 528 is_current_entry);
@@ -530,7 +530,7 @@ out:
530 return row - first_row; 530 return row - first_row;
531} 531}
532 532
533static int hist_browser__show_callchain(struct hist_browser *self, 533static int hist_browser__show_callchain(struct hist_browser *browser,
534 struct rb_root *chain, 534 struct rb_root *chain,
535 int level, unsigned short row, 535 int level, unsigned short row,
536 off_t *row_offset, 536 off_t *row_offset,
@@ -542,31 +542,31 @@ static int hist_browser__show_callchain(struct hist_browser *self,
542 for (nd = rb_first(chain); nd; nd = rb_next(nd)) { 542 for (nd = rb_first(chain); nd; nd = rb_next(nd)) {
543 struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node); 543 struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node);
544 544
545 row += hist_browser__show_callchain_node(self, node, level, 545 row += hist_browser__show_callchain_node(browser, node, level,
546 row, row_offset, 546 row, row_offset,
547 is_current_entry); 547 is_current_entry);
548 if (row == self->b.height) 548 if (row == browser->b.height)
549 break; 549 break;
550 } 550 }
551 551
552 return row - first_row; 552 return row - first_row;
553} 553}
554 554
555static int hist_browser__show_entry(struct hist_browser *self, 555static int hist_browser__show_entry(struct hist_browser *browser,
556 struct hist_entry *entry, 556 struct hist_entry *entry,
557 unsigned short row) 557 unsigned short row)
558{ 558{
559 char s[256]; 559 char s[256];
560 double percent; 560 double percent;
561 int printed = 0; 561 int printed = 0;
562 int width = self->b.width - 6; /* The percentage */ 562 int width = browser->b.width - 6; /* The percentage */
563 char folded_sign = ' '; 563 char folded_sign = ' ';
564 bool current_entry = ui_browser__is_current_entry(&self->b, row); 564 bool current_entry = ui_browser__is_current_entry(&browser->b, row);
565 off_t row_offset = entry->row_offset; 565 off_t row_offset = entry->row_offset;
566 566
567 if (current_entry) { 567 if (current_entry) {
568 self->he_selection = entry; 568 browser->he_selection = entry;
569 self->selection = &entry->ms; 569 browser->selection = &entry->ms;
570 } 570 }
571 571
572 if (symbol_conf.use_callchain) { 572 if (symbol_conf.use_callchain) {
@@ -575,11 +575,11 @@ static int hist_browser__show_entry(struct hist_browser *self,
575 } 575 }
576 576
577 if (row_offset == 0) { 577 if (row_offset == 0) {
578 hist_entry__snprintf(entry, s, sizeof(s), self->hists); 578 hist_entry__snprintf(entry, s, sizeof(s), browser->hists);
579 percent = (entry->period * 100.0) / self->hists->stats.total_period; 579 percent = (entry->period * 100.0) / browser->hists->stats.total_period;
580 580
581 ui_browser__set_percent_color(&self->b, percent, current_entry); 581 ui_browser__set_percent_color(&browser->b, percent, current_entry);
582 ui_browser__gotorc(&self->b, row, 0); 582 ui_browser__gotorc(&browser->b, row, 0);
583 if (symbol_conf.use_callchain) { 583 if (symbol_conf.use_callchain) {
584 slsmg_printf("%c ", folded_sign); 584 slsmg_printf("%c ", folded_sign);
585 width -= 2; 585 width -= 2;
@@ -588,11 +588,11 @@ static int hist_browser__show_entry(struct hist_browser *self,
588 slsmg_printf(" %5.2f%%", percent); 588 slsmg_printf(" %5.2f%%", percent);
589 589
590 /* The scroll bar isn't being used */ 590 /* The scroll bar isn't being used */
591 if (!self->b.navkeypressed) 591 if (!browser->b.navkeypressed)
592 width += 1; 592 width += 1;
593 593
594 if (!current_entry || !self->b.navkeypressed) 594 if (!current_entry || !browser->b.navkeypressed)
595 ui_browser__set_color(&self->b, HE_COLORSET_NORMAL); 595 ui_browser__set_color(&browser->b, HE_COLORSET_NORMAL);
596 596
597 if (symbol_conf.show_nr_samples) { 597 if (symbol_conf.show_nr_samples) {
598 slsmg_printf(" %11u", entry->nr_events); 598 slsmg_printf(" %11u", entry->nr_events);
@@ -610,12 +610,12 @@ static int hist_browser__show_entry(struct hist_browser *self,
610 } else 610 } else
611 --row_offset; 611 --row_offset;
612 612
613 if (folded_sign == '-' && row != self->b.height) { 613 if (folded_sign == '-' && row != browser->b.height) {
614 printed += hist_browser__show_callchain(self, &entry->sorted_chain, 614 printed += hist_browser__show_callchain(browser, &entry->sorted_chain,
615 1, row, &row_offset, 615 1, row, &row_offset,
616 &current_entry); 616 &current_entry);
617 if (current_entry) 617 if (current_entry)
618 self->he_selection = entry; 618 browser->he_selection = entry;
619 } 619 }
620 620
621 return printed; 621 return printed;
@@ -631,22 +631,22 @@ static void ui_browser__hists_init_top(struct ui_browser *browser)
631 } 631 }
632} 632}
633 633
634static unsigned int hist_browser__refresh(struct ui_browser *self) 634static unsigned int hist_browser__refresh(struct ui_browser *browser)
635{ 635{
636 unsigned row = 0; 636 unsigned row = 0;
637 struct rb_node *nd; 637 struct rb_node *nd;
638 struct hist_browser *hb = container_of(self, struct hist_browser, b); 638 struct hist_browser *hb = container_of(browser, struct hist_browser, b);
639 639
640 ui_browser__hists_init_top(self); 640 ui_browser__hists_init_top(browser);
641 641
642 for (nd = self->top; nd; nd = rb_next(nd)) { 642 for (nd = browser->top; nd; nd = rb_next(nd)) {
643 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 643 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
644 644
645 if (h->filtered) 645 if (h->filtered)
646 continue; 646 continue;
647 647
648 row += hist_browser__show_entry(hb, h, row); 648 row += hist_browser__show_entry(hb, h, row);
649 if (row == self->height) 649 if (row == browser->height)
650 break; 650 break;
651 } 651 }
652 652
@@ -679,27 +679,27 @@ static struct rb_node *hists__filter_prev_entries(struct rb_node *nd)
679 return NULL; 679 return NULL;
680} 680}
681 681
682static void ui_browser__hists_seek(struct ui_browser *self, 682static void ui_browser__hists_seek(struct ui_browser *browser,
683 off_t offset, int whence) 683 off_t offset, int whence)
684{ 684{
685 struct hist_entry *h; 685 struct hist_entry *h;
686 struct rb_node *nd; 686 struct rb_node *nd;
687 bool first = true; 687 bool first = true;
688 688
689 if (self->nr_entries == 0) 689 if (browser->nr_entries == 0)
690 return; 690 return;
691 691
692 ui_browser__hists_init_top(self); 692 ui_browser__hists_init_top(browser);
693 693
694 switch (whence) { 694 switch (whence) {
695 case SEEK_SET: 695 case SEEK_SET:
696 nd = hists__filter_entries(rb_first(self->entries)); 696 nd = hists__filter_entries(rb_first(browser->entries));
697 break; 697 break;
698 case SEEK_CUR: 698 case SEEK_CUR:
699 nd = self->top; 699 nd = browser->top;
700 goto do_offset; 700 goto do_offset;
701 case SEEK_END: 701 case SEEK_END:
702 nd = hists__filter_prev_entries(rb_last(self->entries)); 702 nd = hists__filter_prev_entries(rb_last(browser->entries));
703 first = false; 703 first = false;
704 break; 704 break;
705 default: 705 default:
@@ -710,7 +710,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
710 * Moves not relative to the first visible entry invalidates its 710 * Moves not relative to the first visible entry invalidates its
711 * row_offset: 711 * row_offset:
712 */ 712 */
713 h = rb_entry(self->top, struct hist_entry, rb_node); 713 h = rb_entry(browser->top, struct hist_entry, rb_node);
714 h->row_offset = 0; 714 h->row_offset = 0;
715 715
716 /* 716 /*
@@ -738,7 +738,7 @@ do_offset:
738 } else { 738 } else {
739 h->row_offset += offset; 739 h->row_offset += offset;
740 offset = 0; 740 offset = 0;
741 self->top = nd; 741 browser->top = nd;
742 break; 742 break;
743 } 743 }
744 } 744 }
@@ -746,7 +746,7 @@ do_offset:
746 if (nd == NULL) 746 if (nd == NULL)
747 break; 747 break;
748 --offset; 748 --offset;
749 self->top = nd; 749 browser->top = nd;
750 } while (offset != 0); 750 } while (offset != 0);
751 } else if (offset < 0) { 751 } else if (offset < 0) {
752 while (1) { 752 while (1) {
@@ -759,7 +759,7 @@ do_offset:
759 } else { 759 } else {
760 h->row_offset += offset; 760 h->row_offset += offset;
761 offset = 0; 761 offset = 0;
762 self->top = nd; 762 browser->top = nd;
763 break; 763 break;
764 } 764 }
765 } else { 765 } else {
@@ -769,7 +769,7 @@ do_offset:
769 } else { 769 } else {
770 h->row_offset = h->nr_rows + offset; 770 h->row_offset = h->nr_rows + offset;
771 offset = 0; 771 offset = 0;
772 self->top = nd; 772 browser->top = nd;
773 break; 773 break;
774 } 774 }
775 } 775 }
@@ -779,7 +779,7 @@ do_offset:
779 if (nd == NULL) 779 if (nd == NULL)
780 break; 780 break;
781 ++offset; 781 ++offset;
782 self->top = nd; 782 browser->top = nd;
783 if (offset == 0) { 783 if (offset == 0) {
784 /* 784 /*
785 * Last unfiltered hist_entry, check if it is 785 * Last unfiltered hist_entry, check if it is
@@ -794,7 +794,7 @@ do_offset:
794 first = false; 794 first = false;
795 } 795 }
796 } else { 796 } else {
797 self->top = nd; 797 browser->top = nd;
798 h = rb_entry(nd, struct hist_entry, rb_node); 798 h = rb_entry(nd, struct hist_entry, rb_node);
799 h->row_offset = 0; 799 h->row_offset = 0;
800 } 800 }
@@ -802,46 +802,46 @@ do_offset:
802 802
803static struct hist_browser *hist_browser__new(struct hists *hists) 803static struct hist_browser *hist_browser__new(struct hists *hists)
804{ 804{
805 struct hist_browser *self = zalloc(sizeof(*self)); 805 struct hist_browser *browser = zalloc(sizeof(*browser));
806 806
807 if (self) { 807 if (browser) {
808 self->hists = hists; 808 browser->hists = hists;
809 self->b.refresh = hist_browser__refresh; 809 browser->b.refresh = hist_browser__refresh;
810 self->b.seek = ui_browser__hists_seek; 810 browser->b.seek = ui_browser__hists_seek;
811 self->b.use_navkeypressed = true; 811 browser->b.use_navkeypressed = true;
812 if (sort__branch_mode == 1) 812 if (sort__branch_mode == 1)
813 self->has_symbols = sort_sym_from.list.next != NULL; 813 browser->has_symbols = sort_sym_from.list.next != NULL;
814 else 814 else
815 self->has_symbols = sort_sym.list.next != NULL; 815 browser->has_symbols = sort_sym.list.next != NULL;
816 } 816 }
817 817
818 return self; 818 return browser;
819} 819}
820 820
821static void hist_browser__delete(struct hist_browser *self) 821static void hist_browser__delete(struct hist_browser *browser)
822{ 822{
823 free(self); 823 free(browser);
824} 824}
825 825
826static struct hist_entry *hist_browser__selected_entry(struct hist_browser *self) 826static struct hist_entry *hist_browser__selected_entry(struct hist_browser *browser)
827{ 827{
828 return self->he_selection; 828 return browser->he_selection;
829} 829}
830 830
831static struct thread *hist_browser__selected_thread(struct hist_browser *self) 831static struct thread *hist_browser__selected_thread(struct hist_browser *browser)
832{ 832{
833 return self->he_selection->thread; 833 return browser->he_selection->thread;
834} 834}
835 835
836static int hists__browser_title(struct hists *self, char *bf, size_t size, 836static int hists__browser_title(struct hists *hists, char *bf, size_t size,
837 const char *ev_name) 837 const char *ev_name)
838{ 838{
839 char unit; 839 char unit;
840 int printed; 840 int printed;
841 const struct dso *dso = self->dso_filter; 841 const struct dso *dso = hists->dso_filter;
842 const struct thread *thread = self->thread_filter; 842 const struct thread *thread = hists->thread_filter;
843 unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE]; 843 unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
844 u64 nr_events = self->stats.total_period; 844 u64 nr_events = hists->stats.total_period;
845 845
846 nr_samples = convert_unit(nr_samples, &unit); 846 nr_samples = convert_unit(nr_samples, &unit);
847 printed = scnprintf(bf, size, 847 printed = scnprintf(bf, size,
@@ -849,9 +849,9 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size,
849 nr_samples, unit, ev_name, nr_events); 849 nr_samples, unit, ev_name, nr_events);
850 850
851 851
852 if (self->uid_filter_str) 852 if (hists->uid_filter_str)
853 printed += snprintf(bf + printed, size - printed, 853 printed += snprintf(bf + printed, size - printed,
854 ", UID: %s", self->uid_filter_str); 854 ", UID: %s", hists->uid_filter_str);
855 if (thread) 855 if (thread)
856 printed += scnprintf(bf + printed, size - printed, 856 printed += scnprintf(bf + printed, size - printed,
857 ", Thread: %s(%d)", 857 ", Thread: %s(%d)",
@@ -879,8 +879,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
879 void(*timer)(void *arg), void *arg, 879 void(*timer)(void *arg), void *arg,
880 int delay_secs) 880 int delay_secs)
881{ 881{
882 struct hists *self = &evsel->hists; 882 struct hists *hists = &evsel->hists;
883 struct hist_browser *browser = hist_browser__new(self); 883 struct hist_browser *browser = hist_browser__new(hists);
884 struct branch_info *bi; 884 struct branch_info *bi;
885 struct pstack *fstack; 885 struct pstack *fstack;
886 char *options[16]; 886 char *options[16];
@@ -946,8 +946,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
946 "Please enter the name of symbol you want to see", 946 "Please enter the name of symbol you want to see",
947 buf, "ENTER: OK, ESC: Cancel", 947 buf, "ENTER: OK, ESC: Cancel",
948 delay_secs * 2) == K_ENTER) { 948 delay_secs * 2) == K_ENTER) {
949 self->symbol_filter_str = *buf ? buf : NULL; 949 hists->symbol_filter_str = *buf ? buf : NULL;
950 hists__filter_by_symbol(self); 950 hists__filter_by_symbol(hists);
951 hist_browser__reset(browser); 951 hist_browser__reset(browser);
952 } 952 }
953 continue; 953 continue;
@@ -1128,7 +1128,7 @@ zoom_out_dso:
1128 sort_dso.elide = true; 1128 sort_dso.elide = true;
1129 pstack__push(fstack, &browser->hists->dso_filter); 1129 pstack__push(fstack, &browser->hists->dso_filter);
1130 } 1130 }
1131 hists__filter_by_dso(self); 1131 hists__filter_by_dso(hists);
1132 hist_browser__reset(browser); 1132 hist_browser__reset(browser);
1133 } else if (choice == zoom_thread) { 1133 } else if (choice == zoom_thread) {
1134zoom_thread: 1134zoom_thread:
@@ -1146,7 +1146,7 @@ zoom_out_thread:
1146 sort_thread.elide = true; 1146 sort_thread.elide = true;
1147 pstack__push(fstack, &browser->hists->thread_filter); 1147 pstack__push(fstack, &browser->hists->thread_filter);
1148 } 1148 }
1149 hists__filter_by_thread(self); 1149 hists__filter_by_thread(hists);
1150 hist_browser__reset(browser); 1150 hist_browser__reset(browser);
1151 } 1151 }
1152 } 1152 }