perf evlist: Rename for_each() macros to for_each_entry()
[deliverable/linux.git] / tools / perf / util / hist.c
index 31c4641fe5ff06641588bef5e4448641685e49f5..e1fcc8d7c01a838934fd838df385af1d39ffa943 100644 (file)
@@ -79,7 +79,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
 
        len = thread__comm_len(h->thread);
        if (hists__new_col_len(hists, HISTC_COMM, len))
-               hists__set_col_len(hists, HISTC_THREAD, len + 6);
+               hists__set_col_len(hists, HISTC_THREAD, len + 8);
 
        if (h->ms.map) {
                len = dso__name_len(h->ms.map->dso);
@@ -117,6 +117,13 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
                        hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
                        hists__set_unres_dso_col_len(hists, HISTC_DSO_TO);
                }
+
+               if (h->branch_info->srcline_from)
+                       hists__new_col_len(hists, HISTC_SRCLINE_FROM,
+                                       strlen(h->branch_info->srcline_from));
+               if (h->branch_info->srcline_to)
+                       hists__new_col_len(hists, HISTC_SRCLINE_TO,
+                                       strlen(h->branch_info->srcline_to));
        }
 
        if (h->mem_info) {
@@ -295,7 +302,7 @@ static void hists__delete_entry(struct hists *hists, struct hist_entry *he)
                root_in  = &he->parent_he->hroot_in;
                root_out = &he->parent_he->hroot_out;
        } else {
-               if (sort__need_collapse)
+               if (hists__has(hists, need_collapse))
                        root_in = &hists->entries_collapsed;
                else
                        root_in = hists->entries_in;
@@ -524,13 +531,13 @@ out:
        return he;
 }
 
-struct hist_entry *__hists__add_entry(struct hists *hists,
-                                     struct addr_location *al,
-                                     struct symbol *sym_parent,
-                                     struct branch_info *bi,
-                                     struct mem_info *mi,
-                                     struct perf_sample *sample,
-                                     bool sample_self)
+struct hist_entry *hists__add_entry(struct hists *hists,
+                                   struct addr_location *al,
+                                   struct symbol *sym_parent,
+                                   struct branch_info *bi,
+                                   struct mem_info *mi,
+                                   struct perf_sample *sample,
+                                   bool sample_self)
 {
        struct hist_entry entry = {
                .thread = al->thread,
@@ -615,8 +622,8 @@ iter_add_single_mem_entry(struct hist_entry_iter *iter, struct addr_location *al
         */
        sample->period = cost;
 
-       he = __hists__add_entry(hists, al, iter->parent, NULL, mi,
-                               sample, true);
+       he = hists__add_entry(hists, al, iter->parent, NULL, mi,
+                             sample, true);
        if (!he)
                return -ENOMEM;
 
@@ -720,8 +727,8 @@ iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *a
        sample->period = 1;
        sample->weight = bi->flags.cycles ? bi->flags.cycles : 1;
 
-       he = __hists__add_entry(hists, al, iter->parent, &bi[i], NULL,
-                               sample, true);
+       he = hists__add_entry(hists, al, iter->parent, &bi[i], NULL,
+                             sample, true);
        if (he == NULL)
                return -ENOMEM;
 
@@ -757,8 +764,8 @@ iter_add_single_normal_entry(struct hist_entry_iter *iter, struct addr_location
        struct perf_sample *sample = iter->sample;
        struct hist_entry *he;
 
-       he = __hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL,
-                               sample, true);
+       he = hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL,
+                             sample, true);
        if (he == NULL)
                return -ENOMEM;
 
@@ -818,8 +825,8 @@ iter_add_single_cumulative_entry(struct hist_entry_iter *iter,
        struct hist_entry *he;
        int err = 0;
 
-       he = __hists__add_entry(hists, al, iter->parent, NULL, NULL,
-                               sample, true);
+       he = hists__add_entry(hists, al, iter->parent, NULL, NULL,
+                             sample, true);
        if (he == NULL)
                return -ENOMEM;
 
@@ -893,8 +900,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
                }
        }
 
-       he = __hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL,
-                               sample, false);
+       he = hists__add_entry(evsel__hists(evsel), al, iter->parent, NULL, NULL,
+                             sample, false);
        if (he == NULL)
                return -ENOMEM;
 
@@ -953,7 +960,7 @@ int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al,
 {
        int err, err2;
 
-       err = sample__resolve_callchain(iter->sample, &iter->parent,
+       err = sample__resolve_callchain(iter->sample, &callchain_cursor, &iter->parent,
                                        iter->evsel, al, max_stack_depth);
        if (err)
                return err;
@@ -1042,6 +1049,8 @@ void hist_entry__delete(struct hist_entry *he)
        if (he->branch_info) {
                map__zput(he->branch_info->from.map);
                map__zput(he->branch_info->to.map);
+               free_srcline(he->branch_info->srcline_from);
+               free_srcline(he->branch_info->srcline_to);
                zfree(&he->branch_info);
        }
 
@@ -1072,7 +1081,7 @@ int hist_entry__snprintf_alignment(struct hist_entry *he, struct perf_hpp *hpp,
                                   struct perf_hpp_fmt *fmt, int printed)
 {
        if (!list_is_last(&fmt->list, &he->hists->hpp_list->fields)) {
-               const int width = fmt->width(fmt, hpp, hists_to_evsel(he->hists));
+               const int width = fmt->width(fmt, hpp, he->hists);
                if (printed < width) {
                        advance_hpp(hpp, printed);
                        printed = scnprintf(hpp->buf, hpp->size, "%-*s", width - printed, " ");
@@ -1295,8 +1304,9 @@ static int hists__hierarchy_insert_entry(struct hists *hists,
        return ret;
 }
 
-int hists__collapse_insert_entry(struct hists *hists, struct rb_root *root,
-                                struct hist_entry *he)
+static int hists__collapse_insert_entry(struct hists *hists,
+                                       struct rb_root *root,
+                                       struct hist_entry *he)
 {
        struct rb_node **p = &root->rb_node;
        struct rb_node *parent = NULL;
@@ -1372,7 +1382,7 @@ int hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
        struct hist_entry *n;
        int ret;
 
-       if (!sort__need_collapse)
+       if (!hists__has(hists, need_collapse))
                return 0;
 
        hists->nr_entries = 0;
@@ -1631,7 +1641,7 @@ static void output_resort(struct hists *hists, struct ui_progress *prog,
                return;
        }
 
-       if (sort__need_collapse)
+       if (hists__has(hists, need_collapse))
                root = &hists->entries_collapsed;
        else
                root = hists->entries_in;
@@ -2035,7 +2045,7 @@ static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
        struct hist_entry *he;
        int64_t cmp;
 
-       if (sort__need_collapse)
+       if (hists__has(hists, need_collapse))
                root = &hists->entries_collapsed;
        else
                root = hists->entries_in;
@@ -2061,6 +2071,8 @@ static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
        if (he) {
                memset(&he->stat, 0, sizeof(he->stat));
                he->hists = hists;
+               if (symbol_conf.cumulate_callchain)
+                       memset(he->stat_acc, 0, sizeof(he->stat));
                rb_link_node(&he->rb_node_in, parent, p);
                rb_insert_color(&he->rb_node_in, root);
                hists__inc_stats(hists, he);
@@ -2075,7 +2087,7 @@ static struct hist_entry *hists__find_entry(struct hists *hists,
 {
        struct rb_node *n;
 
-       if (sort__need_collapse)
+       if (hists__has(hists, need_collapse))
                n = hists->entries_collapsed.rb_node;
        else
                n = hists->entries_in->rb_node;
@@ -2104,7 +2116,7 @@ void hists__match(struct hists *leader, struct hists *other)
        struct rb_node *nd;
        struct hist_entry *pos, *pair;
 
-       if (sort__need_collapse)
+       if (hists__has(leader, need_collapse))
                root = &leader->entries_collapsed;
        else
                root = leader->entries_in;
@@ -2129,7 +2141,7 @@ int hists__link(struct hists *leader, struct hists *other)
        struct rb_node *nd;
        struct hist_entry *pos, *pair;
 
-       if (sort__need_collapse)
+       if (hists__has(other, need_collapse))
                root = &other->entries_collapsed;
        else
                root = other->entries_in;
@@ -2187,7 +2199,7 @@ size_t perf_evlist__fprintf_nr_events(struct perf_evlist *evlist, FILE *fp)
        struct perf_evsel *pos;
        size_t ret = 0;
 
-       evlist__for_each(evlist, pos) {
+       evlist__for_each_entry(evlist, pos) {
                ret += fprintf(fp, "%s stats:\n", perf_evsel__name(pos));
                ret += events_stats__fprintf(&evsel__hists(pos)->stats, fp);
        }
This page took 0.029434 seconds and 5 git commands to generate.