aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-annotate.c18
-rw-r--r--tools/perf/builtin-diff.c1
-rw-r--r--tools/perf/builtin-inject.c11
-rw-r--r--tools/perf/builtin-kmem.c1
-rw-r--r--tools/perf/builtin-lock.c4
-rw-r--r--tools/perf/builtin-report.c19
-rw-r--r--tools/perf/builtin-sched.c1
-rw-r--r--tools/perf/builtin-script.c15
-rw-r--r--tools/perf/builtin-timechart.c11
-rw-r--r--tools/perf/util/build-id.c1
-rw-r--r--tools/perf/util/hist.h1
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c1
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c1
-rw-r--r--tools/perf/util/session.c25
-rw-r--r--tools/perf/util/session.h7
-rw-r--r--tools/perf/util/trace-event-scripting.c1
-rw-r--r--tools/perf/util/trace-event.h1
17 files changed, 73 insertions, 46 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;
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 6b7d91160ecb..e8219990f8b8 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -32,6 +32,7 @@ static int hists__add_entry(struct hists *self,
32 32
33static int diff__process_sample_event(union perf_event *event, 33static int diff__process_sample_event(union perf_event *event,
34 struct perf_sample *sample, 34 struct perf_sample *sample,
35 struct perf_evsel *evsel __used,
35 struct perf_session *session) 36 struct perf_session *session)
36{ 37{
37 struct addr_location al; 38 struct addr_location al;
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index e29f04ed3396..8dfc12bb119b 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -43,6 +43,14 @@ static int perf_event__repipe(union perf_event *event,
43 return perf_event__repipe_synth(event, session); 43 return perf_event__repipe_synth(event, session);
44} 44}
45 45
46static int perf_event__repipe_sample(union perf_event *event,
47 struct perf_sample *sample __used,
48 struct perf_evsel *evsel __used,
49 struct perf_session *session)
50{
51 return perf_event__repipe_synth(event, session);
52}
53
46static int perf_event__repipe_mmap(union perf_event *event, 54static int perf_event__repipe_mmap(union perf_event *event,
47 struct perf_sample *sample, 55 struct perf_sample *sample,
48 struct perf_session *session) 56 struct perf_session *session)
@@ -124,6 +132,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)
124 132
125static int perf_event__inject_buildid(union perf_event *event, 133static int perf_event__inject_buildid(union perf_event *event,
126 struct perf_sample *sample, 134 struct perf_sample *sample,
135 struct perf_evsel *evsel __used,
127 struct perf_session *session) 136 struct perf_session *session)
128{ 137{
129 struct addr_location al; 138 struct addr_location al;
@@ -164,7 +173,7 @@ repipe:
164} 173}
165 174
166struct perf_event_ops inject_ops = { 175struct perf_event_ops inject_ops = {
167 .sample = perf_event__repipe, 176 .sample = perf_event__repipe_sample,
168 .mmap = perf_event__repipe, 177 .mmap = perf_event__repipe,
169 .comm = perf_event__repipe, 178 .comm = perf_event__repipe,
170 .fork = perf_event__repipe, 179 .fork = perf_event__repipe,
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 7f618f4e7b79..225e963df105 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -305,6 +305,7 @@ static void process_raw_event(union perf_event *raw_event __used, void *data,
305 305
306static int process_sample_event(union perf_event *event, 306static int process_sample_event(union perf_event *event,
307 struct perf_sample *sample, 307 struct perf_sample *sample,
308 struct perf_evsel *evsel __used,
308 struct perf_session *session) 309 struct perf_session *session)
309{ 310{
310 struct thread *thread = perf_session__findnew(session, event->ip.pid); 311 struct thread *thread = perf_session__findnew(session, event->ip.pid);
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 7a2a79d2cf2c..9ac05aafd9b2 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -845,7 +845,9 @@ static void dump_info(void)
845 die("Unknown type of information\n"); 845 die("Unknown type of information\n");
846} 846}
847 847
848static int process_sample_event(union perf_event *event, struct perf_sample *sample, 848static int process_sample_event(union perf_event *event,
849 struct perf_sample *sample,
850 struct perf_evsel *evsel __used,
849 struct perf_session *s) 851 struct perf_session *s)
850{ 852{
851 struct thread *thread = perf_session__findnew(s, sample->tid); 853 struct thread *thread = perf_session__findnew(s, sample->tid);
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index b1b82009ab9b..498c6f70a747 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -50,12 +50,12 @@ static symbol_filter_t annotate_init;
50 50
51static int perf_session__add_hist_entry(struct perf_session *session, 51static int perf_session__add_hist_entry(struct perf_session *session,
52 struct addr_location *al, 52 struct addr_location *al,
53 struct perf_sample *sample) 53 struct perf_sample *sample,
54 struct perf_evsel *evsel)
54{ 55{
55 struct symbol *parent = NULL; 56 struct symbol *parent = NULL;
56 int err = 0; 57 int err = 0;
57 struct hist_entry *he; 58 struct hist_entry *he;
58 struct perf_evsel *evsel;
59 59
60 if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) { 60 if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) {
61 err = perf_session__resolve_callchain(session, al->thread, 61 err = perf_session__resolve_callchain(session, al->thread,
@@ -64,18 +64,6 @@ static int perf_session__add_hist_entry(struct perf_session *session,
64 return err; 64 return err;
65 } 65 }
66 66
67 evsel = perf_evlist__id2evsel(session->evlist, sample->id);
68 if (evsel == NULL) {
69 /*
70 * FIXME: Propagate this back, but at least we're in a builtin,
71 * where exit() is allowed. ;-)
72 */
73 ui__warning("Invalid %s file, contains samples with id %" PRIu64 " not in "
74 "its header!\n", input_name, sample->id);
75 exit_browser(0);
76 exit(1);
77 }
78
79 he = __hists__add_entry(&evsel->hists, al, parent, sample->period); 67 he = __hists__add_entry(&evsel->hists, al, parent, sample->period);
80 if (he == NULL) 68 if (he == NULL)
81 return -ENOMEM; 69 return -ENOMEM;
@@ -113,6 +101,7 @@ out:
113 101
114static int process_sample_event(union perf_event *event, 102static int process_sample_event(union perf_event *event,
115 struct perf_sample *sample, 103 struct perf_sample *sample,
104 struct perf_evsel *evsel,
116 struct perf_session *session) 105 struct perf_session *session)
117{ 106{
118 struct addr_location al; 107 struct addr_location al;
@@ -127,7 +116,7 @@ static int process_sample_event(union perf_event *event,
127 if (al.filtered || (hide_unresolved && al.sym == NULL)) 116 if (al.filtered || (hide_unresolved && al.sym == NULL))
128 return 0; 117 return 0;
129 118
130 if (perf_session__add_hist_entry(session, &al, sample)) { 119 if (perf_session__add_hist_entry(session, &al, sample, evsel)) {
131 pr_debug("problem incrementing symbol period, skipping event\n"); 120 pr_debug("problem incrementing symbol period, skipping event\n");
132 return -1; 121 return -1;
133 } 122 }
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index a32f411faeac..dcfe8873c9a1 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1603,6 +1603,7 @@ static void process_raw_event(union perf_event *raw_event __used,
1603 1603
1604static int process_sample_event(union perf_event *event, 1604static int process_sample_event(union perf_event *event,
1605 struct perf_sample *sample, 1605 struct perf_sample *sample,
1606 struct perf_evsel *evsel __used,
1606 struct perf_session *session) 1607 struct perf_session *session)
1607{ 1608{
1608 struct thread *thread; 1609 struct thread *thread;
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9f5fc5492141..ac574ea23917 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -162,19 +162,11 @@ static void print_sample_start(struct perf_sample *sample,
162 162
163static void process_event(union perf_event *event __unused, 163static void process_event(union perf_event *event __unused,
164 struct perf_sample *sample, 164 struct perf_sample *sample,
165 struct perf_evsel *evsel,
165 struct perf_session *session, 166 struct perf_session *session,
166 struct thread *thread) 167 struct thread *thread)
167{ 168{
168 struct perf_event_attr *attr; 169 struct perf_event_attr *attr = &evsel->attr;
169 struct perf_evsel *evsel;
170
171 evsel = perf_evlist__id2evsel(session->evlist, sample->id);
172 if (evsel == NULL) {
173 pr_err("Invalid data. Contains samples with id not in "
174 "its header!\n");
175 return;
176 }
177 attr = &evsel->attr;
178 170
179 if (output_fields[attr->type] == 0) 171 if (output_fields[attr->type] == 0)
180 return; 172 return;
@@ -244,6 +236,7 @@ static char const *input_name = "perf.data";
244 236
245static int process_sample_event(union perf_event *event, 237static int process_sample_event(union perf_event *event,
246 struct perf_sample *sample, 238 struct perf_sample *sample,
239 struct perf_evsel *evsel,
247 struct perf_session *session) 240 struct perf_session *session)
248{ 241{
249 struct thread *thread = perf_session__findnew(session, event->ip.pid); 242 struct thread *thread = perf_session__findnew(session, event->ip.pid);
@@ -264,7 +257,7 @@ static int process_sample_event(union perf_event *event,
264 last_timestamp = sample->time; 257 last_timestamp = sample->time;
265 return 0; 258 return 0;
266 } 259 }
267 scripting_ops->process_event(event, sample, session, thread); 260 scripting_ops->process_event(event, sample, evsel, session, thread);
268 261
269 session->hists.stats.total_period += sample->period; 262 session->hists.stats.total_period += sample->period;
270 return 0; 263 return 0;
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 67c0459dc325..aa26f4d66d10 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -488,6 +488,7 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te)
488 488
489static int process_sample_event(union perf_event *event __used, 489static int process_sample_event(union perf_event *event __used,
490 struct perf_sample *sample, 490 struct perf_sample *sample,
491 struct perf_evsel *evsel __used,
491 struct perf_session *session) 492 struct perf_session *session)
492{ 493{
493 struct trace_entry *te; 494 struct trace_entry *te;
@@ -506,6 +507,16 @@ static int process_sample_event(union perf_event *event __used,
506 struct power_entry_old *peo; 507 struct power_entry_old *peo;
507 peo = (void *)te; 508 peo = (void *)te;
508#endif 509#endif
510 /*
511 * FIXME: use evsel, its already mapped from id to perf_evsel,
512 * remove perf_header__find_event infrastructure bits.
513 * Mapping all these "power:cpu_idle" strings to the tracepoint
514 * ID and then just comparing against evsel->attr.config.
515 *
516 * e.g.:
517 *
518 * if (evsel->attr.config == power_cpu_idle_id)
519 */
509 event_str = perf_header__find_event(te->type); 520 event_str = perf_header__find_event(te->type);
510 521
511 if (!event_str) 522 if (!event_str)
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 31f934af9861..a91cd99f26ea 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -16,6 +16,7 @@
16 16
17static int build_id__mark_dso_hit(union perf_event *event, 17static int build_id__mark_dso_hit(union perf_event *event,
18 struct perf_sample *sample __used, 18 struct perf_sample *sample __used,
19 struct perf_evsel *evsel __used,
19 struct perf_session *session) 20 struct perf_session *session)
20{ 21{
21 struct addr_location al; 22 struct addr_location al;
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index cb6858a2f9a3..3beb97c4d822 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -29,6 +29,7 @@ struct events_stats {
29 u32 nr_events[PERF_RECORD_HEADER_MAX]; 29 u32 nr_events[PERF_RECORD_HEADER_MAX];
30 u32 nr_unknown_events; 30 u32 nr_unknown_events;
31 u32 nr_invalid_chains; 31 u32 nr_invalid_chains;
32 u32 nr_unknown_id;
32}; 33};
33 34
34enum hist_column { 35enum hist_column {
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index 621427212e86..74350ffb57fe 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -247,6 +247,7 @@ static inline struct event *find_cache_event(int type)
247 247
248static void perl_process_event(union perf_event *pevent __unused, 248static void perl_process_event(union perf_event *pevent __unused,
249 struct perf_sample *sample, 249 struct perf_sample *sample,
250 struct perf_evsel *evsel,
250 struct perf_session *session __unused, 251 struct perf_session *session __unused,
251 struct thread *thread) 252 struct thread *thread)
252{ 253{
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 1b85d6055159..6ccf70e8d8f2 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -206,6 +206,7 @@ static inline struct event *find_cache_event(int type)
206 206
207static void python_process_event(union perf_event *pevent __unused, 207static void python_process_event(union perf_event *pevent __unused,
208 struct perf_sample *sample, 208 struct perf_sample *sample,
209 struct perf_evsel *evsel __unused,
209 struct perf_session *session __unused, 210 struct perf_session *session __unused,
210 struct thread *thread) 211 struct thread *thread)
211{ 212{
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index c68cf40764f9..caa224522fea 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -280,6 +280,15 @@ static int process_event_synth_stub(union perf_event *event __used,
280 return 0; 280 return 0;
281} 281}
282 282
283static int process_event_sample_stub(union perf_event *event __used,
284 struct perf_sample *sample __used,
285 struct perf_evsel *evsel __used,
286 struct perf_session *session __used)
287{
288 dump_printf(": unhandled!\n");
289 return 0;
290}
291
283static int process_event_stub(union perf_event *event __used, 292static int process_event_stub(union perf_event *event __used,
284 struct perf_sample *sample __used, 293 struct perf_sample *sample __used,
285 struct perf_session *session __used) 294 struct perf_session *session __used)
@@ -303,7 +312,7 @@ static int process_finished_round(union perf_event *event,
303static void perf_event_ops__fill_defaults(struct perf_event_ops *handler) 312static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
304{ 313{
305 if (handler->sample == NULL) 314 if (handler->sample == NULL)
306 handler->sample = process_event_stub; 315 handler->sample = process_event_sample_stub;
307 if (handler->mmap == NULL) 316 if (handler->mmap == NULL)
308 handler->mmap = process_event_stub; 317 handler->mmap = process_event_stub;
309 if (handler->comm == NULL) 318 if (handler->comm == NULL)
@@ -698,12 +707,19 @@ static int perf_session_deliver_event(struct perf_session *session,
698 struct perf_event_ops *ops, 707 struct perf_event_ops *ops,
699 u64 file_offset) 708 u64 file_offset)
700{ 709{
710 struct perf_evsel *evsel;
711
701 dump_event(session, event, file_offset, sample); 712 dump_event(session, event, file_offset, sample);
702 713
703 switch (event->header.type) { 714 switch (event->header.type) {
704 case PERF_RECORD_SAMPLE: 715 case PERF_RECORD_SAMPLE:
705 dump_sample(session, event, sample); 716 dump_sample(session, event, sample);
706 return ops->sample(event, sample, session); 717 evsel = perf_evlist__id2evsel(session->evlist, sample->id);
718 if (evsel == NULL) {
719 ++session->hists.stats.nr_unknown_id;
720 return -1;
721 }
722 return ops->sample(event, sample, evsel, session);
707 case PERF_RECORD_MMAP: 723 case PERF_RECORD_MMAP:
708 return ops->mmap(event, sample, session); 724 return ops->mmap(event, sample, session);
709 case PERF_RECORD_COMM: 725 case PERF_RECORD_COMM:
@@ -845,6 +861,11 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
845 session->hists.stats.nr_unknown_events); 861 session->hists.stats.nr_unknown_events);
846 } 862 }
847 863
864 if (session->hists.stats.nr_unknown_id != 0) {
865 ui__warning("%u samples with id not present in the header\n",
866 session->hists.stats.nr_unknown_id);
867 }
868
848 if (session->hists.stats.nr_invalid_chains != 0) { 869 if (session->hists.stats.nr_invalid_chains != 0) {
849 ui__warning("Found invalid callchains!\n\n" 870 ui__warning("Found invalid callchains!\n\n"
850 "%u out of %u events were discarded for this reason.\n\n" 871 "%u out of %u events were discarded for this reason.\n\n"
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 0b3c9afecaa9..1ac481fc1100 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -55,8 +55,11 @@ struct perf_session {
55 char filename[0]; 55 char filename[0];
56}; 56};
57 57
58struct perf_evsel;
58struct perf_event_ops; 59struct perf_event_ops;
59 60
61typedef int (*event_sample)(union perf_event *event, struct perf_sample *sample,
62 struct perf_evsel *evsel, struct perf_session *session);
60typedef int (*event_op)(union perf_event *self, struct perf_sample *sample, 63typedef int (*event_op)(union perf_event *self, struct perf_sample *sample,
61 struct perf_session *session); 64 struct perf_session *session);
62typedef int (*event_synth_op)(union perf_event *self, 65typedef int (*event_synth_op)(union perf_event *self,
@@ -65,8 +68,8 @@ typedef int (*event_op2)(union perf_event *self, struct perf_session *session,
65 struct perf_event_ops *ops); 68 struct perf_event_ops *ops);
66 69
67struct perf_event_ops { 70struct perf_event_ops {
68 event_op sample, 71 event_sample sample;
69 mmap, 72 event_op mmap,
70 comm, 73 comm,
71 fork, 74 fork,
72 exit, 75 exit,
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
index 66f4b78737ab..c9dcbec7d800 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -38,6 +38,7 @@ static int stop_script_unsupported(void)
38 38
39static void process_event_unsupported(union perf_event *event __unused, 39static void process_event_unsupported(union perf_event *event __unused,
40 struct perf_sample *sample __unused, 40 struct perf_sample *sample __unused,
41 struct perf_evsel *evsel __unused,
41 struct perf_session *session __unused, 42 struct perf_session *session __unused,
42 struct thread *thread __unused) 43 struct thread *thread __unused)
43{ 44{
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index b04da5722437..f674dda3363b 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -280,6 +280,7 @@ struct scripting_ops {
280 int (*stop_script) (void); 280 int (*stop_script) (void);
281 void (*process_event) (union perf_event *event, 281 void (*process_event) (union perf_event *event,
282 struct perf_sample *sample, 282 struct perf_sample *sample,
283 struct perf_evsel *evsel,
283 struct perf_session *session, 284 struct perf_session *session,
284 struct thread *thread); 285 struct thread *thread);
285 int (*generate_script) (const char *outfile); 286 int (*generate_script) (const char *outfile);