aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-03-15 14:44:01 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-03-23 18:28:58 -0400
commit9e69c210822c4035708a6111567c96364ca244d5 (patch)
tree3bae4b7f4309ec18bf4628b81cf85bb1570f6a31 /tools/perf/builtin-annotate.c
parent880f57318450dbead6a03f9e31a1468924d6dd88 (diff)
perf session: Pass evsel in event_ops->sample()
Resolving the sample->id to an evsel since the most advanced tools, report and annotate, and the others will too when they evolve to properly support multi-event perf.data files. Good also because it does an extra validation, checking that the ID is valid when present. When that is not the case, the overhead is just a branch + function call (perf_evlist__id2evsel). Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 695de4b5ae63..e18eb7ed30ae 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -42,9 +42,9 @@ static const char *sym_hist_filter;
42 42
43static int perf_evlist__add_sample(struct perf_evlist *evlist, 43static int perf_evlist__add_sample(struct perf_evlist *evlist,
44 struct perf_sample *sample, 44 struct perf_sample *sample,
45 struct perf_evsel *evsel,
45 struct addr_location *al) 46 struct addr_location *al)
46{ 47{
47 struct perf_evsel *evsel;
48 struct hist_entry *he; 48 struct hist_entry *he;
49 int ret; 49 int ret;
50 50
@@ -59,18 +59,6 @@ static int perf_evlist__add_sample(struct perf_evlist *evlist,
59 return 0; 59 return 0;
60 } 60 }
61 61
62 evsel = perf_evlist__id2evsel(evlist, sample->id);
63 if (evsel == NULL) {
64 /*
65 * FIXME: Propagate this back, but at least we're in a builtin,
66 * where exit() is allowed. ;-)
67 */
68 ui__warning("Invalid %s file, contains samples with id not in "
69 "its header!\n", input_name);
70 exit_browser(0);
71 exit(1);
72 }
73
74 he = __hists__add_entry(&evsel->hists, al, NULL, 1); 62 he = __hists__add_entry(&evsel->hists, al, NULL, 1);
75 if (he == NULL) 63 if (he == NULL)
76 return -ENOMEM; 64 return -ENOMEM;
@@ -92,6 +80,7 @@ static int perf_evlist__add_sample(struct perf_evlist *evlist,
92 80
93static int process_sample_event(union perf_event *event, 81static int process_sample_event(union perf_event *event,
94 struct perf_sample *sample, 82 struct perf_sample *sample,
83 struct perf_evsel *evsel,
95 struct perf_session *session) 84 struct perf_session *session)
96{ 85{
97 struct addr_location al; 86 struct addr_location al;
@@ -103,7 +92,8 @@ static int process_sample_event(union perf_event *event,
103 return -1; 92 return -1;
104 } 93 }
105 94
106 if (!al.filtered && perf_evlist__add_sample(session->evlist, sample, &al)) { 95 if (!al.filtered &&
96 perf_evlist__add_sample(session->evlist, sample, evsel, &al)) {
107 pr_warning("problem incrementing symbol count, " 97 pr_warning("problem incrementing symbol count, "
108 "skipping event\n"); 98 "skipping event\n");
109 return -1; 99 return -1;