.order = ORDER_CALLEE
};
-u16 hists__col_len(struct hists *self, enum hist_column col)
+u16 hists__col_len(struct hists *hists, enum hist_column col)
{
- return self->col_len[col];
+ return hists->col_len[col];
}
-void hists__set_col_len(struct hists *self, enum hist_column col, u16 len)
+void hists__set_col_len(struct hists *hists, enum hist_column col, u16 len)
{
- self->col_len[col] = len;
+ hists->col_len[col] = len;
}
-bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len)
+bool hists__new_col_len(struct hists *hists, enum hist_column col, u16 len)
{
- if (len > hists__col_len(self, col)) {
- hists__set_col_len(self, col, len);
+ if (len > hists__col_len(hists, col)) {
+ hists__set_col_len(hists, col, len);
return true;
}
return false;
}
-static void hists__reset_col_len(struct hists *self)
+static void hists__reset_col_len(struct hists *hists)
{
enum hist_column col;
for (col = 0; col < HISTC_NR_COLS; ++col)
- hists__set_col_len(self, col, 0);
+ hists__set_col_len(hists, col, 0);
}
-static void hists__calc_col_len(struct hists *self, struct hist_entry *h)
+static void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
{
u16 len;
if (h->ms.sym)
- hists__new_col_len(self, HISTC_SYMBOL, h->ms.sym->namelen);
+ hists__new_col_len(hists, HISTC_SYMBOL, h->ms.sym->namelen);
else {
const unsigned int unresolved_col_width = BITS_PER_LONG / 4;
- if (hists__col_len(self, HISTC_DSO) < unresolved_col_width &&
+ if (hists__col_len(hists, HISTC_DSO) < unresolved_col_width &&
!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
!symbol_conf.dso_list)
- hists__set_col_len(self, HISTC_DSO,
+ hists__set_col_len(hists, HISTC_DSO,
unresolved_col_width);
}
len = thread__comm_len(h->thread);
- if (hists__new_col_len(self, HISTC_COMM, len))
- hists__set_col_len(self, HISTC_THREAD, len + 6);
+ if (hists__new_col_len(hists, HISTC_COMM, len))
+ hists__set_col_len(hists, HISTC_THREAD, len + 6);
if (h->ms.map) {
len = dso__name_len(h->ms.map->dso);
- hists__new_col_len(self, HISTC_DSO, len);
+ hists__new_col_len(hists, HISTC_DSO, len);
}
}
return self;
}
-static void hists__inc_nr_entries(struct hists *self, struct hist_entry *h)
+static void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h)
{
if (!h->filtered) {
- hists__calc_col_len(self, h);
- ++self->nr_entries;
+ hists__calc_col_len(hists, h);
+ ++hists->nr_entries;
}
}
return 0;
}
-struct hist_entry *__hists__add_entry(struct hists *self,
+struct hist_entry *__hists__add_entry(struct hists *hists,
struct addr_location *al,
struct symbol *sym_parent, u64 period)
{
- struct rb_node **p = &self->entries.rb_node;
+ struct rb_node **p = &hists->entries.rb_node;
struct rb_node *parent = NULL;
struct hist_entry *he;
struct hist_entry entry = {
if (!he)
return NULL;
rb_link_node(&he->rb_node, parent, p);
- rb_insert_color(&he->rb_node, &self->entries);
- hists__inc_nr_entries(self, he);
+ rb_insert_color(&he->rb_node, &hists->entries);
+ hists__inc_nr_entries(hists, he);
out:
hist_entry__add_cpumode_period(he, al->cpumode, period);
return he;
* collapse the histogram
*/
-static bool hists__collapse_insert_entry(struct hists *self,
+static bool hists__collapse_insert_entry(struct hists *hists,
struct rb_root *root,
struct hist_entry *he)
{
if (!cmp) {
iter->period += he->period;
if (symbol_conf.use_callchain) {
- callchain_cursor_reset(&self->callchain_cursor);
- callchain_merge(&self->callchain_cursor, iter->callchain,
+ callchain_cursor_reset(&hists->callchain_cursor);
+ callchain_merge(&hists->callchain_cursor, iter->callchain,
he->callchain);
}
hist_entry__free(he);
return true;
}
-void hists__collapse_resort(struct hists *self)
+void hists__collapse_resort(struct hists *hists)
{
struct rb_root tmp;
struct rb_node *next;
return;
tmp = RB_ROOT;
- next = rb_first(&self->entries);
- self->nr_entries = 0;
- hists__reset_col_len(self);
+ next = rb_first(&hists->entries);
+ hists->nr_entries = 0;
+ hists__reset_col_len(hists);
while (next) {
n = rb_entry(next, struct hist_entry, rb_node);
next = rb_next(&n->rb_node);
- rb_erase(&n->rb_node, &self->entries);
- if (hists__collapse_insert_entry(self, &tmp, n))
- hists__inc_nr_entries(self, n);
+ rb_erase(&n->rb_node, &hists->entries);
+ if (hists__collapse_insert_entry(hists, &tmp, n))
+ hists__inc_nr_entries(hists, n);
}
- self->entries = tmp;
+ hists->entries = tmp;
}
/*
rb_insert_color(&he->rb_node, entries);
}
-void hists__output_resort(struct hists *self)
+void hists__output_resort(struct hists *hists)
{
struct rb_root tmp;
struct rb_node *next;
struct hist_entry *n;
u64 min_callchain_hits;
- min_callchain_hits = self->stats.total_period * (callchain_param.min_percent / 100);
+ min_callchain_hits = hists->stats.total_period * (callchain_param.min_percent / 100);
tmp = RB_ROOT;
- next = rb_first(&self->entries);
+ next = rb_first(&hists->entries);
- self->nr_entries = 0;
- hists__reset_col_len(self);
+ hists->nr_entries = 0;
+ hists__reset_col_len(hists);
while (next) {
n = rb_entry(next, struct hist_entry, rb_node);
next = rb_next(&n->rb_node);
- rb_erase(&n->rb_node, &self->entries);
+ rb_erase(&n->rb_node, &hists->entries);
__hists__insert_output_entry(&tmp, n, min_callchain_hits);
- hists__inc_nr_entries(self, n);
+ hists__inc_nr_entries(hists, n);
}
- self->entries = tmp;
+ hists->entries = tmp;
}
static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
left_margin);
}
-size_t hists__fprintf(struct hists *self, struct hists *pair,
+size_t hists__fprintf(struct hists *hists, struct hists *pair,
bool show_displacement, FILE *fp)
{
struct sort_entry *se;
width = strlen(se->se_header);
if (symbol_conf.col_width_list_str) {
if (col_width) {
- hists__set_col_len(self, se->se_width_idx,
+ hists__set_col_len(hists, se->se_width_idx,
atoi(col_width));
col_width = strchr(col_width, ',');
if (col_width)
++col_width;
}
}
- if (!hists__new_col_len(self, se->se_width_idx, width))
- width = hists__col_len(self, se->se_width_idx);
+ if (!hists__new_col_len(hists, se->se_width_idx, width))
+ width = hists__col_len(hists, se->se_width_idx);
fprintf(fp, " %*s", width, se->se_header);
}
fprintf(fp, "\n");
continue;
fprintf(fp, " ");
- width = hists__col_len(self, se->se_width_idx);
+ width = hists__col_len(hists, se->se_width_idx);
if (width == 0)
width = strlen(se->se_header);
for (i = 0; i < width; i++)
fprintf(fp, "\n#\n");
print_entries:
- 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 *h = rb_entry(nd, struct hist_entry, rb_node);
if (h->filtered)
displacement = 0;
++position;
}
- ret += hist_entry__fprintf(h, self, pair, show_displacement,
- displacement, fp, self->stats.total_period);
+ ret += hist_entry__fprintf(h, hists, pair, show_displacement,
+ displacement, fp, hists->stats.total_period);
if (symbol_conf.use_callchain)
- ret += hist_entry__fprintf_callchain(h, self, fp,
- self->stats.total_period);
+ ret += hist_entry__fprintf_callchain(h, hists, fp,
+ hists->stats.total_period);
if (h->ms.map == NULL && verbose > 1) {
__map_groups__fprintf_maps(&h->thread->mg,
MAP__FUNCTION, verbose, fp);
/*
* See hists__fprintf to match the column widths
*/
-unsigned int hists__sort_list_width(struct hists *self)
+unsigned int hists__sort_list_width(struct hists *hists)
{
struct sort_entry *se;
int ret = 9; /* total % */
list_for_each_entry(se, &hist_entry__sort_list, list)
if (!se->elide)
- ret += 2 + hists__col_len(self, se->se_width_idx);
+ ret += 2 + hists__col_len(hists, se->se_width_idx);
if (verbose) /* Addr + origin */
ret += 3 + BITS_PER_LONG / 4;
return ret;
}
-static void hists__remove_entry_filter(struct hists *self, struct hist_entry *h,
+static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h,
enum hist_filter filter)
{
h->filtered &= ~(1 << filter);
if (h->filtered)
return;
- ++self->nr_entries;
+ ++hists->nr_entries;
if (h->ms.unfolded)
- self->nr_entries += h->nr_rows;
+ hists->nr_entries += h->nr_rows;
h->row_offset = 0;
- self->stats.total_period += h->period;
- self->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events;
+ hists->stats.total_period += h->period;
+ hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events;
- hists__calc_col_len(self, h);
+ hists__calc_col_len(hists, h);
}
-void hists__filter_by_dso(struct hists *self, const struct dso *dso)
+void hists__filter_by_dso(struct hists *hists, const struct dso *dso)
{
struct rb_node *nd;
- self->nr_entries = self->stats.total_period = 0;
- self->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
- hists__reset_col_len(self);
+ hists->nr_entries = hists->stats.total_period = 0;
+ hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
+ hists__reset_col_len(hists);
- 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 *h = rb_entry(nd, struct hist_entry, rb_node);
if (symbol_conf.exclude_other && !h->parent)
continue;
}
- hists__remove_entry_filter(self, h, HIST_FILTER__DSO);
+ hists__remove_entry_filter(hists, h, HIST_FILTER__DSO);
}
}
-void hists__filter_by_thread(struct hists *self, const struct thread *thread)
+void hists__filter_by_thread(struct hists *hists, const struct thread *thread)
{
struct rb_node *nd;
- self->nr_entries = self->stats.total_period = 0;
- self->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
- hists__reset_col_len(self);
+ hists->nr_entries = hists->stats.total_period = 0;
+ hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
+ hists__reset_col_len(hists);
- 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 *h = rb_entry(nd, struct hist_entry, rb_node);
if (thread != NULL && h->thread != thread) {
continue;
}
- hists__remove_entry_filter(self, h, HIST_FILTER__THREAD);
+ hists__remove_entry_filter(hists, h, HIST_FILTER__THREAD);
}
}
return symbol__annotate(he->ms.sym, he->ms.map, privsize);
}
-void hists__inc_nr_events(struct hists *self, u32 type)
+void hists__inc_nr_events(struct hists *hists, u32 type)
{
- ++self->stats.nr_events[0];
- ++self->stats.nr_events[type];
+ ++hists->stats.nr_events[0];
+ ++hists->stats.nr_events[type];
}
-size_t hists__fprintf_nr_events(struct hists *self, FILE *fp)
+size_t hists__fprintf_nr_events(struct hists *hists, FILE *fp)
{
int i;
size_t ret = 0;
for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) {
const char *name;
- if (self->stats.nr_events[i] == 0)
+ if (hists->stats.nr_events[i] == 0)
continue;
name = perf_event__name(i);
continue;
ret += fprintf(fp, "%16s events: %10d\n", name,
- self->stats.nr_events[i]);
+ hists->stats.nr_events[i]);
}
return ret;