]> Git Repo - linux.git/blobdiff - tools/perf/builtin-top.c
perf annotate: Pass a 'map_symbol' in places receiving a pair of 'map' and 'symbol...
[linux.git] / tools / perf / builtin-top.c
index 726e3f2dd8c7dae819028f218495c279b2659272..dc80044bc46f48cdd7123eced665a33017bd6343 100644 (file)
 #include "util/dso.h"
 #include "util/evlist.h"
 #include "util/evsel.h"
+#include "util/evsel_config.h"
 #include "util/event.h"
 #include "util/machine.h"
 #include "util/map.h"
+#include "util/mmap.h"
 #include "util/session.h"
 #include "util/symbol.h"
+#include "util/synthetic-events.h"
 #include "util/top.h"
 #include "util/util.h"
 #include <linux/rbtree.h>
 #include <linux/stringify.h>
 #include <linux/time64.h>
 #include <linux/types.h>
+#include <linux/err.h>
 
 #include <linux/ctype.h>
+#include <perf/mmap.h>
 
 static volatile int done;
 static volatile int resize;
@@ -138,12 +143,12 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
                return err;
        }
 
-       err = symbol__annotate(sym, map, evsel, 0, &top->annotation_opts, NULL);
+       err = symbol__annotate(&he->ms, evsel, 0, &top->annotation_opts, NULL);
        if (err == 0) {
                top->sym_filter_entry = he;
        } else {
                char msg[BUFSIZ];
-               symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
+               symbol__strerror_disassemble(&he->ms, err, msg, sizeof(msg));
                pr_err("Couldn't annotate %s: %s\n", sym->name, msg);
        }
 
@@ -252,7 +257,7 @@ static void perf_top__show_details(struct perf_top *top)
        printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), symbol->name);
        printf("  Events  Pcnt (>=%d%%)\n", top->annotation_opts.min_pcnt);
 
-       more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, &top->annotation_opts);
+       more = symbol__annotate_printf(&he->ms, top->sym_evsel, &top->annotation_opts);
 
        if (top->evlist->enabled) {
                if (top->zero)
@@ -528,7 +533,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
                                prompt_integer(&counter, "Enter details event counter");
 
                                if (counter >= top->evlist->core.nr_entries) {
-                                       top->sym_evsel = perf_evlist__first(top->evlist);
+                                       top->sym_evsel = evlist__first(top->evlist);
                                        fprintf(stderr, "Sorry, no such event, using %s.\n", perf_evsel__name(top->sym_evsel));
                                        sleep(1);
                                        break;
@@ -537,7 +542,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
                                        if (top->sym_evsel->idx == counter)
                                                break;
                        } else
-                               top->sym_evsel = perf_evlist__first(top->evlist);
+                               top->sym_evsel = evlist__first(top->evlist);
                        break;
                case 'f':
                        prompt_integer(&top->count_filter, "Enter display event count filter");
@@ -720,7 +725,8 @@ static int hist_iter__top_callback(struct hist_entry_iter *iter,
                perf_top__record_precise_ip(top, he, iter->sample, evsel, al->addr);
 
        hist__account_cycles(iter->sample->branch_stack, al, iter->sample,
-                    !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY));
+                    !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY),
+                    NULL);
        return 0;
 }
 
@@ -861,14 +867,14 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
 {
        struct record_opts *opts = &top->record_opts;
        struct evlist *evlist = top->evlist;
-       struct perf_mmap *md;
+       struct mmap *md;
        union perf_event *event;
 
        md = opts->overwrite ? &evlist->overwrite_mmap[idx] : &evlist->mmap[idx];
-       if (perf_mmap__read_init(md) < 0)
+       if (perf_mmap__read_init(&md->core) < 0)
                return;
 
-       while ((event = perf_mmap__read_event(md)) != NULL) {
+       while ((event = perf_mmap__read_event(&md->core)) != NULL) {
                int ret;
 
                ret = perf_evlist__parse_sample_timestamp(evlist, event, &last_timestamp);
@@ -879,7 +885,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
                if (ret)
                        break;
 
-               perf_mmap__consume(md);
+               perf_mmap__consume(&md->core);
 
                if (top->qe.rotate) {
                        pthread_mutex_lock(&top->qe.mutex);
@@ -889,7 +895,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
                }
        }
 
-       perf_mmap__read_done(md);
+       perf_mmap__read_done(&md->core);
 }
 
 static void perf_top__mmap_read(struct perf_top *top)
@@ -901,7 +907,7 @@ static void perf_top__mmap_read(struct perf_top *top)
        if (overwrite)
                perf_evlist__toggle_bkw_mmap(evlist, BKW_MMAP_DATA_PENDING);
 
-       for (i = 0; i < top->evlist->nr_mmaps; i++)
+       for (i = 0; i < top->evlist->core.nr_mmaps; i++)
                perf_top__mmap_read_idx(top, i);
 
        if (overwrite) {
@@ -959,7 +965,7 @@ static int perf_top__overwrite_check(struct perf_top *top)
                /* has term for current event */
                if ((overwrite < 0) && (set >= 0)) {
                        /* if it's first event, set overwrite */
-                       if (evsel == perf_evlist__first(evlist))
+                       if (evsel == evlist__first(evlist))
                                overwrite = set;
                        else
                                return -1;
@@ -983,7 +989,7 @@ static int perf_top_overwrite_fallback(struct perf_top *top,
                return 0;
 
        /* only fall back when first event fails */
-       if (evsel != perf_evlist__first(evlist))
+       if (evsel != evlist__first(evlist))
                return 0;
 
        evlist__for_each_entry(evlist, counter)
@@ -1040,7 +1046,7 @@ try_again:
                }
        }
 
-       if (perf_evlist__mmap(evlist, opts->mmap_pages) < 0) {
+       if (evlist__mmap(evlist, opts->mmap_pages) < 0) {
                ui__error("Failed to mmap with %d (%s)\n",
                            errno, str_error_r(errno, msg, sizeof(msg)));
                goto out_err;
@@ -1304,7 +1310,7 @@ static int __cmd_top(struct perf_top *top)
        }
 
        /* Wait for a minimal set of events before starting the snapshot */
-       perf_evlist__poll(top->evlist, 100);
+       evlist__poll(top->evlist, 100);
 
        perf_top__mmap_read(top);
 
@@ -1314,7 +1320,7 @@ static int __cmd_top(struct perf_top *top)
                perf_top__mmap_read(top);
 
                if (opts->overwrite || (hits == top->samples))
-                       ret = perf_evlist__poll(top->evlist, 100);
+                       ret = evlist__poll(top->evlist, 100);
 
                if (resize) {
                        perf_top__resize(top);
@@ -1556,6 +1562,17 @@ int cmd_top(int argc, const char **argv)
        status = perf_config(perf_top_config, &top);
        if (status)
                return status;
+       /*
+        * Since the per arch annotation init routine may need the cpuid, read
+        * it here, since we are not getting this from the perf.data header.
+        */
+       status = perf_env__read_cpuid(&perf_env);
+       if (status) {
+               pr_err("Couldn't read the cpuid for this machine: %s\n",
+                      str_error_r(errno, errbuf, sizeof(errbuf)));
+               goto out_delete_evlist;
+       }
+       top.evlist->env = &perf_env;
 
        argc = parse_options(argc, argv, options, top_usage, 0);
        if (argc)
@@ -1641,7 +1658,7 @@ int cmd_top(int argc, const char **argv)
                goto out_delete_evlist;
        }
 
-       top.sym_evsel = perf_evlist__first(top.evlist);
+       top.sym_evsel = evlist__first(top.evlist);
 
        if (!callchain_param.enabled) {
                symbol_conf.cumulate_callchain = false;
@@ -1671,8 +1688,8 @@ int cmd_top(int argc, const char **argv)
        }
 
        top.session = perf_session__new(NULL, false, NULL);
-       if (top.session == NULL) {
-               status = -1;
+       if (IS_ERR(top.session)) {
+               status = PTR_ERR(top.session);
                goto out_delete_evlist;
        }
 
This page took 0.063003 seconds and 4 git commands to generate.