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: default avatarThomas 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c323cf04
...@@ -35,16 +35,16 @@ int ui_browser__set_color(struct ui_browser *browser, int color) ...@@ -35,16 +35,16 @@ int ui_browser__set_color(struct ui_browser *browser, int color)
return ret; return ret;
} }
void ui_browser__set_percent_color(struct ui_browser *self, void ui_browser__set_percent_color(struct ui_browser *browser,
double percent, bool current) double percent, bool current)
{ {
int color = ui_browser__percent_color(self, percent, current); int color = ui_browser__percent_color(browser, percent, current);
ui_browser__set_color(self, color); ui_browser__set_color(browser, color);
} }
void ui_browser__gotorc(struct ui_browser *self, int y, int x) void ui_browser__gotorc(struct ui_browser *browser, int y, int x)
{ {
SLsmg_gotorc(self->y + y, self->x + x); SLsmg_gotorc(browser->y + y, browser->x + x);
} }
static struct list_head * static struct list_head *
...@@ -73,23 +73,23 @@ ui_browser__list_head_filter_prev_entries(struct ui_browser *browser, ...@@ -73,23 +73,23 @@ ui_browser__list_head_filter_prev_entries(struct ui_browser *browser,
return NULL; return NULL;
} }
void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whence) void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int whence)
{ {
struct list_head *head = self->entries; struct list_head *head = browser->entries;
struct list_head *pos; struct list_head *pos;
if (self->nr_entries == 0) if (browser->nr_entries == 0)
return; return;
switch (whence) { switch (whence) {
case SEEK_SET: case SEEK_SET:
pos = ui_browser__list_head_filter_entries(self, head->next); pos = ui_browser__list_head_filter_entries(browser, head->next);
break; break;
case SEEK_CUR: case SEEK_CUR:
pos = self->top; pos = browser->top;
break; break;
case SEEK_END: case SEEK_END:
pos = ui_browser__list_head_filter_prev_entries(self, head->prev); pos = ui_browser__list_head_filter_prev_entries(browser, head->prev);
break; break;
default: default:
return; return;
...@@ -99,18 +99,18 @@ void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whenc ...@@ -99,18 +99,18 @@ void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whenc
if (offset > 0) { if (offset > 0) {
while (offset-- != 0) while (offset-- != 0)
pos = ui_browser__list_head_filter_entries(self, pos->next); pos = ui_browser__list_head_filter_entries(browser, pos->next);
} else { } else {
while (offset++ != 0) while (offset++ != 0)
pos = ui_browser__list_head_filter_prev_entries(self, pos->prev); pos = ui_browser__list_head_filter_prev_entries(browser, pos->prev);
} }
self->top = pos; browser->top = pos;
} }
void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence) void ui_browser__rb_tree_seek(struct ui_browser *browser, off_t offset, int whence)
{ {
struct rb_root *root = self->entries; struct rb_root *root = browser->entries;
struct rb_node *nd; struct rb_node *nd;
switch (whence) { switch (whence) {
...@@ -118,7 +118,7 @@ void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence) ...@@ -118,7 +118,7 @@ void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence)
nd = rb_first(root); nd = rb_first(root);
break; break;
case SEEK_CUR: case SEEK_CUR:
nd = self->top; nd = browser->top;
break; break;
case SEEK_END: case SEEK_END:
nd = rb_last(root); nd = rb_last(root);
...@@ -135,23 +135,23 @@ void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence) ...@@ -135,23 +135,23 @@ void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence)
nd = rb_prev(nd); nd = rb_prev(nd);
} }
self->top = nd; browser->top = nd;
} }
unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self) unsigned int ui_browser__rb_tree_refresh(struct ui_browser *browser)
{ {
struct rb_node *nd; struct rb_node *nd;
int row = 0; int row = 0;
if (self->top == NULL) if (browser->top == NULL)
self->top = rb_first(self->entries); browser->top = rb_first(browser->entries);
nd = self->top; nd = browser->top;
while (nd != NULL) { while (nd != NULL) {
ui_browser__gotorc(self, row, 0); ui_browser__gotorc(browser, row, 0);
self->write(self, nd, row); browser->write(browser, nd, row);
if (++row == self->height) if (++row == browser->height)
break; break;
nd = rb_next(nd); nd = rb_next(nd);
} }
...@@ -159,17 +159,17 @@ unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self) ...@@ -159,17 +159,17 @@ unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self)
return row; return row;
} }
bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row) bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row)
{ {
return self->top_idx + row == self->index; return browser->top_idx + row == browser->index;
} }
void ui_browser__refresh_dimensions(struct ui_browser *self) void ui_browser__refresh_dimensions(struct ui_browser *browser)
{ {
self->width = SLtt_Screen_Cols - 1; browser->width = SLtt_Screen_Cols - 1;
self->height = SLtt_Screen_Rows - 2; browser->height = SLtt_Screen_Rows - 2;
self->y = 1; browser->y = 1;
self->x = 0; browser->x = 0;
} }
void ui_browser__handle_resize(struct ui_browser *browser) void 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,10 +225,10 @@ bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text)
return key == K_ENTER || toupper(key) == 'Y'; return key == K_ENTER || toupper(key) == 'Y';
} }
void ui_browser__reset_index(struct ui_browser *self) void ui_browser__reset_index(struct ui_browser *browser)
{ {
self->index = self->top_idx = 0; browser->index = browser->top_idx = 0;
self->seek(self, 0, SEEK_SET); browser->seek(browser, 0, SEEK_SET);
} }
void __ui_browser__show_title(struct ui_browser *browser, const char *title) void __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,26 +245,26 @@ void ui_browser__show_title(struct ui_browser *browser, const char *title)
pthread_mutex_unlock(&ui__lock); pthread_mutex_unlock(&ui__lock);
} }
int ui_browser__show(struct ui_browser *self, const char *title, int ui_browser__show(struct ui_browser *browser, const char *title,
const char *helpline, ...) const char *helpline, ...)
{ {
int err; int err;
va_list ap; va_list ap;
ui_browser__refresh_dimensions(self); ui_browser__refresh_dimensions(browser);
pthread_mutex_lock(&ui__lock); pthread_mutex_lock(&ui__lock);
__ui_browser__show_title(self, title); __ui_browser__show_title(browser, title);
self->title = title; browser->title = title;
free(self->helpline); free(browser->helpline);
self->helpline = NULL; browser->helpline = NULL;
va_start(ap, helpline); va_start(ap, helpline);
err = vasprintf(&self->helpline, helpline, ap); err = vasprintf(&browser->helpline, helpline, ap);
va_end(ap); va_end(ap);
if (err > 0) if (err > 0)
ui_helpline__push(self->helpline); ui_helpline__push(browser->helpline);
pthread_mutex_unlock(&ui__lock); pthread_mutex_unlock(&ui__lock);
return err ? 0 : -1; return err ? 0 : -1;
} }
...@@ -350,7 +350,7 @@ void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries) ...@@ -350,7 +350,7 @@ void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries)
browser->seek(browser, browser->top_idx, SEEK_SET); browser->seek(browser, browser->top_idx, SEEK_SET);
} }
int ui_browser__run(struct ui_browser *self, int delay_secs) int ui_browser__run(struct ui_browser *browser, int delay_secs)
{ {
int err, key; int err, key;
...@@ -358,7 +358,7 @@ int ui_browser__run(struct ui_browser *self, int delay_secs) ...@@ -358,7 +358,7 @@ int ui_browser__run(struct ui_browser *self, int delay_secs)
off_t offset; off_t offset;
pthread_mutex_lock(&ui__lock); pthread_mutex_lock(&ui__lock);
err = __ui_browser__refresh(self); err = __ui_browser__refresh(browser);
SLsmg_refresh(); SLsmg_refresh();
pthread_mutex_unlock(&ui__lock); pthread_mutex_unlock(&ui__lock);
if (err < 0) if (err < 0)
...@@ -368,18 +368,18 @@ int ui_browser__run(struct ui_browser *self, int delay_secs) ...@@ -368,18 +368,18 @@ int ui_browser__run(struct ui_browser *self, int delay_secs)
if (key == K_RESIZE) { if (key == K_RESIZE) {
ui__refresh_dimensions(false); ui__refresh_dimensions(false);
ui_browser__refresh_dimensions(self); ui_browser__refresh_dimensions(browser);
__ui_browser__show_title(self, self->title); __ui_browser__show_title(browser, browser->title);
ui_helpline__puts(self->helpline); ui_helpline__puts(browser->helpline);
continue; continue;
} }
if (self->use_navkeypressed && !self->navkeypressed) { if (browser->use_navkeypressed && !browser->navkeypressed) {
if (key == K_DOWN || key == K_UP || if (key == K_DOWN || key == K_UP ||
key == K_PGDN || key == K_PGUP || key == K_PGDN || key == K_PGUP ||
key == K_HOME || key == K_END || key == K_HOME || key == K_END ||
key == ' ') { key == ' ') {
self->navkeypressed = true; browser->navkeypressed = true;
continue; continue;
} else } else
return key; return key;
...@@ -387,59 +387,59 @@ int ui_browser__run(struct ui_browser *self, int delay_secs) ...@@ -387,59 +387,59 @@ int ui_browser__run(struct ui_browser *self, int delay_secs)
switch (key) { switch (key) {
case K_DOWN: case K_DOWN:
if (self->index == self->nr_entries - 1) if (browser->index == browser->nr_entries - 1)
break; break;
++self->index; ++browser->index;
if (self->index == self->top_idx + self->height) { if (browser->index == browser->top_idx + browser->height) {
++self->top_idx; ++browser->top_idx;
self->seek(self, +1, SEEK_CUR); browser->seek(browser, +1, SEEK_CUR);
} }
break; break;
case K_UP: case K_UP:
if (self->index == 0) if (browser->index == 0)
break; break;
--self->index; --browser->index;
if (self->index < self->top_idx) { if (browser->index < browser->top_idx) {
--self->top_idx; --browser->top_idx;
self->seek(self, -1, SEEK_CUR); browser->seek(browser, -1, SEEK_CUR);
} }
break; break;
case K_PGDN: case K_PGDN:
case ' ': case ' ':
if (self->top_idx + self->height > self->nr_entries - 1) if (browser->top_idx + browser->height > browser->nr_entries - 1)
break; break;
offset = self->height; offset = browser->height;
if (self->index + offset > self->nr_entries - 1) if (browser->index + offset > browser->nr_entries - 1)
offset = self->nr_entries - 1 - self->index; offset = browser->nr_entries - 1 - browser->index;
self->index += offset; browser->index += offset;
self->top_idx += offset; browser->top_idx += offset;
self->seek(self, +offset, SEEK_CUR); browser->seek(browser, +offset, SEEK_CUR);
break; break;
case K_PGUP: case K_PGUP:
if (self->top_idx == 0) if (browser->top_idx == 0)
break; break;
if (self->top_idx < self->height) if (browser->top_idx < browser->height)
offset = self->top_idx; offset = browser->top_idx;
else else
offset = self->height; offset = browser->height;
self->index -= offset; browser->index -= offset;
self->top_idx -= offset; browser->top_idx -= offset;
self->seek(self, -offset, SEEK_CUR); browser->seek(browser, -offset, SEEK_CUR);
break; break;
case K_HOME: case K_HOME:
ui_browser__reset_index(self); ui_browser__reset_index(browser);
break; break;
case K_END: case K_END:
offset = self->height - 1; offset = browser->height - 1;
if (offset >= self->nr_entries) if (offset >= browser->nr_entries)
offset = self->nr_entries - 1; offset = browser->nr_entries - 1;
self->index = self->nr_entries - 1; browser->index = browser->nr_entries - 1;
self->top_idx = self->index - offset; browser->top_idx = browser->index - offset;
self->seek(self, -offset, SEEK_END); browser->seek(browser, -offset, SEEK_END);
break; break;
default: default:
return key; return key;
...@@ -448,22 +448,22 @@ int ui_browser__run(struct ui_browser *self, int delay_secs) ...@@ -448,22 +448,22 @@ int ui_browser__run(struct ui_browser *self, int delay_secs)
return -1; return -1;
} }
unsigned int ui_browser__list_head_refresh(struct ui_browser *self) unsigned int ui_browser__list_head_refresh(struct ui_browser *browser)
{ {
struct list_head *pos; struct list_head *pos;
struct list_head *head = self->entries; struct list_head *head = browser->entries;
int row = 0; int row = 0;
if (self->top == NULL || self->top == self->entries) if (browser->top == NULL || browser->top == browser->entries)
self->top = ui_browser__list_head_filter_entries(self, head->next); browser->top = ui_browser__list_head_filter_entries(browser, head->next);
pos = self->top; pos = browser->top;
list_for_each_from(pos, head) { list_for_each_from(pos, head) {
if (!self->filter || !self->filter(self, pos)) { if (!browser->filter || !browser->filter(browser, pos)) {
ui_browser__gotorc(self, row, 0); ui_browser__gotorc(browser, row, 0);
self->write(self, pos, row); browser->write(browser, pos, row);
if (++row == self->height) if (++row == browser->height)
break; break;
} }
} }
......
...@@ -83,30 +83,30 @@ static int annotate_browser__set_jumps_percent_color(struct annotate_browser *br ...@@ -83,30 +83,30 @@ static int annotate_browser__set_jumps_percent_color(struct annotate_browser *br
return ui_browser__set_color(&browser->b, color); return ui_browser__set_color(&browser->b, color);
} }
static void annotate_browser__write(struct ui_browser *self, void *entry, int row) static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
{ {
struct annotate_browser *ab = container_of(self, struct annotate_browser, b); struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
struct disasm_line *dl = list_entry(entry, struct disasm_line, node); struct disasm_line *dl = list_entry(entry, struct disasm_line, node);
struct browser_disasm_line *bdl = disasm_line__browser(dl); struct browser_disasm_line *bdl = disasm_line__browser(dl);
bool current_entry = ui_browser__is_current_entry(self, row); bool current_entry = ui_browser__is_current_entry(browser, row);
bool change_color = (!annotate_browser__opts.hide_src_code && bool change_color = (!annotate_browser__opts.hide_src_code &&
(!current_entry || (self->use_navkeypressed && (!current_entry || (browser->use_navkeypressed &&
!self->navkeypressed))); !browser->navkeypressed)));
int width = self->width, printed; int width = browser->width, printed;
char bf[256]; char bf[256];
if (dl->offset != -1 && bdl->percent != 0.0) { if (dl->offset != -1 && bdl->percent != 0.0) {
ui_browser__set_percent_color(self, bdl->percent, current_entry); ui_browser__set_percent_color(browser, bdl->percent, current_entry);
slsmg_printf("%6.2f ", bdl->percent); slsmg_printf("%6.2f ", bdl->percent);
} else { } else {
ui_browser__set_percent_color(self, 0, current_entry); ui_browser__set_percent_color(browser, 0, current_entry);
slsmg_write_nstring(" ", 7); slsmg_write_nstring(" ", 7);
} }
SLsmg_write_char(' '); SLsmg_write_char(' ');
/* The scroll bar isn't being used */ /* The scroll bar isn't being used */
if (!self->navkeypressed) if (!browser->navkeypressed)
width += 1; width += 1;
if (!*dl->line) if (!*dl->line)
...@@ -135,7 +135,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro ...@@ -135,7 +135,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
prev = annotate_browser__set_jumps_percent_color(ab, bdl->jump_sources, prev = annotate_browser__set_jumps_percent_color(ab, bdl->jump_sources,
current_entry); current_entry);
slsmg_write_nstring(bf, printed); slsmg_write_nstring(bf, printed);
ui_browser__set_color(self, prev); ui_browser__set_color(browser, prev);
} }
printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ", printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ": ",
...@@ -147,19 +147,19 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro ...@@ -147,19 +147,19 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
} }
if (change_color) if (change_color)
color = ui_browser__set_color(self, HE_COLORSET_ADDR); color = ui_browser__set_color(browser, HE_COLORSET_ADDR);
slsmg_write_nstring(bf, printed); slsmg_write_nstring(bf, printed);
if (change_color) if (change_color)
ui_browser__set_color(self, color); ui_browser__set_color(browser, color);
if (dl->ins && dl->ins->ops->scnprintf) { if (dl->ins && dl->ins->ops->scnprintf) {
if (ins__is_jump(dl->ins)) { if (ins__is_jump(dl->ins)) {
bool fwd = dl->ops.target.offset > (u64)dl->offset; bool fwd = dl->ops.target.offset > (u64)dl->offset;
ui_browser__write_graph(self, fwd ? SLSMG_DARROW_CHAR : ui_browser__write_graph(browser, fwd ? SLSMG_DARROW_CHAR :
SLSMG_UARROW_CHAR); SLSMG_UARROW_CHAR);
SLsmg_write_char(' '); SLsmg_write_char(' ');
} else if (ins__is_call(dl->ins)) { } else if (ins__is_call(dl->ins)) {
ui_browser__write_graph(self, SLSMG_RARROW_CHAR); ui_browser__write_graph(browser, SLSMG_RARROW_CHAR);
SLsmg_write_char(' '); SLsmg_write_char(' ');
} else { } else {
slsmg_write_nstring(" ", 2); slsmg_write_nstring(" ", 2);
...@@ -168,7 +168,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro ...@@ -168,7 +168,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
if (strcmp(dl->name, "retq")) { if (strcmp(dl->name, "retq")) {
slsmg_write_nstring(" ", 2); slsmg_write_nstring(" ", 2);
} else { } else {
ui_browser__write_graph(self, SLSMG_LARROW_CHAR); ui_browser__write_graph(browser, SLSMG_LARROW_CHAR);
SLsmg_write_char(' '); SLsmg_write_char(' ');
} }
} }
...@@ -275,27 +275,27 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_l ...@@ -275,27 +275,27 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct browser_disasm_l
rb_insert_color(&bdl->rb_node, root); rb_insert_color(&bdl->rb_node, root);
} }
static void annotate_browser__set_top(struct annotate_browser *self, static void annotate_browser__set_top(struct annotate_browser *browser,
struct disasm_line *pos, u32 idx) struct disasm_line *pos, u32 idx)
{ {
unsigned back; unsigned back;
ui_browser__refresh_dimensions(&self->b); ui_browser__refresh_dimensions(&browser->b);
back = self->b.height / 2; back = browser->b.height / 2;
self->b.top_idx = self->b.index = idx; browser->b.top_idx = browser->b.index = idx;
while (self->b.top_idx != 0 && back != 0) { while (browser->b.top_idx != 0 && back != 0) {
pos = list_entry(pos->node.prev, struct disasm_line, node); pos = list_entry(pos->node.prev, struct disasm_line, node);
if (disasm_line__filter(&self->b, &pos->node)) if (disasm_line__filter(&browser->b, &pos->node))
continue; continue;
--self->b.top_idx; --browser->b.top_idx;
--back; --back;
} }
self->b.top = pos; browser->b.top = pos;
self->b.navkeypressed = true; browser->b.navkeypressed = true;
} }
static void annotate_browser__set_rb_top(struct annotate_browser *browser, static 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,33 +600,33 @@ static void annotate_browser__update_addr_width(struct annotate_browser *browser
browser->addr_width += browser->jumps_width + 1; browser->addr_width += browser->jumps_width + 1;
} }
static int annotate_browser__run(struct annotate_browser *self, int evidx, static int annotate_browser__run(struct annotate_browser *browser, int evidx,
void(*timer)(void *arg), void(*timer)(void *arg),
void *arg, int delay_secs) void *arg, int delay_secs)
{ {
struct rb_node *nd = NULL; struct rb_node *nd = NULL;
struct map_symbol *ms = self->b.priv; struct map_symbol *ms = browser->b.priv;
struct symbol *sym = ms->sym; struct symbol *sym = ms->sym;
const char *help = "Press 'h' for help on key bindings"; const char *help = "Press 'h' for help on key bindings";
int key; int key;
if (ui_browser__show(&self->b, sym->name, help) < 0) if (ui_browser__show(&browser->b, sym->name, help) < 0)
return -1; return -1;
annotate_browser__calc_percent(self, evidx); annotate_browser__calc_percent(browser, evidx);
if (self->curr_hot) { if (browser->curr_hot) {
annotate_browser__set_rb_top(self, self->curr_hot); annotate_browser__set_rb_top(browser, browser->curr_hot);
self->b.navkeypressed = false; browser->b.navkeypressed = false;
} }
nd = self->curr_hot; nd = browser->curr_hot;
while (1) { while (1) {
key = ui_browser__run(&self->b, delay_secs); key = ui_browser__run(&browser->b, delay_secs);
if (delay_secs != 0) { if (delay_secs != 0) {
annotate_browser__calc_percent(self, evidx); annotate_browser__calc_percent(browser, evidx);
/* /*
* Current line focus got out of the list of most active * Current line focus got out of the list of most active
* lines, NULL it so that if TAB|UNTAB is pressed, we * 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,21 +648,21 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
if (nd != NULL) { if (nd != NULL) {
nd = rb_prev(nd); nd = rb_prev(nd);
if (nd == NULL) if (nd == NULL)
nd = rb_last(&self->entries); nd = rb_last(&browser->entries);
} else } else
nd = self->curr_hot; nd = browser->curr_hot;
break; break;
case K_UNTAB: case K_UNTAB:
if (nd != NULL) if (nd != NULL)
nd = rb_next(nd); nd = rb_next(nd);
if (nd == NULL) if (nd == NULL)
nd = rb_first(&self->entries); nd = rb_first(&browser->entries);
else else
nd = self->curr_hot; nd = browser->curr_hot;
break; break;
case K_F1: case K_F1:
case 'h': case 'h':
ui_browser__help_window(&self->b, ui_browser__help_window(&browser->b,
"UP/DOWN/PGUP\n" "UP/DOWN/PGUP\n"
"PGDN/SPACE Navigate\n" "PGDN/SPACE Navigate\n"
"q/ESC/CTRL+C Exit\n\n" "q/ESC/CTRL+C Exit\n\n"
...@@ -678,62 +678,62 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx, ...@@ -678,62 +678,62 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
"? Search previous string\n"); "? Search previous string\n");
continue; continue;
case 'H': case 'H':
nd = self->curr_hot; nd = browser->curr_hot;
break; break;
case 's': case 's':
if (annotate_browser__toggle_source(self)) if (annotate_browser__toggle_source(browser))
ui_helpline__puts(help); ui_helpline__puts(help);
continue; continue;
case 'o': case 'o':
annotate_browser__opts.use_offset = !annotate_browser__opts.use_offset; annotate_browser__opts.use_offset = !annotate_browser__opts.use_offset;
annotate_browser__update_addr_width(self); annotate_browser__update_addr_width(browser);
continue; continue;
case 'j': case 'j':
annotate_browser__opts.jump_arrows = !annotate_browser__opts.jump_arrows; annotate_browser__opts.jump_arrows = !annotate_browser__opts.jump_arrows;
continue; continue;
case 'J': case 'J':
annotate_browser__opts.show_nr_jumps = !annotate_browser__opts.show_nr_jumps; annotate_browser__opts.show_nr_jumps = !annotate_browser__opts.show_nr_jumps;
annotate_browser__update_addr_width(self); annotate_browser__update_addr_width(browser);
continue; continue;
case '/': case '/':
if (annotate_browser__search(self, delay_secs)) { if (annotate_browser__search(browser, delay_secs)) {
show_help: show_help:
ui_helpline__puts(help); ui_helpline__puts(help);
} }
continue; continue;
case 'n': case 'n':
if (self->searching_backwards ? if (browser->searching_backwards ?
annotate_browser__continue_search_reverse(self, delay_secs) : annotate_browser__continue_search_reverse(browser, delay_secs) :
annotate_browser__continue_search(self, delay_secs)) annotate_browser__continue_search(browser, delay_secs))
goto show_help; goto show_help;
continue; continue;
case '?': case '?':
if (annotate_browser__search_reverse(self, delay_secs)) if (annotate_browser__search_reverse(browser, delay_secs))
goto show_help; goto show_help;
continue; continue;
case 'D': { case 'D': {
static int seq; static int seq;
ui_helpline__pop(); ui_helpline__pop();
ui_helpline__fpush("%d: nr_ent=%d, height=%d, idx=%d, top_idx=%d, nr_asm_entries=%d", ui_helpline__fpush("%d: nr_ent=%d, height=%d, idx=%d, top_idx=%d, nr_asm_entries=%d",
seq++, self->b.nr_entries, seq++, browser->b.nr_entries,
self->b.height, browser->b.height,
self->b.index, browser->b.index,
self->b.top_idx, browser->b.top_idx,
self->nr_asm_entries); browser->nr_asm_entries);
} }
continue; continue;
case K_ENTER: case K_ENTER:
case K_RIGHT: case K_RIGHT:
if (self->selection == NULL) if (browser->selection == NULL)
ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org"); ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org");
else if (self->selection->offset == -1) else if (browser->selection->offset == -1)
ui_helpline__puts("Actions are only available for assembly lines."); ui_helpline__puts("Actions are only available for assembly lines.");
else if (!self->selection->ins) { else if (!browser->selection->ins) {
if (strcmp(self->selection->name, "retq")) if (strcmp(browser->selection->name, "retq"))
goto show_sup_ins; goto show_sup_ins;
goto out; goto out;
} else if (!(annotate_browser__jump(self) || } else if (!(annotate_browser__jump(browser) ||
annotate_browser__callq(self, evidx, timer, arg, delay_secs))) { annotate_browser__callq(browser, evidx, timer, arg, delay_secs))) {
show_sup_ins: show_sup_ins:
ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions."); ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions.");
} }
...@@ -748,10 +748,10 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx, ...@@ -748,10 +748,10 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
} }
if (nd != NULL) if (nd != NULL)
annotate_browser__set_rb_top(self, nd); annotate_browser__set_rb_top(browser, nd);
} }
out: out:
ui_browser__hide(&self->b); ui_browser__hide(&browser->b);
return key; return key;
} }
......
...@@ -26,21 +26,21 @@ struct hist_browser { ...@@ -26,21 +26,21 @@ struct hist_browser {
bool has_symbols; bool has_symbols;
}; };
static int hists__browser_title(struct hists *self, char *bf, size_t size, static int hists__browser_title(struct hists *hists, char *bf, size_t size,
const char *ev_name); const char *ev_name);
static void hist_browser__refresh_dimensions(struct hist_browser *self) static void hist_browser__refresh_dimensions(struct hist_browser *browser)
{ {
/* 3 == +/- toggle symbol before actual hist_entry rendering */ /* 3 == +/- toggle symbol before actual hist_entry rendering */
self->b.width = 3 + (hists__sort_list_width(self->hists) + browser->b.width = 3 + (hists__sort_list_width(browser->hists) +
sizeof("[k]")); sizeof("[k]"));
} }
static void hist_browser__reset(struct hist_browser *self) static void hist_browser__reset(struct hist_browser *browser)
{ {
self->b.nr_entries = self->hists->nr_entries; browser->b.nr_entries = browser->hists->nr_entries;
hist_browser__refresh_dimensions(self); hist_browser__refresh_dimensions(browser);
ui_browser__reset_index(&self->b); ui_browser__reset_index(&browser->b);
} }
static char tree__folded_sign(bool unfolded) static char tree__folded_sign(bool unfolded)
...@@ -48,32 +48,32 @@ static char tree__folded_sign(bool unfolded) ...@@ -48,32 +48,32 @@ static char tree__folded_sign(bool unfolded)
return unfolded ? '-' : '+'; return unfolded ? '-' : '+';
} }
static char map_symbol__folded(const struct map_symbol *self) static char map_symbol__folded(const struct map_symbol *ms)
{ {
return self->has_children ? tree__folded_sign(self->unfolded) : ' '; return ms->has_children ? tree__folded_sign(ms->unfolded) : ' ';
} }
static char hist_entry__folded(const struct hist_entry *self) static char hist_entry__folded(const struct hist_entry *he)
{ {
return map_symbol__folded(&self->ms); return map_symbol__folded(&he->ms);
} }
static char callchain_list__folded(const struct callchain_list *self) static char callchain_list__folded(const struct callchain_list *cl)
{ {
return map_symbol__folded(&self->ms); return map_symbol__folded(&cl->ms);
} }
static void map_symbol__set_folding(struct map_symbol *self, bool unfold) static void map_symbol__set_folding(struct map_symbol *ms, bool unfold)
{ {
self->unfolded = unfold ? self->has_children : false; ms->unfolded = unfold ? ms->has_children : false;
} }
static int callchain_node__count_rows_rb_tree(struct callchain_node *self) static int callchain_node__count_rows_rb_tree(struct callchain_node *node)
{ {
int n = 0; int n = 0;
struct rb_node *nd; struct rb_node *nd;
for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) { for (nd = rb_first(&node->rb_root); nd; nd = rb_next(nd)) {
struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node);
struct callchain_list *chain; struct callchain_list *chain;
char folded_sign = ' '; /* No children */ char folded_sign = ' '; /* No children */
...@@ -123,23 +123,23 @@ static int callchain__count_rows(struct rb_root *chain) ...@@ -123,23 +123,23 @@ static int callchain__count_rows(struct rb_root *chain)
return n; return n;
} }
static bool map_symbol__toggle_fold(struct map_symbol *self) static bool map_symbol__toggle_fold(struct map_symbol *ms)
{ {
if (!self) if (!ms)
return false; return false;
if (!self->has_children) if (!ms->has_children)
return false; return false;
self->unfolded = !self->unfolded; ms->unfolded = !ms->unfolded;
return true; return true;
} }
static void callchain_node__init_have_children_rb_tree(struct callchain_node *self) static void callchain_node__init_have_children_rb_tree(struct callchain_node *node)
{ {
struct rb_node *nd = rb_first(&self->rb_root); struct rb_node *nd = rb_first(&node->rb_root);
for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) { for (nd = rb_first(&node->rb_root); nd; nd = rb_next(nd)) {
struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node);
struct callchain_list *chain; struct callchain_list *chain;
bool first = true; bool first = true;
...@@ -158,49 +158,49 @@ static void callchain_node__init_have_children_rb_tree(struct callchain_node *se ...@@ -158,49 +158,49 @@ static void callchain_node__init_have_children_rb_tree(struct callchain_node *se
} }
} }
static void callchain_node__init_have_children(struct callchain_node *self) static void callchain_node__init_have_children(struct callchain_node *node)
{ {
struct callchain_list *chain; struct callchain_list *chain;
list_for_each_entry(chain, &self->val, list) list_for_each_entry(chain, &node->val, list)
chain->ms.has_children = !RB_EMPTY_ROOT(&self->rb_root); chain->ms.has_children = !RB_EMPTY_ROOT(&node->rb_root);
callchain_node__init_have_children_rb_tree(self); callchain_node__init_have_children_rb_tree(node);
} }
static void callchain__init_have_children(struct rb_root *self) static void callchain__init_have_children(struct rb_root *root)
{ {
struct rb_node *nd; struct rb_node *nd;
for (nd = rb_first(self); nd; nd = rb_next(nd)) { for (nd = rb_first(root); nd; nd = rb_next(nd)) {
struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node); struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node);
callchain_node__init_have_children(node); callchain_node__init_have_children(node);
} }
} }
static void hist_entry__init_have_children(struct hist_entry *self) static void hist_entry__init_have_children(struct hist_entry *he)
{ {
if (!self->init_have_children) { if (!he->init_have_children) {
self->ms.has_children = !RB_EMPTY_ROOT(&self->sorted_chain); he->ms.has_children = !RB_EMPTY_ROOT(&he->sorted_chain);
callchain__init_have_children(&self->sorted_chain); callchain__init_have_children(&he->sorted_chain);
self->init_have_children = true; he->init_have_children = true;
} }
} }
static bool hist_browser__toggle_fold(struct hist_browser *self) static bool hist_browser__toggle_fold(struct hist_browser *browser)
{ {
if (map_symbol__toggle_fold(self->selection)) { if (map_symbol__toggle_fold(browser->selection)) {
struct hist_entry *he = self->he_selection; struct hist_entry *he = browser->he_selection;
hist_entry__init_have_children(he); hist_entry__init_have_children(he);
self->hists->nr_entries -= he->nr_rows; browser->hists->nr_entries -= he->nr_rows;
if (he->ms.unfolded) if (he->ms.unfolded)
he->nr_rows = callchain__count_rows(&he->sorted_chain); he->nr_rows = callchain__count_rows(&he->sorted_chain);
else else
he->nr_rows = 0; he->nr_rows = 0;
self->hists->nr_entries += he->nr_rows; browser->hists->nr_entries += he->nr_rows;
self->b.nr_entries = self->hists->nr_entries; browser->b.nr_entries = browser->hists->nr_entries;
return true; return true;
} }
...@@ -209,12 +209,12 @@ static bool hist_browser__toggle_fold(struct hist_browser *self) ...@@ -209,12 +209,12 @@ static bool hist_browser__toggle_fold(struct hist_browser *self)
return false; return false;
} }
static int callchain_node__set_folding_rb_tree(struct callchain_node *self, bool unfold) static int callchain_node__set_folding_rb_tree(struct callchain_node *node, bool unfold)
{ {
int n = 0; int n = 0;
struct rb_node *nd; struct rb_node *nd;
for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) { for (nd = rb_first(&node->rb_root); nd; nd = rb_next(nd)) {
struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node);
struct callchain_list *chain; struct callchain_list *chain;
bool has_children = false; bool has_children = false;
...@@ -263,37 +263,37 @@ static int callchain__set_folding(struct rb_root *chain, bool unfold) ...@@ -263,37 +263,37 @@ static int callchain__set_folding(struct rb_root *chain, bool unfold)
return n; return n;
} }
static void hist_entry__set_folding(struct hist_entry *self, bool unfold) static void hist_entry__set_folding(struct hist_entry *he, bool unfold)
{ {
hist_entry__init_have_children(self); hist_entry__init_have_children(he);
map_symbol__set_folding(&self->ms, unfold); map_symbol__set_folding(&he->ms, unfold);
if (self->ms.has_children) { if (he->ms.has_children) {
int n = callchain__set_folding(&self->sorted_chain, unfold); int n = callchain__set_folding(&he->sorted_chain, unfold);
self->nr_rows = unfold ? n : 0; he->nr_rows = unfold ? n : 0;
} else } else
self->nr_rows = 0; he->nr_rows = 0;
} }
static void hists__set_folding(struct hists *self, bool unfold) static void hists__set_folding(struct hists *hists, bool unfold)
{ {
struct rb_node *nd; struct rb_node *nd;
self->nr_entries = 0; hists->nr_entries = 0;
for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node); struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
hist_entry__set_folding(he, unfold); hist_entry__set_folding(he, unfold);
self->nr_entries += 1 + he->nr_rows; hists->nr_entries += 1 + he->nr_rows;
} }
} }
static void hist_browser__set_folding(struct hist_browser *self, bool unfold) static void hist_browser__set_folding(struct hist_browser *browser, bool unfold)
{ {
hists__set_folding(self->hists, unfold); hists__set_folding(browser->hists, unfold);
self->b.nr_entries = self->hists->nr_entries; browser->b.nr_entries = browser->hists->nr_entries;
/* Go to the start, we may be way after valid entries after a collapse */ /* Go to the start, we may be way after valid entries after a collapse */
ui_browser__reset_index(&self->b); ui_browser__reset_index(&browser->b);
} }
static void ui_browser__warn_lost_events(struct ui_browser *browser) static 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,64 +305,64 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser)
"Or reduce the sampling frequency."); "Or reduce the sampling frequency.");
} }
static int hist_browser__run(struct hist_browser *self, const char *ev_name, static int hist_browser__run(struct hist_browser *browser, const char *ev_name,
void(*timer)(void *arg), void *arg, int delay_secs) void(*timer)(void *arg), void *arg, int delay_secs)
{ {
int key; int key;
char title[160]; char title[160];
self->b.entries = &self->hists->entries; browser->b.entries = &browser->hists->entries;
self->b.nr_entries = self->hists->nr_entries; browser->b.nr_entries = browser->hists->nr_entries;
hist_browser__refresh_dimensions(self); hist_browser__refresh_dimensions(browser);
hists__browser_title(self->hists, title, sizeof(title), ev_name); hists__browser_title(browser->hists, title, sizeof(title), ev_name);
if (ui_browser__show(&self->b, title, if (ui_browser__show(&browser->b, title,
"Press '?' for help on key bindings") < 0) "Press '?' for help on key bindings") < 0)
return -1; return -1;
while (1) { while (1) {
key = ui_browser__run(&self->b, delay_secs); key = ui_browser__run(&browser->b, delay_secs);
switch (key) { switch (key) {
case K_TIMER: case K_TIMER:
timer(arg); timer(arg);
ui_browser__update_nr_entries(&self->b, self->hists->nr_entries); ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries);
if (self->hists->stats.nr_lost_warned != if (browser->hists->stats.nr_lost_warned !=
self->hists->stats.nr_events[PERF_RECORD_LOST]) { browser->hists->stats.nr_events[PERF_RECORD_LOST]) {
self->hists->stats.nr_lost_warned = browser->hists->stats.nr_lost_warned =
self->hists->stats.nr_events[PERF_RECORD_LOST]; browser->hists->stats.nr_events[PERF_RECORD_LOST];
ui_browser__warn_lost_events(&self->b); ui_browser__warn_lost_events(&browser->b);
} }
hists__browser_title(self->hists, title, sizeof(title), ev_name); hists__browser_title(browser->hists, title, sizeof(title), ev_name);
ui_browser__show_title(&self->b, title); ui_browser__show_title(&browser->b, title);
continue; continue;
case 'D': { /* Debug */ case 'D': { /* Debug */
static int seq; static int seq;
struct hist_entry *h = rb_entry(self->b.top, struct hist_entry *h = rb_entry(browser->b.top,
struct hist_entry, rb_node); struct hist_entry, rb_node);
ui_helpline__pop(); ui_helpline__pop();
ui_helpline__fpush("%d: nr_ent=(%d,%d), height=%d, idx=%d, fve: idx=%d, row_off=%d, nrows=%d", ui_helpline__fpush("%d: nr_ent=(%d,%d), height=%d, idx=%d, fve: idx=%d, row_off=%d, nrows=%d",
seq++, self->b.nr_entries, seq++, browser->b.nr_entries,
self->hists->nr_entries, browser->hists->nr_entries,
self->b.height, browser->b.height,
self->b.index, browser->b.index,
self->b.top_idx, browser->b.top_idx,
h->row_offset, h->nr_rows); h->row_offset, h->nr_rows);
} }
break; break;
case 'C': case 'C':
/* Collapse the whole world. */ /* Collapse the whole world. */
hist_browser__set_folding(self, false); hist_browser__set_folding(browser, false);
break; break;
case 'E': case 'E':
/* Expand the whole world. */ /* Expand the whole world. */
hist_browser__set_folding(self, true); hist_browser__set_folding(browser, true);
break; break;
case K_ENTER: case K_ENTER:
if (hist_browser__toggle_fold(self)) if (hist_browser__toggle_fold(browser))
break; break;
/* fall thru */ /* fall thru */
default: default:
...@@ -370,23 +370,23 @@ static int hist_browser__run(struct hist_browser *self, const char *ev_name, ...@@ -370,23 +370,23 @@ static int hist_browser__run(struct hist_browser *self, const char *ev_name,
} }
} }
out: out:
ui_browser__hide(&self->b); ui_browser__hide(&browser->b);
return key; return key;
} }
static char *callchain_list__sym_name(struct callchain_list *self, static char *callchain_list__sym_name(struct callchain_list *cl,
char *bf, size_t bfsize) char *bf, size_t bfsize)
{ {
if (self->ms.sym) if (cl->ms.sym)
return self->ms.sym->name; return cl->ms.sym->name;
snprintf(bf, bfsize, "%#" PRIx64, self->ip); snprintf(bf, bfsize, "%#" PRIx64, cl->ip);
return bf; return bf;
} }
#define LEVEL_OFFSET_STEP 3 #define LEVEL_OFFSET_STEP 3
static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self, static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *browser,
struct callchain_node *chain_node, struct callchain_node *chain_node,
u64 total, int level, u64 total, int level,
unsigned short row, unsigned short row,
...@@ -444,21 +444,21 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self, ...@@ -444,21 +444,21 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self,
} }
color = HE_COLORSET_NORMAL; color = HE_COLORSET_NORMAL;
width = self->b.width - (offset + extra_offset + 2); width = browser->b.width - (offset + extra_offset + 2);
if (ui_browser__is_current_entry(&self->b, row)) { if (ui_browser__is_current_entry(&browser->b, row)) {
self->selection = &chain->ms; browser->selection = &chain->ms;
color = HE_COLORSET_SELECTED; color = HE_COLORSET_SELECTED;
*is_current_entry = true; *is_current_entry = true;
} }
ui_browser__set_color(&self->b, color); ui_browser__set_color(&browser->b, color);
ui_browser__gotorc(&self->b, row, 0); ui_browser__gotorc(&browser->b, row, 0);
slsmg_write_nstring(" ", offset + extra_offset); slsmg_write_nstring(" ", offset + extra_offset);
slsmg_printf("%c ", folded_sign); slsmg_printf("%c ", folded_sign);
slsmg_write_nstring(str, width); slsmg_write_nstring(str, width);
free(alloc_str); free(alloc_str);
if (++row == self->b.height) if (++row == browser->b.height)
goto out; goto out;
do_next: do_next:
if (folded_sign == '+') if (folded_sign == '+')
...@@ -467,11 +467,11 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self, ...@@ -467,11 +467,11 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self,
if (folded_sign == '-') { if (folded_sign == '-') {
const int new_level = level + (extra_offset ? 2 : 1); const int new_level = level + (extra_offset ? 2 : 1);
row += hist_browser__show_callchain_node_rb_tree(self, child, new_total, row += hist_browser__show_callchain_node_rb_tree(browser, child, new_total,
new_level, row, row_offset, new_level, row, row_offset,
is_current_entry); is_current_entry);
} }
if (row == self->b.height) if (row == browser->b.height)
goto out; goto out;
node = next; node = next;
} }
...@@ -479,7 +479,7 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self, ...@@ -479,7 +479,7 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self,
return row - first_row; return row - first_row;
} }
static int hist_browser__show_callchain_node(struct hist_browser *self, static int hist_browser__show_callchain_node(struct hist_browser *browser,
struct callchain_node *node, struct callchain_node *node,
int level, unsigned short row, int level, unsigned short row,
off_t *row_offset, off_t *row_offset,
...@@ -488,7 +488,7 @@ static int hist_browser__show_callchain_node(struct hist_browser *self, ...@@ -488,7 +488,7 @@ static int hist_browser__show_callchain_node(struct hist_browser *self,
struct callchain_list *chain; struct callchain_list *chain;
int first_row = row, int first_row = row,
offset = level * LEVEL_OFFSET_STEP, offset = level * LEVEL_OFFSET_STEP,
width = self->b.width - offset; width = browser->b.width - offset;
char folded_sign = ' '; char folded_sign = ' ';
list_for_each_entry(chain, &node->val, list) { list_for_each_entry(chain, &node->val, list) {
...@@ -503,26 +503,26 @@ static int hist_browser__show_callchain_node(struct hist_browser *self, ...@@ -503,26 +503,26 @@ static int hist_browser__show_callchain_node(struct hist_browser *self,
} }
color = HE_COLORSET_NORMAL; color = HE_COLORSET_NORMAL;
if (ui_browser__is_current_entry(&self->b, row)) { if (ui_browser__is_current_entry(&browser->b, row)) {
self->selection = &chain->ms; browser->selection = &chain->ms;
color = HE_COLORSET_SELECTED; color = HE_COLORSET_SELECTED;
*is_current_entry = true; *is_current_entry = true;
} }
s = callchain_list__sym_name(chain, ipstr, sizeof(ipstr)); s = callchain_list__sym_name(chain, ipstr, sizeof(ipstr));
ui_browser__gotorc(&self->b, row, 0); ui_browser__gotorc(&browser->b, row, 0);
ui_browser__set_color(&self->b, color); ui_browser__set_color(&browser->b, color);
slsmg_write_nstring(" ", offset); slsmg_write_nstring(" ", offset);
slsmg_printf("%c ", folded_sign); slsmg_printf("%c ", folded_sign);
slsmg_write_nstring(s, width - 2); slsmg_write_nstring(s, width - 2);
if (++row == self->b.height) if (++row == browser->b.height)
goto out; goto out;
} }
if (folded_sign == '-') if (folded_sign == '-')
row += hist_browser__show_callchain_node_rb_tree(self, node, row += hist_browser__show_callchain_node_rb_tree(browser, node,
self->hists->stats.total_period, browser->hists->stats.total_period,
level + 1, row, level + 1, row,
row_offset, row_offset,
is_current_entry); is_current_entry);
...@@ -530,7 +530,7 @@ static int hist_browser__show_callchain_node(struct hist_browser *self, ...@@ -530,7 +530,7 @@ static int hist_browser__show_callchain_node(struct hist_browser *self,
return row - first_row; return row - first_row;
} }
static int hist_browser__show_callchain(struct hist_browser *self, static int hist_browser__show_callchain(struct hist_browser *browser,
struct rb_root *chain, struct rb_root *chain,
int level, unsigned short row, int level, unsigned short row,
off_t *row_offset, off_t *row_offset,
...@@ -542,31 +542,31 @@ static int hist_browser__show_callchain(struct hist_browser *self, ...@@ -542,31 +542,31 @@ static int hist_browser__show_callchain(struct hist_browser *self,
for (nd = rb_first(chain); nd; nd = rb_next(nd)) { for (nd = rb_first(chain); nd; nd = rb_next(nd)) {
struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node); struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node);
row += hist_browser__show_callchain_node(self, node, level, row += hist_browser__show_callchain_node(browser, node, level,
row, row_offset, row, row_offset,
is_current_entry); is_current_entry);
if (row == self->b.height) if (row == browser->b.height)
break; break;
} }
return row - first_row; return row - first_row;
} }
static int hist_browser__show_entry(struct hist_browser *self, static int hist_browser__show_entry(struct hist_browser *browser,
struct hist_entry *entry, struct hist_entry *entry,
unsigned short row) unsigned short row)
{ {
char s[256]; char s[256];
double percent; double percent;
int printed = 0; int printed = 0;
int width = self->b.width - 6; /* The percentage */ int width = browser->b.width - 6; /* The percentage */
char folded_sign = ' '; char folded_sign = ' ';
bool current_entry = ui_browser__is_current_entry(&self->b, row); bool current_entry = ui_browser__is_current_entry(&browser->b, row);
off_t row_offset = entry->row_offset; off_t row_offset = entry->row_offset;
if (current_entry) { if (current_entry) {
self->he_selection = entry; browser->he_selection = entry;
self->selection = &entry->ms; browser->selection = &entry->ms;
} }
if (symbol_conf.use_callchain) { if (symbol_conf.use_callchain) {
...@@ -575,11 +575,11 @@ static int hist_browser__show_entry(struct hist_browser *self, ...@@ -575,11 +575,11 @@ static int hist_browser__show_entry(struct hist_browser *self,
} }
if (row_offset == 0) { if (row_offset == 0) {
hist_entry__snprintf(entry, s, sizeof(s), self->hists); hist_entry__snprintf(entry, s, sizeof(s), browser->hists);
percent = (entry->period * 100.0) / self->hists->stats.total_period; percent = (entry->period * 100.0) / browser->hists->stats.total_period;
ui_browser__set_percent_color(&self->b, percent, current_entry); ui_browser__set_percent_color(&browser->b, percent, current_entry);
ui_browser__gotorc(&self->b, row, 0); ui_browser__gotorc(&browser->b, row, 0);
if (symbol_conf.use_callchain) { if (symbol_conf.use_callchain) {
slsmg_printf("%c ", folded_sign); slsmg_printf("%c ", folded_sign);
width -= 2; width -= 2;
...@@ -588,11 +588,11 @@ static int hist_browser__show_entry(struct hist_browser *self, ...@@ -588,11 +588,11 @@ static int hist_browser__show_entry(struct hist_browser *self,
slsmg_printf(" %5.2f%%", percent); slsmg_printf(" %5.2f%%", percent);
/* The scroll bar isn't being used */ /* The scroll bar isn't being used */
if (!self->b.navkeypressed) if (!browser->b.navkeypressed)
width += 1; width += 1;
if (!current_entry || !self->b.navkeypressed) if (!current_entry || !browser->b.navkeypressed)
ui_browser__set_color(&self->b, HE_COLORSET_NORMAL); ui_browser__set_color(&browser->b, HE_COLORSET_NORMAL);
if (symbol_conf.show_nr_samples) { if (symbol_conf.show_nr_samples) {
slsmg_printf(" %11u", entry->nr_events); slsmg_printf(" %11u", entry->nr_events);
...@@ -610,12 +610,12 @@ static int hist_browser__show_entry(struct hist_browser *self, ...@@ -610,12 +610,12 @@ static int hist_browser__show_entry(struct hist_browser *self,
} else } else
--row_offset; --row_offset;
if (folded_sign == '-' && row != self->b.height) { if (folded_sign == '-' && row != browser->b.height) {
printed += hist_browser__show_callchain(self, &entry->sorted_chain, printed += hist_browser__show_callchain(browser, &entry->sorted_chain,
1, row, &row_offset, 1, row, &row_offset,
&current_entry); &current_entry);
if (current_entry) if (current_entry)
self->he_selection = entry; browser->he_selection = entry;
} }
return printed; return printed;
...@@ -631,22 +631,22 @@ static void ui_browser__hists_init_top(struct ui_browser *browser) ...@@ -631,22 +631,22 @@ static void ui_browser__hists_init_top(struct ui_browser *browser)
} }
} }
static unsigned int hist_browser__refresh(struct ui_browser *self) static unsigned int hist_browser__refresh(struct ui_browser *browser)
{ {
unsigned row = 0; unsigned row = 0;
struct rb_node *nd; struct rb_node *nd;
struct hist_browser *hb = container_of(self, struct hist_browser, b); struct hist_browser *hb = container_of(browser, struct hist_browser, b);
ui_browser__hists_init_top(self); ui_browser__hists_init_top(browser);
for (nd = self->top; nd; nd = rb_next(nd)) { for (nd = browser->top; nd; nd = rb_next(nd)) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
if (h->filtered) if (h->filtered)
continue; continue;
row += hist_browser__show_entry(hb, h, row); row += hist_browser__show_entry(hb, h, row);
if (row == self->height) if (row == browser->height)
break; break;
} }
...@@ -679,27 +679,27 @@ static struct rb_node *hists__filter_prev_entries(struct rb_node *nd) ...@@ -679,27 +679,27 @@ static struct rb_node *hists__filter_prev_entries(struct rb_node *nd)
return NULL; return NULL;
} }
static void ui_browser__hists_seek(struct ui_browser *self, static void ui_browser__hists_seek(struct ui_browser *browser,
off_t offset, int whence) off_t offset, int whence)
{ {
struct hist_entry *h; struct hist_entry *h;
struct rb_node *nd; struct rb_node *nd;
bool first = true; bool first = true;
if (self->nr_entries == 0) if (browser->nr_entries == 0)
return; return;
ui_browser__hists_init_top(self); ui_browser__hists_init_top(browser);
switch (whence) { switch (whence) {
case SEEK_SET: case SEEK_SET:
nd = hists__filter_entries(rb_first(self->entries)); nd = hists__filter_entries(rb_first(browser->entries));
break; break;
case SEEK_CUR: case SEEK_CUR:
nd = self->top; nd = browser->top;
goto do_offset; goto do_offset;
case SEEK_END: case SEEK_END:
nd = hists__filter_prev_entries(rb_last(self->entries)); nd = hists__filter_prev_entries(rb_last(browser->entries));
first = false; first = false;
break; break;
default: default:
...@@ -710,7 +710,7 @@ static void ui_browser__hists_seek(struct ui_browser *self, ...@@ -710,7 +710,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
* Moves not relative to the first visible entry invalidates its * Moves not relative to the first visible entry invalidates its
* row_offset: * row_offset:
*/ */
h = rb_entry(self->top, struct hist_entry, rb_node); h = rb_entry(browser->top, struct hist_entry, rb_node);
h->row_offset = 0; h->row_offset = 0;
/* /*
...@@ -738,7 +738,7 @@ static void ui_browser__hists_seek(struct ui_browser *self, ...@@ -738,7 +738,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
} else { } else {
h->row_offset += offset; h->row_offset += offset;
offset = 0; offset = 0;
self->top = nd; browser->top = nd;
break; break;
} }
} }
...@@ -746,7 +746,7 @@ static void ui_browser__hists_seek(struct ui_browser *self, ...@@ -746,7 +746,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
if (nd == NULL) if (nd == NULL)
break; break;
--offset; --offset;
self->top = nd; browser->top = nd;
} while (offset != 0); } while (offset != 0);
} else if (offset < 0) { } else if (offset < 0) {
while (1) { while (1) {
...@@ -759,7 +759,7 @@ static void ui_browser__hists_seek(struct ui_browser *self, ...@@ -759,7 +759,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
} else { } else {
h->row_offset += offset; h->row_offset += offset;
offset = 0; offset = 0;
self->top = nd; browser->top = nd;
break; break;
} }
} else { } else {
...@@ -769,7 +769,7 @@ static void ui_browser__hists_seek(struct ui_browser *self, ...@@ -769,7 +769,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
} else { } else {
h->row_offset = h->nr_rows + offset; h->row_offset = h->nr_rows + offset;
offset = 0; offset = 0;
self->top = nd; browser->top = nd;
break; break;
} }
} }
...@@ -779,7 +779,7 @@ static void ui_browser__hists_seek(struct ui_browser *self, ...@@ -779,7 +779,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
if (nd == NULL) if (nd == NULL)
break; break;
++offset; ++offset;
self->top = nd; browser->top = nd;
if (offset == 0) { if (offset == 0) {
/* /*
* Last unfiltered hist_entry, check if it is * Last unfiltered hist_entry, check if it is
...@@ -794,7 +794,7 @@ static void ui_browser__hists_seek(struct ui_browser *self, ...@@ -794,7 +794,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
first = false; first = false;
} }
} else { } else {
self->top = nd; browser->top = nd;
h = rb_entry(nd, struct hist_entry, rb_node); h = rb_entry(nd, struct hist_entry, rb_node);
h->row_offset = 0; h->row_offset = 0;
} }
...@@ -802,46 +802,46 @@ static void ui_browser__hists_seek(struct ui_browser *self, ...@@ -802,46 +802,46 @@ static void ui_browser__hists_seek(struct ui_browser *self,
static struct hist_browser *hist_browser__new(struct hists *hists) static struct hist_browser *hist_browser__new(struct hists *hists)
{ {
struct hist_browser *self = zalloc(sizeof(*self)); struct hist_browser *browser = zalloc(sizeof(*browser));
if (self) { if (browser) {
self->hists = hists; browser->hists = hists;
self->b.refresh = hist_browser__refresh; browser->b.refresh = hist_browser__refresh;
self->b.seek = ui_browser__hists_seek; browser->b.seek = ui_browser__hists_seek;
self->b.use_navkeypressed = true; browser->b.use_navkeypressed = true;
if (sort__branch_mode == 1) if (sort__branch_mode == 1)
self->has_symbols = sort_sym_from.list.next != NULL; browser->has_symbols = sort_sym_from.list.next != NULL;
else else
self->has_symbols = sort_sym.list.next != NULL; browser->has_symbols = sort_sym.list.next != NULL;
} }
return self; return browser;
} }
static void hist_browser__delete(struct hist_browser *self) static void hist_browser__delete(struct hist_browser *browser)
{ {
free(self); free(browser);
} }
static struct hist_entry *hist_browser__selected_entry(struct hist_browser *self) static struct hist_entry *hist_browser__selected_entry(struct hist_browser *browser)
{ {
return self->he_selection; return browser->he_selection;
} }
static struct thread *hist_browser__selected_thread(struct hist_browser *self) static struct thread *hist_browser__selected_thread(struct hist_browser *browser)
{ {
return self->he_selection->thread; return browser->he_selection->thread;
} }
static int hists__browser_title(struct hists *self, char *bf, size_t size, static int hists__browser_title(struct hists *hists, char *bf, size_t size,
const char *ev_name) const char *ev_name)
{ {
char unit; char unit;
int printed; int printed;
const struct dso *dso = self->dso_filter; const struct dso *dso = hists->dso_filter;
const struct thread *thread = self->thread_filter; const struct thread *thread = hists->thread_filter;
unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE]; unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
u64 nr_events = self->stats.total_period; u64 nr_events = hists->stats.total_period;
nr_samples = convert_unit(nr_samples, &unit); nr_samples = convert_unit(nr_samples, &unit);
printed = scnprintf(bf, size, printed = scnprintf(bf, size,
...@@ -849,9 +849,9 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size, ...@@ -849,9 +849,9 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size,
nr_samples, unit, ev_name, nr_events); nr_samples, unit, ev_name, nr_events);
if (self->uid_filter_str) if (hists->uid_filter_str)
printed += snprintf(bf + printed, size - printed, printed += snprintf(bf + printed, size - printed,
", UID: %s", self->uid_filter_str); ", UID: %s", hists->uid_filter_str);
if (thread) if (thread)
printed += scnprintf(bf + printed, size - printed, printed += scnprintf(bf + printed, size - printed,
", Thread: %s(%d)", ", Thread: %s(%d)",
...@@ -879,8 +879,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, ...@@ -879,8 +879,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
void(*timer)(void *arg), void *arg, void(*timer)(void *arg), void *arg,
int delay_secs) int delay_secs)
{ {
struct hists *self = &evsel->hists; struct hists *hists = &evsel->hists;
struct hist_browser *browser = hist_browser__new(self); struct hist_browser *browser = hist_browser__new(hists);
struct branch_info *bi; struct branch_info *bi;
struct pstack *fstack; struct pstack *fstack;
char *options[16]; char *options[16];
...@@ -946,8 +946,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, ...@@ -946,8 +946,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
"Please enter the name of symbol you want to see", "Please enter the name of symbol you want to see",
buf, "ENTER: OK, ESC: Cancel", buf, "ENTER: OK, ESC: Cancel",
delay_secs * 2) == K_ENTER) { delay_secs * 2) == K_ENTER) {
self->symbol_filter_str = *buf ? buf : NULL; hists->symbol_filter_str = *buf ? buf : NULL;
hists__filter_by_symbol(self); hists__filter_by_symbol(hists);
hist_browser__reset(browser); hist_browser__reset(browser);
} }
continue; continue;
...@@ -1128,7 +1128,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, ...@@ -1128,7 +1128,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
sort_dso.elide = true; sort_dso.elide = true;
pstack__push(fstack, &browser->hists->dso_filter); pstack__push(fstack, &browser->hists->dso_filter);
} }
hists__filter_by_dso(self); hists__filter_by_dso(hists);
hist_browser__reset(browser); hist_browser__reset(browser);
} else if (choice == zoom_thread) { } else if (choice == zoom_thread) {
zoom_thread: zoom_thread:
...@@ -1146,7 +1146,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, ...@@ -1146,7 +1146,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
sort_thread.elide = true; sort_thread.elide = true;
pstack__push(fstack, &browser->hists->thread_filter); pstack__push(fstack, &browser->hists->thread_filter);
} }
hists__filter_by_thread(self); hists__filter_by_thread(hists);
hist_browser__reset(browser); hist_browser__reset(browser);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment