perf evlist: Factor out a function to propagate maps for a single evsel
[firefly-linux-kernel-4.4.55.git] / tools / perf / util / hist.c
index a6e9ddd37913088c7a427d8c97a55c59e5de3813..08b6cd945f1ece736249318835c044a735c6e29c 100644 (file)
@@ -151,6 +151,12 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
        hists__new_col_len(hists, HISTC_LOCAL_WEIGHT, 12);
        hists__new_col_len(hists, HISTC_GLOBAL_WEIGHT, 12);
 
+       if (h->srcline)
+               hists__new_col_len(hists, HISTC_SRCLINE, strlen(h->srcline));
+
+       if (h->srcfile)
+               hists__new_col_len(hists, HISTC_SRCFILE, strlen(h->srcfile));
+
        if (h->transaction)
                hists__new_col_len(hists, HISTC_TRANSACTION,
                                   hist_entry__transaction_len());
@@ -761,6 +767,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
        struct hist_entry **he_cache = iter->priv;
        struct hist_entry *he;
        struct hist_entry he_tmp = {
+               .hists = evsel__hists(evsel),
                .cpu = al->cpu,
                .thread = al->thread,
                .comm = thread__comm(al->thread),
@@ -945,6 +952,8 @@ void hist_entry__delete(struct hist_entry *he)
 
        zfree(&he->stat_acc);
        free_srcline(he->srcline);
+       if (he->srcfile && he->srcfile[0])
+               free(he->srcfile);
        free_callchain(he->callchain);
        free(he);
 }
@@ -1100,13 +1109,14 @@ void hists__inc_stats(struct hists *hists, struct hist_entry *h)
 
 static void __hists__insert_output_entry(struct rb_root *entries,
                                         struct hist_entry *he,
-                                        u64 min_callchain_hits)
+                                        u64 min_callchain_hits,
+                                        bool use_callchain)
 {
        struct rb_node **p = &entries->rb_node;
        struct rb_node *parent = NULL;
        struct hist_entry *iter;
 
-       if (symbol_conf.use_callchain)
+       if (use_callchain)
                callchain_param.sort(&he->sorted_chain, he->callchain,
                                      min_callchain_hits, &callchain_param);
 
@@ -1130,6 +1140,13 @@ void hists__output_resort(struct hists *hists, struct ui_progress *prog)
        struct rb_node *next;
        struct hist_entry *n;
        u64 min_callchain_hits;
+       struct perf_evsel *evsel = hists_to_evsel(hists);
+       bool use_callchain;
+
+       if (evsel && !symbol_conf.show_ref_callgraph)
+               use_callchain = evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN;
+       else
+               use_callchain = symbol_conf.use_callchain;
 
        min_callchain_hits = hists->stats.total_period * (callchain_param.min_percent / 100);
 
@@ -1148,7 +1165,7 @@ void hists__output_resort(struct hists *hists, struct ui_progress *prog)
                n = rb_entry(next, struct hist_entry, rb_node_in);
                next = rb_next(&n->rb_node_in);
 
-               __hists__insert_output_entry(&hists->entries, n, min_callchain_hits);
+               __hists__insert_output_entry(&hists->entries, n, min_callchain_hits, use_callchain);
                hists__inc_stats(hists, n);
 
                if (!n->filtered)