diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-29 11:01:45 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-29 13:25:37 -0500 |
commit | 8115d60c323dd9931b95221c0a392aeddc1d6ef3 (patch) | |
tree | 13e75d71c5163c78efc9d8ab33988cc6c7be74a1 /tools/perf/util | |
parent | 8d50e5b4171a69cf48ca94a1e7c14033d0b4771d (diff) |
perf tools: Kill event_t typedef, use 'union perf_event' instead
And move the event_t methods to the perf_event__ too.
No code changes, just namespace consistency.
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/util')
-rw-r--r-- | tools/perf/util/build-id.c | 19 | ||||
-rw-r--r-- | tools/perf/util/callchain.c | 3 | ||||
-rw-r--r-- | tools/perf/util/callchain.h | 4 | ||||
-rw-r--r-- | tools/perf/util/debug.c | 2 | ||||
-rw-r--r-- | tools/perf/util/debug.h | 2 | ||||
-rw-r--r-- | tools/perf/util/event.c | 187 | ||||
-rw-r--r-- | tools/perf/util/event.h | 69 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 6 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 4 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 10 | ||||
-rw-r--r-- | tools/perf/util/header.c | 83 | ||||
-rw-r--r-- | tools/perf/util/header.h | 50 | ||||
-rw-r--r-- | tools/perf/util/hist.c | 2 | ||||
-rw-r--r-- | tools/perf/util/session.c | 169 | ||||
-rw-r--r-- | tools/perf/util/session.h | 13 |
15 files changed, 321 insertions, 302 deletions
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index b184a7fa0843..31f934af9861 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include "debug.h" | 15 | #include "debug.h" |
16 | 16 | ||
17 | static int build_id__mark_dso_hit(event_t *event, | 17 | static 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_session *session) | 19 | struct perf_session *session) |
20 | { | 20 | { |
@@ -37,13 +37,14 @@ static int build_id__mark_dso_hit(event_t *event, | |||
37 | return 0; | 37 | return 0; |
38 | } | 38 | } |
39 | 39 | ||
40 | static int event__exit_del_thread(event_t *self, struct perf_sample *sample __used, | 40 | static int perf_event__exit_del_thread(union perf_event *event, |
41 | struct perf_session *session) | 41 | struct perf_sample *sample __used, |
42 | struct perf_session *session) | ||
42 | { | 43 | { |
43 | struct thread *thread = perf_session__findnew(session, self->fork.tid); | 44 | struct thread *thread = perf_session__findnew(session, event->fork.tid); |
44 | 45 | ||
45 | dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid, | 46 | dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid, |
46 | self->fork.ppid, self->fork.ptid); | 47 | event->fork.ppid, event->fork.ptid); |
47 | 48 | ||
48 | if (thread) { | 49 | if (thread) { |
49 | rb_erase(&thread->rb_node, &session->threads); | 50 | rb_erase(&thread->rb_node, &session->threads); |
@@ -56,9 +57,9 @@ static int event__exit_del_thread(event_t *self, struct perf_sample *sample __us | |||
56 | 57 | ||
57 | struct perf_event_ops build_id__mark_dso_hit_ops = { | 58 | struct perf_event_ops build_id__mark_dso_hit_ops = { |
58 | .sample = build_id__mark_dso_hit, | 59 | .sample = build_id__mark_dso_hit, |
59 | .mmap = event__process_mmap, | 60 | .mmap = perf_event__process_mmap, |
60 | .fork = event__process_task, | 61 | .fork = perf_event__process_task, |
61 | .exit = event__exit_del_thread, | 62 | .exit = perf_event__exit_del_thread, |
62 | }; | 63 | }; |
63 | 64 | ||
64 | char *dso__build_id_filename(struct dso *self, char *bf, size_t size) | 65 | char *dso__build_id_filename(struct dso *self, char *bf, size_t size) |
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index f8c66d1435e0..9f7106a8d9a4 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c | |||
@@ -18,7 +18,8 @@ | |||
18 | #include "util.h" | 18 | #include "util.h" |
19 | #include "callchain.h" | 19 | #include "callchain.h" |
20 | 20 | ||
21 | bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event) | 21 | bool ip_callchain__valid(struct ip_callchain *chain, |
22 | const union perf_event *event) | ||
22 | { | 23 | { |
23 | unsigned int chain_size = event->header.size; | 24 | unsigned int chain_size = event->header.size; |
24 | chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event; | 25 | chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event; |
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 67137256a1cd..1a79df9f739f 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h | |||
@@ -95,8 +95,8 @@ int callchain_append(struct callchain_root *root, | |||
95 | int callchain_merge(struct callchain_cursor *cursor, | 95 | int callchain_merge(struct callchain_cursor *cursor, |
96 | struct callchain_root *dst, struct callchain_root *src); | 96 | struct callchain_root *dst, struct callchain_root *src); |
97 | 97 | ||
98 | bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event); | 98 | bool ip_callchain__valid(struct ip_callchain *chain, |
99 | 99 | const union perf_event *event); | |
100 | /* | 100 | /* |
101 | * Initialize a cursor before adding entries inside, but keep | 101 | * Initialize a cursor before adding entries inside, but keep |
102 | * the previously allocated entries as a cache. | 102 | * the previously allocated entries as a cache. |
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 01bbe8ecec3f..d4536a9e0d8c 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c | |||
@@ -57,7 +57,7 @@ void ui__warning(const char *format, ...) | |||
57 | } | 57 | } |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | void trace_event(event_t *event) | 60 | void trace_event(union perf_event *event) |
61 | { | 61 | { |
62 | unsigned char *raw_event = (void *)event; | 62 | unsigned char *raw_event = (void *)event; |
63 | const char *color = PERF_COLOR_BLUE; | 63 | const char *color = PERF_COLOR_BLUE; |
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index ca35fd66b5df..93516cf4682c 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h | |||
@@ -9,7 +9,7 @@ extern int verbose; | |||
9 | extern bool quiet, dump_trace; | 9 | extern bool quiet, dump_trace; |
10 | 10 | ||
11 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); | 11 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); |
12 | void trace_event(event_t *event); | 12 | void trace_event(union perf_event *event); |
13 | 13 | ||
14 | struct ui_progress; | 14 | struct ui_progress; |
15 | 15 | ||
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 5c886fbd50ce..731265f4ad19 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -7,7 +7,7 @@ | |||
7 | #include "strlist.h" | 7 | #include "strlist.h" |
8 | #include "thread.h" | 8 | #include "thread.h" |
9 | 9 | ||
10 | static const char *event__name[] = { | 10 | static const char *perf_event__names[] = { |
11 | [0] = "TOTAL", | 11 | [0] = "TOTAL", |
12 | [PERF_RECORD_MMAP] = "MMAP", | 12 | [PERF_RECORD_MMAP] = "MMAP", |
13 | [PERF_RECORD_LOST] = "LOST", | 13 | [PERF_RECORD_LOST] = "LOST", |
@@ -25,13 +25,13 @@ static const char *event__name[] = { | |||
25 | [PERF_RECORD_FINISHED_ROUND] = "FINISHED_ROUND", | 25 | [PERF_RECORD_FINISHED_ROUND] = "FINISHED_ROUND", |
26 | }; | 26 | }; |
27 | 27 | ||
28 | const char *event__get_event_name(unsigned int id) | 28 | const char *perf_event__name(unsigned int id) |
29 | { | 29 | { |
30 | if (id >= ARRAY_SIZE(event__name)) | 30 | if (id >= ARRAY_SIZE(perf_event__names)) |
31 | return "INVALID"; | 31 | return "INVALID"; |
32 | if (!event__name[id]) | 32 | if (!perf_event__names[id]) |
33 | return "UNKNOWN"; | 33 | return "UNKNOWN"; |
34 | return event__name[id]; | 34 | return perf_event__names[id]; |
35 | } | 35 | } |
36 | 36 | ||
37 | static struct perf_sample synth_sample = { | 37 | static struct perf_sample synth_sample = { |
@@ -43,9 +43,9 @@ static struct perf_sample synth_sample = { | |||
43 | .period = 1, | 43 | .period = 1, |
44 | }; | 44 | }; |
45 | 45 | ||
46 | static pid_t event__synthesize_comm(event_t *event, pid_t pid, int full, | 46 | static pid_t perf_event__synthesize_comm(union perf_event *event, pid_t pid, |
47 | event__handler_t process, | 47 | int full, perf_event__handler_t process, |
48 | struct perf_session *session) | 48 | struct perf_session *session) |
49 | { | 49 | { |
50 | char filename[PATH_MAX]; | 50 | char filename[PATH_MAX]; |
51 | char bf[BUFSIZ]; | 51 | char bf[BUFSIZ]; |
@@ -126,9 +126,10 @@ out: | |||
126 | return tgid; | 126 | return tgid; |
127 | } | 127 | } |
128 | 128 | ||
129 | static int event__synthesize_mmap_events(event_t *event, pid_t pid, pid_t tgid, | 129 | static int perf_event__synthesize_mmap_events(union perf_event *event, |
130 | event__handler_t process, | 130 | pid_t pid, pid_t tgid, |
131 | struct perf_session *session) | 131 | perf_event__handler_t process, |
132 | struct perf_session *session) | ||
132 | { | 133 | { |
133 | char filename[PATH_MAX]; | 134 | char filename[PATH_MAX]; |
134 | FILE *fp; | 135 | FILE *fp; |
@@ -199,14 +200,14 @@ static int event__synthesize_mmap_events(event_t *event, pid_t pid, pid_t tgid, | |||
199 | return 0; | 200 | return 0; |
200 | } | 201 | } |
201 | 202 | ||
202 | int event__synthesize_modules(event__handler_t process, | 203 | int perf_event__synthesize_modules(perf_event__handler_t process, |
203 | struct perf_session *session, | 204 | struct perf_session *session, |
204 | struct machine *machine) | 205 | struct machine *machine) |
205 | { | 206 | { |
206 | struct rb_node *nd; | 207 | struct rb_node *nd; |
207 | struct map_groups *kmaps = &machine->kmaps; | 208 | struct map_groups *kmaps = &machine->kmaps; |
208 | event_t *event = zalloc(sizeof(event->mmap) + session->id_hdr_size); | 209 | union perf_event *event = zalloc((sizeof(event->mmap) + |
209 | 210 | session->id_hdr_size)); | |
210 | if (event == NULL) { | 211 | if (event == NULL) { |
211 | pr_debug("Not enough memory synthesizing mmap event " | 212 | pr_debug("Not enough memory synthesizing mmap event " |
212 | "for kernel modules\n"); | 213 | "for kernel modules\n"); |
@@ -251,22 +252,23 @@ int event__synthesize_modules(event__handler_t process, | |||
251 | return 0; | 252 | return 0; |
252 | } | 253 | } |
253 | 254 | ||
254 | static int __event__synthesize_thread(event_t *comm_event, event_t *mmap_event, | 255 | static int __event__synthesize_thread(union perf_event *comm_event, |
255 | pid_t pid, event__handler_t process, | 256 | union perf_event *mmap_event, |
257 | pid_t pid, perf_event__handler_t process, | ||
256 | struct perf_session *session) | 258 | struct perf_session *session) |
257 | { | 259 | { |
258 | pid_t tgid = event__synthesize_comm(comm_event, pid, 1, process, | 260 | pid_t tgid = perf_event__synthesize_comm(comm_event, pid, 1, process, |
259 | session); | 261 | session); |
260 | if (tgid == -1) | 262 | if (tgid == -1) |
261 | return -1; | 263 | return -1; |
262 | return event__synthesize_mmap_events(mmap_event, pid, tgid, | 264 | return perf_event__synthesize_mmap_events(mmap_event, pid, tgid, |
263 | process, session); | 265 | process, session); |
264 | } | 266 | } |
265 | 267 | ||
266 | int event__synthesize_thread(pid_t pid, event__handler_t process, | 268 | int perf_event__synthesize_thread(pid_t pid, perf_event__handler_t process, |
267 | struct perf_session *session) | 269 | struct perf_session *session) |
268 | { | 270 | { |
269 | event_t *comm_event, *mmap_event; | 271 | union perf_event *comm_event, *mmap_event; |
270 | int err = -1; | 272 | int err = -1; |
271 | 273 | ||
272 | comm_event = malloc(sizeof(comm_event->comm) + session->id_hdr_size); | 274 | comm_event = malloc(sizeof(comm_event->comm) + session->id_hdr_size); |
@@ -286,12 +288,12 @@ out: | |||
286 | return err; | 288 | return err; |
287 | } | 289 | } |
288 | 290 | ||
289 | int event__synthesize_threads(event__handler_t process, | 291 | int perf_event__synthesize_threads(perf_event__handler_t process, |
290 | struct perf_session *session) | 292 | struct perf_session *session) |
291 | { | 293 | { |
292 | DIR *proc; | 294 | DIR *proc; |
293 | struct dirent dirent, *next; | 295 | struct dirent dirent, *next; |
294 | event_t *comm_event, *mmap_event; | 296 | union perf_event *comm_event, *mmap_event; |
295 | int err = -1; | 297 | int err = -1; |
296 | 298 | ||
297 | comm_event = malloc(sizeof(comm_event->comm) + session->id_hdr_size); | 299 | comm_event = malloc(sizeof(comm_event->comm) + session->id_hdr_size); |
@@ -349,10 +351,10 @@ static int find_symbol_cb(void *arg, const char *name, char type, | |||
349 | return 1; | 351 | return 1; |
350 | } | 352 | } |
351 | 353 | ||
352 | int event__synthesize_kernel_mmap(event__handler_t process, | 354 | int perf_event__synthesize_kernel_mmap(perf_event__handler_t process, |
353 | struct perf_session *session, | 355 | struct perf_session *session, |
354 | struct machine *machine, | 356 | struct machine *machine, |
355 | const char *symbol_name) | 357 | const char *symbol_name) |
356 | { | 358 | { |
357 | size_t size; | 359 | size_t size; |
358 | const char *filename, *mmap_name; | 360 | const char *filename, *mmap_name; |
@@ -366,8 +368,8 @@ int event__synthesize_kernel_mmap(event__handler_t process, | |||
366 | * kernels. | 368 | * kernels. |
367 | */ | 369 | */ |
368 | struct process_symbol_args args = { .name = symbol_name, }; | 370 | struct process_symbol_args args = { .name = symbol_name, }; |
369 | event_t *event = zalloc(sizeof(event->mmap) + session->id_hdr_size); | 371 | union perf_event *event = zalloc((sizeof(event->mmap) + |
370 | 372 | session->id_hdr_size)); | |
371 | if (event == NULL) { | 373 | if (event == NULL) { |
372 | pr_debug("Not enough memory synthesizing mmap event " | 374 | pr_debug("Not enough memory synthesizing mmap event " |
373 | "for kernel modules\n"); | 375 | "for kernel modules\n"); |
@@ -440,14 +442,15 @@ static int thread__set_comm_adjust(struct thread *self, const char *comm, | |||
440 | return 0; | 442 | return 0; |
441 | } | 443 | } |
442 | 444 | ||
443 | int event__process_comm(event_t *self, struct perf_sample *sample __used, | 445 | int perf_event__process_comm(union perf_event *event, |
444 | struct perf_session *session) | 446 | struct perf_sample *sample __used, |
447 | struct perf_session *session) | ||
445 | { | 448 | { |
446 | struct thread *thread = perf_session__findnew(session, self->comm.tid); | 449 | struct thread *thread = perf_session__findnew(session, event->comm.tid); |
447 | 450 | ||
448 | dump_printf(": %s:%d\n", self->comm.comm, self->comm.tid); | 451 | dump_printf(": %s:%d\n", event->comm.comm, event->comm.tid); |
449 | 452 | ||
450 | if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm, | 453 | if (thread == NULL || thread__set_comm_adjust(thread, event->comm.comm, |
451 | &session->hists)) { | 454 | &session->hists)) { |
452 | dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); | 455 | dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); |
453 | return -1; | 456 | return -1; |
@@ -456,19 +459,21 @@ int event__process_comm(event_t *self, struct perf_sample *sample __used, | |||
456 | return 0; | 459 | return 0; |
457 | } | 460 | } |
458 | 461 | ||
459 | int event__process_lost(event_t *self, struct perf_sample *sample __used, | 462 | int perf_event__process_lost(union perf_event *event, |
460 | struct perf_session *session) | 463 | struct perf_sample *sample __used, |
464 | struct perf_session *session) | ||
461 | { | 465 | { |
462 | dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n", | 466 | dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n", |
463 | self->lost.id, self->lost.lost); | 467 | event->lost.id, event->lost.lost); |
464 | session->hists.stats.total_lost += self->lost.lost; | 468 | session->hists.stats.total_lost += event->lost.lost; |
465 | return 0; | 469 | return 0; |
466 | } | 470 | } |
467 | 471 | ||
468 | static void event_set_kernel_mmap_len(struct map **maps, event_t *self) | 472 | static void perf_event__set_kernel_mmap_len(union perf_event *event, |
473 | struct map **maps) | ||
469 | { | 474 | { |
470 | maps[MAP__FUNCTION]->start = self->mmap.start; | 475 | maps[MAP__FUNCTION]->start = event->mmap.start; |
471 | maps[MAP__FUNCTION]->end = self->mmap.start + self->mmap.len; | 476 | maps[MAP__FUNCTION]->end = event->mmap.start + event->mmap.len; |
472 | /* | 477 | /* |
473 | * Be a bit paranoid here, some perf.data file came with | 478 | * Be a bit paranoid here, some perf.data file came with |
474 | * a zero sized synthesized MMAP event for the kernel. | 479 | * a zero sized synthesized MMAP event for the kernel. |
@@ -477,8 +482,8 @@ static void event_set_kernel_mmap_len(struct map **maps, event_t *self) | |||
477 | maps[MAP__FUNCTION]->end = ~0ULL; | 482 | maps[MAP__FUNCTION]->end = ~0ULL; |
478 | } | 483 | } |
479 | 484 | ||
480 | static int event__process_kernel_mmap(event_t *self, | 485 | static int perf_event__process_kernel_mmap(union perf_event *event, |
481 | struct perf_session *session) | 486 | struct perf_session *session) |
482 | { | 487 | { |
483 | struct map *map; | 488 | struct map *map; |
484 | char kmmap_prefix[PATH_MAX]; | 489 | char kmmap_prefix[PATH_MAX]; |
@@ -486,9 +491,9 @@ static int event__process_kernel_mmap(event_t *self, | |||
486 | enum dso_kernel_type kernel_type; | 491 | enum dso_kernel_type kernel_type; |
487 | bool is_kernel_mmap; | 492 | bool is_kernel_mmap; |
488 | 493 | ||
489 | machine = perf_session__findnew_machine(session, self->mmap.pid); | 494 | machine = perf_session__findnew_machine(session, event->mmap.pid); |
490 | if (!machine) { | 495 | if (!machine) { |
491 | pr_err("Can't find id %d's machine\n", self->mmap.pid); | 496 | pr_err("Can't find id %d's machine\n", event->mmap.pid); |
492 | goto out_problem; | 497 | goto out_problem; |
493 | } | 498 | } |
494 | 499 | ||
@@ -498,17 +503,17 @@ static int event__process_kernel_mmap(event_t *self, | |||
498 | else | 503 | else |
499 | kernel_type = DSO_TYPE_GUEST_KERNEL; | 504 | kernel_type = DSO_TYPE_GUEST_KERNEL; |
500 | 505 | ||
501 | is_kernel_mmap = memcmp(self->mmap.filename, | 506 | is_kernel_mmap = memcmp(event->mmap.filename, |
502 | kmmap_prefix, | 507 | kmmap_prefix, |
503 | strlen(kmmap_prefix)) == 0; | 508 | strlen(kmmap_prefix)) == 0; |
504 | if (self->mmap.filename[0] == '/' || | 509 | if (event->mmap.filename[0] == '/' || |
505 | (!is_kernel_mmap && self->mmap.filename[0] == '[')) { | 510 | (!is_kernel_mmap && event->mmap.filename[0] == '[')) { |
506 | 511 | ||
507 | char short_module_name[1024]; | 512 | char short_module_name[1024]; |
508 | char *name, *dot; | 513 | char *name, *dot; |
509 | 514 | ||
510 | if (self->mmap.filename[0] == '/') { | 515 | if (event->mmap.filename[0] == '/') { |
511 | name = strrchr(self->mmap.filename, '/'); | 516 | name = strrchr(event->mmap.filename, '/'); |
512 | if (name == NULL) | 517 | if (name == NULL) |
513 | goto out_problem; | 518 | goto out_problem; |
514 | 519 | ||
@@ -520,10 +525,10 @@ static int event__process_kernel_mmap(event_t *self, | |||
520 | "[%.*s]", (int)(dot - name), name); | 525 | "[%.*s]", (int)(dot - name), name); |
521 | strxfrchar(short_module_name, '-', '_'); | 526 | strxfrchar(short_module_name, '-', '_'); |
522 | } else | 527 | } else |
523 | strcpy(short_module_name, self->mmap.filename); | 528 | strcpy(short_module_name, event->mmap.filename); |
524 | 529 | ||
525 | map = machine__new_module(machine, self->mmap.start, | 530 | map = machine__new_module(machine, event->mmap.start, |
526 | self->mmap.filename); | 531 | event->mmap.filename); |
527 | if (map == NULL) | 532 | if (map == NULL) |
528 | goto out_problem; | 533 | goto out_problem; |
529 | 534 | ||
@@ -533,9 +538,9 @@ static int event__process_kernel_mmap(event_t *self, | |||
533 | 538 | ||
534 | map->dso->short_name = name; | 539 | map->dso->short_name = name; |
535 | map->dso->sname_alloc = 1; | 540 | map->dso->sname_alloc = 1; |
536 | map->end = map->start + self->mmap.len; | 541 | map->end = map->start + event->mmap.len; |
537 | } else if (is_kernel_mmap) { | 542 | } else if (is_kernel_mmap) { |
538 | const char *symbol_name = (self->mmap.filename + | 543 | const char *symbol_name = (event->mmap.filename + |
539 | strlen(kmmap_prefix)); | 544 | strlen(kmmap_prefix)); |
540 | /* | 545 | /* |
541 | * Should be there already, from the build-id table in | 546 | * Should be there already, from the build-id table in |
@@ -550,10 +555,10 @@ static int event__process_kernel_mmap(event_t *self, | |||
550 | if (__machine__create_kernel_maps(machine, kernel) < 0) | 555 | if (__machine__create_kernel_maps(machine, kernel) < 0) |
551 | goto out_problem; | 556 | goto out_problem; |
552 | 557 | ||
553 | event_set_kernel_mmap_len(machine->vmlinux_maps, self); | 558 | perf_event__set_kernel_mmap_len(event, machine->vmlinux_maps); |
554 | perf_session__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, | 559 | perf_session__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, |
555 | symbol_name, | 560 | symbol_name, |
556 | self->mmap.pgoff); | 561 | event->mmap.pgoff); |
557 | if (machine__is_default_guest(machine)) { | 562 | if (machine__is_default_guest(machine)) { |
558 | /* | 563 | /* |
559 | * preload dso of guest kernel and modules | 564 | * preload dso of guest kernel and modules |
@@ -567,22 +572,23 @@ out_problem: | |||
567 | return -1; | 572 | return -1; |
568 | } | 573 | } |
569 | 574 | ||
570 | int event__process_mmap(event_t *self, struct perf_sample *sample __used, | 575 | int perf_event__process_mmap(union perf_event *event, |
571 | struct perf_session *session) | 576 | struct perf_sample *sample __used, |
577 | struct perf_session *session) | ||
572 | { | 578 | { |
573 | struct machine *machine; | 579 | struct machine *machine; |
574 | struct thread *thread; | 580 | struct thread *thread; |
575 | struct map *map; | 581 | struct map *map; |
576 | u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 582 | u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
577 | int ret = 0; | 583 | int ret = 0; |
578 | 584 | ||
579 | dump_printf(" %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %s\n", | 585 | dump_printf(" %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %s\n", |
580 | self->mmap.pid, self->mmap.tid, self->mmap.start, | 586 | event->mmap.pid, event->mmap.tid, event->mmap.start, |
581 | self->mmap.len, self->mmap.pgoff, self->mmap.filename); | 587 | event->mmap.len, event->mmap.pgoff, event->mmap.filename); |
582 | 588 | ||
583 | if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL || | 589 | if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL || |
584 | cpumode == PERF_RECORD_MISC_KERNEL) { | 590 | cpumode == PERF_RECORD_MISC_KERNEL) { |
585 | ret = event__process_kernel_mmap(self, session); | 591 | ret = perf_event__process_kernel_mmap(event, session); |
586 | if (ret < 0) | 592 | if (ret < 0) |
587 | goto out_problem; | 593 | goto out_problem; |
588 | return 0; | 594 | return 0; |
@@ -591,12 +597,12 @@ int event__process_mmap(event_t *self, struct perf_sample *sample __used, | |||
591 | machine = perf_session__find_host_machine(session); | 597 | machine = perf_session__find_host_machine(session); |
592 | if (machine == NULL) | 598 | if (machine == NULL) |
593 | goto out_problem; | 599 | goto out_problem; |
594 | thread = perf_session__findnew(session, self->mmap.pid); | 600 | thread = perf_session__findnew(session, event->mmap.pid); |
595 | if (thread == NULL) | 601 | if (thread == NULL) |
596 | goto out_problem; | 602 | goto out_problem; |
597 | map = map__new(&machine->user_dsos, self->mmap.start, | 603 | map = map__new(&machine->user_dsos, event->mmap.start, |
598 | self->mmap.len, self->mmap.pgoff, | 604 | event->mmap.len, event->mmap.pgoff, |
599 | self->mmap.pid, self->mmap.filename, | 605 | event->mmap.pid, event->mmap.filename, |
600 | MAP__FUNCTION); | 606 | MAP__FUNCTION); |
601 | if (map == NULL) | 607 | if (map == NULL) |
602 | goto out_problem; | 608 | goto out_problem; |
@@ -609,16 +615,17 @@ out_problem: | |||
609 | return 0; | 615 | return 0; |
610 | } | 616 | } |
611 | 617 | ||
612 | int event__process_task(event_t *self, struct perf_sample *sample __used, | 618 | int perf_event__process_task(union perf_event *event, |
613 | struct perf_session *session) | 619 | struct perf_sample *sample __used, |
620 | struct perf_session *session) | ||
614 | { | 621 | { |
615 | struct thread *thread = perf_session__findnew(session, self->fork.tid); | 622 | struct thread *thread = perf_session__findnew(session, event->fork.tid); |
616 | struct thread *parent = perf_session__findnew(session, self->fork.ptid); | 623 | struct thread *parent = perf_session__findnew(session, event->fork.ptid); |
617 | 624 | ||
618 | dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid, | 625 | dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid, |
619 | self->fork.ppid, self->fork.ptid); | 626 | event->fork.ppid, event->fork.ptid); |
620 | 627 | ||
621 | if (self->header.type == PERF_RECORD_EXIT) { | 628 | if (event->header.type == PERF_RECORD_EXIT) { |
622 | perf_session__remove_thread(session, thread); | 629 | perf_session__remove_thread(session, thread); |
623 | return 0; | 630 | return 0; |
624 | } | 631 | } |
@@ -632,22 +639,22 @@ int event__process_task(event_t *self, struct perf_sample *sample __used, | |||
632 | return 0; | 639 | return 0; |
633 | } | 640 | } |
634 | 641 | ||
635 | int event__process(event_t *event, struct perf_sample *sample, | 642 | int perf_event__process(union perf_event *event, struct perf_sample *sample, |
636 | struct perf_session *session) | 643 | struct perf_session *session) |
637 | { | 644 | { |
638 | switch (event->header.type) { | 645 | switch (event->header.type) { |
639 | case PERF_RECORD_COMM: | 646 | case PERF_RECORD_COMM: |
640 | event__process_comm(event, sample, session); | 647 | perf_event__process_comm(event, sample, session); |
641 | break; | 648 | break; |
642 | case PERF_RECORD_MMAP: | 649 | case PERF_RECORD_MMAP: |
643 | event__process_mmap(event, sample, session); | 650 | perf_event__process_mmap(event, sample, session); |
644 | break; | 651 | break; |
645 | case PERF_RECORD_FORK: | 652 | case PERF_RECORD_FORK: |
646 | case PERF_RECORD_EXIT: | 653 | case PERF_RECORD_EXIT: |
647 | event__process_task(event, sample, session); | 654 | perf_event__process_task(event, sample, session); |
648 | break; | 655 | break; |
649 | case PERF_RECORD_LOST: | 656 | case PERF_RECORD_LOST: |
650 | event__process_lost(event, sample, session); | 657 | perf_event__process_lost(event, sample, session); |
651 | default: | 658 | default: |
652 | break; | 659 | break; |
653 | } | 660 | } |
@@ -756,12 +763,14 @@ static void dso__calc_col_width(struct dso *self, struct hists *hists) | |||
756 | self->slen_calculated = 1; | 763 | self->slen_calculated = 1; |
757 | } | 764 | } |
758 | 765 | ||
759 | int event__preprocess_sample(const event_t *self, struct perf_session *session, | 766 | int perf_event__preprocess_sample(const union perf_event *event, |
760 | struct addr_location *al, struct perf_sample *sample, | 767 | struct perf_session *session, |
761 | symbol_filter_t filter) | 768 | struct addr_location *al, |
769 | struct perf_sample *sample, | ||
770 | symbol_filter_t filter) | ||
762 | { | 771 | { |
763 | u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 772 | u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
764 | struct thread *thread = perf_session__findnew(session, self->ip.pid); | 773 | struct thread *thread = perf_session__findnew(session, event->ip.pid); |
765 | 774 | ||
766 | if (thread == NULL) | 775 | if (thread == NULL) |
767 | return -1; | 776 | return -1; |
@@ -783,7 +792,7 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session, | |||
783 | machine__create_kernel_maps(&session->host_machine); | 792 | machine__create_kernel_maps(&session->host_machine); |
784 | 793 | ||
785 | thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, | 794 | thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, |
786 | self->ip.pid, self->ip.ip, al); | 795 | event->ip.pid, event->ip.ip, al); |
787 | dump_printf(" ...... dso: %s\n", | 796 | dump_printf(" ...... dso: %s\n", |
788 | al->map ? al->map->dso->long_name : | 797 | al->map ? al->map->dso->long_name : |
789 | al->level == 'H' ? "[hypervisor]" : "<not found>"); | 798 | al->level == 'H' ? "[hypervisor]" : "<not found>"); |
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 84fd71ffd619..eecb42273d59 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -117,7 +117,7 @@ struct tracing_data_event { | |||
117 | u32 size; | 117 | u32 size; |
118 | }; | 118 | }; |
119 | 119 | ||
120 | typedef union event_union { | 120 | union perf_event { |
121 | struct perf_event_header header; | 121 | struct perf_event_header header; |
122 | struct ip_event ip; | 122 | struct ip_event ip; |
123 | struct mmap_event mmap; | 123 | struct mmap_event mmap; |
@@ -130,49 +130,52 @@ typedef union event_union { | |||
130 | struct event_type_event event_type; | 130 | struct event_type_event event_type; |
131 | struct tracing_data_event tracing_data; | 131 | struct tracing_data_event tracing_data; |
132 | struct build_id_event build_id; | 132 | struct build_id_event build_id; |
133 | } event_t; | 133 | }; |
134 | 134 | ||
135 | void event__print_totals(void); | 135 | void perf_event__print_totals(void); |
136 | 136 | ||
137 | struct perf_session; | 137 | struct perf_session; |
138 | 138 | ||
139 | typedef int (*event__handler_synth_t)(event_t *event, | 139 | typedef int (*perf_event__handler_synth_t)(union perf_event *event, |
140 | struct perf_session *session); | ||
141 | typedef int (*perf_event__handler_t)(union perf_event *event, | ||
142 | struct perf_sample *sample, | ||
140 | struct perf_session *session); | 143 | struct perf_session *session); |
141 | typedef int (*event__handler_t)(event_t *event, struct perf_sample *sample, | ||
142 | struct perf_session *session); | ||
143 | 144 | ||
144 | int event__synthesize_thread(pid_t pid, event__handler_t process, | 145 | int perf_event__synthesize_thread(pid_t pid, perf_event__handler_t process, |
146 | struct perf_session *session); | ||
147 | int perf_event__synthesize_threads(perf_event__handler_t process, | ||
148 | struct perf_session *session); | ||
149 | int perf_event__synthesize_kernel_mmap(perf_event__handler_t process, | ||
150 | struct perf_session *session, | ||
151 | struct machine *machine, | ||
152 | const char *symbol_name); | ||
153 | |||
154 | int perf_event__synthesize_modules(perf_event__handler_t process, | ||
155 | struct perf_session *session, | ||
156 | struct machine *machine); | ||
157 | |||
158 | int perf_event__process_comm(union perf_event *event, struct perf_sample *sample, | ||
145 | struct perf_session *session); | 159 | struct perf_session *session); |
146 | int event__synthesize_threads(event__handler_t process, | 160 | int perf_event__process_lost(union perf_event *event, struct perf_sample *sample, |
147 | struct perf_session *session); | 161 | struct perf_session *session); |
148 | int event__synthesize_kernel_mmap(event__handler_t process, | 162 | int perf_event__process_mmap(union perf_event *event, struct perf_sample *sample, |
149 | struct perf_session *session, | 163 | struct perf_session *session); |
150 | struct machine *machine, | 164 | int perf_event__process_task(union perf_event *event, struct perf_sample *sample, |
151 | const char *symbol_name); | 165 | struct perf_session *session); |
152 | 166 | int perf_event__process(union perf_event *event, struct perf_sample *sample, | |
153 | int event__synthesize_modules(event__handler_t process, | ||
154 | struct perf_session *session, | ||
155 | struct machine *machine); | ||
156 | |||
157 | int event__process_comm(event_t *event, struct perf_sample *sample, | ||
158 | struct perf_session *session); | ||
159 | int event__process_lost(event_t *event, struct perf_sample *sample, | ||
160 | struct perf_session *session); | ||
161 | int event__process_mmap(event_t *event, struct perf_sample *sample, | ||
162 | struct perf_session *session); | ||
163 | int event__process_task(event_t *event, struct perf_sample *sample, | ||
164 | struct perf_session *session); | 167 | struct perf_session *session); |
165 | int event__process(event_t *event, struct perf_sample *sample, | ||
166 | struct perf_session *session); | ||
167 | 168 | ||
168 | struct addr_location; | 169 | struct addr_location; |
169 | int event__preprocess_sample(const event_t *self, struct perf_session *session, | 170 | int perf_event__preprocess_sample(const union perf_event *self, |
170 | struct addr_location *al, struct perf_sample *sample, | 171 | struct perf_session *session, |
171 | symbol_filter_t filter); | 172 | struct addr_location *al, |
173 | struct perf_sample *sample, | ||
174 | symbol_filter_t filter); | ||
172 | 175 | ||
173 | const char *event__get_event_name(unsigned int id); | 176 | const char *perf_event__name(unsigned int id); |
174 | 177 | ||
175 | int event__parse_sample(const event_t *event, u64 type, bool sample_id_all, | 178 | int perf_event__parse_sample(const union perf_event *event, u64 type, |
176 | struct perf_sample *sample); | 179 | bool sample_id_all, struct perf_sample *sample); |
177 | 180 | ||
178 | #endif /* __PERF_RECORD_H */ | 181 | #endif /* __PERF_RECORD_H */ |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index b498eecbe850..917fc18d0bed 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -107,7 +107,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id) | |||
107 | return NULL; | 107 | return NULL; |
108 | } | 108 | } |
109 | 109 | ||
110 | event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) | 110 | union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) |
111 | { | 111 | { |
112 | /* XXX Move this to perf.c, making it generally available */ | 112 | /* XXX Move this to perf.c, making it generally available */ |
113 | unsigned int page_size = sysconf(_SC_PAGE_SIZE); | 113 | unsigned int page_size = sysconf(_SC_PAGE_SIZE); |
@@ -115,7 +115,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) | |||
115 | unsigned int head = perf_mmap__read_head(md); | 115 | unsigned int head = perf_mmap__read_head(md); |
116 | unsigned int old = md->prev; | 116 | unsigned int old = md->prev; |
117 | unsigned char *data = md->base + page_size; | 117 | unsigned char *data = md->base + page_size; |
118 | event_t *event = NULL; | 118 | union perf_event *event = NULL; |
119 | 119 | ||
120 | if (evlist->overwrite) { | 120 | if (evlist->overwrite) { |
121 | /* | 121 | /* |
@@ -140,7 +140,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) | |||
140 | if (old != head) { | 140 | if (old != head) { |
141 | size_t size; | 141 | size_t size; |
142 | 142 | ||
143 | event = (event_t *)&data[old & md->mask]; | 143 | event = (union perf_event *)&data[old & md->mask]; |
144 | size = event->header.size; | 144 | size = event->header.size; |
145 | 145 | ||
146 | /* | 146 | /* |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 2706ae40c8b3..022ae404b908 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -17,7 +17,7 @@ struct perf_evlist { | |||
17 | int nr_fds; | 17 | int nr_fds; |
18 | int mmap_len; | 18 | int mmap_len; |
19 | bool overwrite; | 19 | bool overwrite; |
20 | event_t event_copy; | 20 | union perf_event event_copy; |
21 | struct perf_mmap *mmap; | 21 | struct perf_mmap *mmap; |
22 | struct pollfd *pollfd; | 22 | struct pollfd *pollfd; |
23 | }; | 23 | }; |
@@ -37,6 +37,6 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd); | |||
37 | 37 | ||
38 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); | 38 | struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); |
39 | 39 | ||
40 | event_t *perf_evlist__read_on_cpu(struct perf_evlist *self, int cpu); | 40 | union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *self, int cpu); |
41 | 41 | ||
42 | #endif /* __PERF_EVLIST_H */ | 42 | #endif /* __PERF_EVLIST_H */ |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index a13488511880..fddeb08f48a7 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -367,8 +367,8 @@ out_unmap: | |||
367 | return -1; | 367 | return -1; |
368 | } | 368 | } |
369 | 369 | ||
370 | static int event__parse_id_sample(const event_t *event, u64 type, | 370 | static int perf_event__parse_id_sample(const union perf_event *event, u64 type, |
371 | struct perf_sample *sample) | 371 | struct perf_sample *sample) |
372 | { | 372 | { |
373 | const u64 *array = event->sample.array; | 373 | const u64 *array = event->sample.array; |
374 | 374 | ||
@@ -405,8 +405,8 @@ static int event__parse_id_sample(const event_t *event, u64 type, | |||
405 | return 0; | 405 | return 0; |
406 | } | 406 | } |
407 | 407 | ||
408 | int event__parse_sample(const event_t *event, u64 type, bool sample_id_all, | 408 | int perf_event__parse_sample(const union perf_event *event, u64 type, |
409 | struct perf_sample *data) | 409 | bool sample_id_all, struct perf_sample *data) |
410 | { | 410 | { |
411 | const u64 *array; | 411 | const u64 *array; |
412 | 412 | ||
@@ -416,7 +416,7 @@ int event__parse_sample(const event_t *event, u64 type, bool sample_id_all, | |||
416 | if (event->header.type != PERF_RECORD_SAMPLE) { | 416 | if (event->header.type != PERF_RECORD_SAMPLE) { |
417 | if (!sample_id_all) | 417 | if (!sample_id_all) |
418 | return 0; | 418 | return 0; |
419 | return event__parse_id_sample(event, type, data); | 419 | return perf_event__parse_id_sample(event, type, data); |
420 | } | 420 | } |
421 | 421 | ||
422 | array = event->sample.array; | 422 | array = event->sample.array; |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index f0138d472339..c0de5ec44145 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -1000,11 +1000,11 @@ perf_header__find_attr(u64 id, struct perf_header *header) | |||
1000 | return NULL; | 1000 | return NULL; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, | 1003 | int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, |
1004 | event__handler_t process, | 1004 | perf_event__handler_t process, |
1005 | struct perf_session *session) | 1005 | struct perf_session *session) |
1006 | { | 1006 | { |
1007 | event_t *ev; | 1007 | union perf_event *ev; |
1008 | size_t size; | 1008 | size_t size; |
1009 | int err; | 1009 | int err; |
1010 | 1010 | ||
@@ -1031,8 +1031,9 @@ int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, | |||
1031 | return err; | 1031 | return err; |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | int event__synthesize_attrs(struct perf_header *self, event__handler_t process, | 1034 | int perf_event__synthesize_attrs(struct perf_header *self, |
1035 | struct perf_session *session) | 1035 | perf_event__handler_t process, |
1036 | struct perf_session *session) | ||
1036 | { | 1037 | { |
1037 | struct perf_header_attr *attr; | 1038 | struct perf_header_attr *attr; |
1038 | int i, err = 0; | 1039 | int i, err = 0; |
@@ -1040,8 +1041,8 @@ int event__synthesize_attrs(struct perf_header *self, event__handler_t process, | |||
1040 | for (i = 0; i < self->attrs; i++) { | 1041 | for (i = 0; i < self->attrs; i++) { |
1041 | attr = self->attr[i]; | 1042 | attr = self->attr[i]; |
1042 | 1043 | ||
1043 | err = event__synthesize_attr(&attr->attr, attr->ids, attr->id, | 1044 | err = perf_event__synthesize_attr(&attr->attr, attr->ids, |
1044 | process, session); | 1045 | attr->id, process, session); |
1045 | if (err) { | 1046 | if (err) { |
1046 | pr_debug("failed to create perf header attribute\n"); | 1047 | pr_debug("failed to create perf header attribute\n"); |
1047 | return err; | 1048 | return err; |
@@ -1051,21 +1052,22 @@ int event__synthesize_attrs(struct perf_header *self, event__handler_t process, | |||
1051 | return err; | 1052 | return err; |
1052 | } | 1053 | } |
1053 | 1054 | ||
1054 | int event__process_attr(event_t *self, struct perf_session *session) | 1055 | int perf_event__process_attr(union perf_event *event, |
1056 | struct perf_session *session) | ||
1055 | { | 1057 | { |
1056 | struct perf_header_attr *attr; | 1058 | struct perf_header_attr *attr; |
1057 | unsigned int i, ids, n_ids; | 1059 | unsigned int i, ids, n_ids; |
1058 | 1060 | ||
1059 | attr = perf_header_attr__new(&self->attr.attr); | 1061 | attr = perf_header_attr__new(&event->attr.attr); |
1060 | if (attr == NULL) | 1062 | if (attr == NULL) |
1061 | return -ENOMEM; | 1063 | return -ENOMEM; |
1062 | 1064 | ||
1063 | ids = self->header.size; | 1065 | ids = event->header.size; |
1064 | ids -= (void *)&self->attr.id - (void *)self; | 1066 | ids -= (void *)&event->attr.id - (void *)event; |
1065 | n_ids = ids / sizeof(u64); | 1067 | n_ids = ids / sizeof(u64); |
1066 | 1068 | ||
1067 | for (i = 0; i < n_ids; i++) { | 1069 | for (i = 0; i < n_ids; i++) { |
1068 | if (perf_header_attr__add_id(attr, self->attr.id[i]) < 0) { | 1070 | if (perf_header_attr__add_id(attr, event->attr.id[i]) < 0) { |
1069 | perf_header_attr__delete(attr); | 1071 | perf_header_attr__delete(attr); |
1070 | return -ENOMEM; | 1072 | return -ENOMEM; |
1071 | } | 1073 | } |
@@ -1081,11 +1083,11 @@ int event__process_attr(event_t *self, struct perf_session *session) | |||
1081 | return 0; | 1083 | return 0; |
1082 | } | 1084 | } |
1083 | 1085 | ||
1084 | int event__synthesize_event_type(u64 event_id, char *name, | 1086 | int perf_event__synthesize_event_type(u64 event_id, char *name, |
1085 | event__handler_t process, | 1087 | perf_event__handler_t process, |
1086 | struct perf_session *session) | 1088 | struct perf_session *session) |
1087 | { | 1089 | { |
1088 | event_t ev; | 1090 | union perf_event ev; |
1089 | size_t size = 0; | 1091 | size_t size = 0; |
1090 | int err = 0; | 1092 | int err = 0; |
1091 | 1093 | ||
@@ -1106,8 +1108,8 @@ int event__synthesize_event_type(u64 event_id, char *name, | |||
1106 | return err; | 1108 | return err; |
1107 | } | 1109 | } |
1108 | 1110 | ||
1109 | int event__synthesize_event_types(event__handler_t process, | 1111 | int perf_event__synthesize_event_types(perf_event__handler_t process, |
1110 | struct perf_session *session) | 1112 | struct perf_session *session) |
1111 | { | 1113 | { |
1112 | struct perf_trace_event_type *type; | 1114 | struct perf_trace_event_type *type; |
1113 | int i, err = 0; | 1115 | int i, err = 0; |
@@ -1115,8 +1117,9 @@ int event__synthesize_event_types(event__handler_t process, | |||
1115 | for (i = 0; i < event_count; i++) { | 1117 | for (i = 0; i < event_count; i++) { |
1116 | type = &events[i]; | 1118 | type = &events[i]; |
1117 | 1119 | ||
1118 | err = event__synthesize_event_type(type->event_id, type->name, | 1120 | err = perf_event__synthesize_event_type(type->event_id, |
1119 | process, session); | 1121 | type->name, process, |
1122 | session); | ||
1120 | if (err) { | 1123 | if (err) { |
1121 | pr_debug("failed to create perf header event type\n"); | 1124 | pr_debug("failed to create perf header event type\n"); |
1122 | return err; | 1125 | return err; |
@@ -1126,21 +1129,21 @@ int event__synthesize_event_types(event__handler_t process, | |||
1126 | return err; | 1129 | return err; |
1127 | } | 1130 | } |
1128 | 1131 | ||
1129 | int event__process_event_type(event_t *self, | 1132 | int perf_event__process_event_type(union perf_event *event, |
1130 | struct perf_session *session __unused) | 1133 | struct perf_session *session __unused) |
1131 | { | 1134 | { |
1132 | if (perf_header__push_event(self->event_type.event_type.event_id, | 1135 | if (perf_header__push_event(event->event_type.event_type.event_id, |
1133 | self->event_type.event_type.name) < 0) | 1136 | event->event_type.event_type.name) < 0) |
1134 | return -ENOMEM; | 1137 | return -ENOMEM; |
1135 | 1138 | ||
1136 | return 0; | 1139 | return 0; |
1137 | } | 1140 | } |
1138 | 1141 | ||
1139 | int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, | 1142 | int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, |
1140 | event__handler_t process, | 1143 | perf_event__handler_t process, |
1141 | struct perf_session *session __unused) | 1144 | struct perf_session *session __unused) |
1142 | { | 1145 | { |
1143 | event_t ev; | 1146 | union perf_event ev; |
1144 | ssize_t size = 0, aligned_size = 0, padding; | 1147 | ssize_t size = 0, aligned_size = 0, padding; |
1145 | int err = 0; | 1148 | int err = 0; |
1146 | 1149 | ||
@@ -1163,10 +1166,10 @@ int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, | |||
1163 | return aligned_size; | 1166 | return aligned_size; |
1164 | } | 1167 | } |
1165 | 1168 | ||
1166 | int event__process_tracing_data(event_t *self, | 1169 | int perf_event__process_tracing_data(union perf_event *event, |
1167 | struct perf_session *session) | 1170 | struct perf_session *session) |
1168 | { | 1171 | { |
1169 | ssize_t size_read, padding, size = self->tracing_data.size; | 1172 | ssize_t size_read, padding, size = event->tracing_data.size; |
1170 | off_t offset = lseek(session->fd, 0, SEEK_CUR); | 1173 | off_t offset = lseek(session->fd, 0, SEEK_CUR); |
1171 | char buf[BUFSIZ]; | 1174 | char buf[BUFSIZ]; |
1172 | 1175 | ||
@@ -1192,12 +1195,12 @@ int event__process_tracing_data(event_t *self, | |||
1192 | return size_read + padding; | 1195 | return size_read + padding; |
1193 | } | 1196 | } |
1194 | 1197 | ||
1195 | int event__synthesize_build_id(struct dso *pos, u16 misc, | 1198 | int perf_event__synthesize_build_id(struct dso *pos, u16 misc, |
1196 | event__handler_t process, | 1199 | perf_event__handler_t process, |
1197 | struct machine *machine, | 1200 | struct machine *machine, |
1198 | struct perf_session *session) | 1201 | struct perf_session *session) |
1199 | { | 1202 | { |
1200 | event_t ev; | 1203 | union perf_event ev; |
1201 | size_t len; | 1204 | size_t len; |
1202 | int err = 0; | 1205 | int err = 0; |
1203 | 1206 | ||
@@ -1220,11 +1223,11 @@ int event__synthesize_build_id(struct dso *pos, u16 misc, | |||
1220 | return err; | 1223 | return err; |
1221 | } | 1224 | } |
1222 | 1225 | ||
1223 | int event__process_build_id(event_t *self, | 1226 | int perf_event__process_build_id(union perf_event *event, |
1224 | struct perf_session *session) | 1227 | struct perf_session *session) |
1225 | { | 1228 | { |
1226 | __event_process_build_id(&self->build_id, | 1229 | __event_process_build_id(&event->build_id, |
1227 | self->build_id.filename, | 1230 | event->build_id.filename, |
1228 | session); | 1231 | session); |
1229 | return 0; | 1232 | return 0; |
1230 | } | 1233 | } |
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index 65afd7f74e0d..f042cebcec1e 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h | |||
@@ -100,32 +100,32 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | |||
100 | const char *name, bool is_kallsyms); | 100 | const char *name, bool is_kallsyms); |
101 | int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir); | 101 | int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir); |
102 | 102 | ||
103 | int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, | 103 | int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, |
104 | event__handler_t process, | 104 | perf_event__handler_t process, |
105 | struct perf_session *session); | 105 | struct perf_session *session); |
106 | int event__synthesize_attrs(struct perf_header *self, | 106 | int perf_event__synthesize_attrs(struct perf_header *self, |
107 | event__handler_t process, | 107 | perf_event__handler_t process, |
108 | struct perf_session *session); | ||
109 | int event__process_attr(event_t *self, struct perf_session *session); | ||
110 | |||
111 | int event__synthesize_event_type(u64 event_id, char *name, | ||
112 | event__handler_t process, | ||
113 | struct perf_session *session); | 108 | struct perf_session *session); |
114 | int event__synthesize_event_types(event__handler_t process, | 109 | int perf_event__process_attr(union perf_event *event, struct perf_session *session); |
115 | struct perf_session *session); | 110 | |
116 | int event__process_event_type(event_t *self, | 111 | int perf_event__synthesize_event_type(u64 event_id, char *name, |
117 | struct perf_session *session); | 112 | perf_event__handler_t process, |
118 | 113 | struct perf_session *session); | |
119 | int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, | 114 | int perf_event__synthesize_event_types(perf_event__handler_t process, |
120 | event__handler_t process, | 115 | struct perf_session *session); |
116 | int perf_event__process_event_type(union perf_event *event, | ||
121 | struct perf_session *session); | 117 | struct perf_session *session); |
122 | int event__process_tracing_data(event_t *self, | ||
123 | struct perf_session *session); | ||
124 | |||
125 | int event__synthesize_build_id(struct dso *pos, u16 misc, | ||
126 | event__handler_t process, | ||
127 | struct machine *machine, | ||
128 | struct perf_session *session); | ||
129 | int event__process_build_id(event_t *self, struct perf_session *session); | ||
130 | 118 | ||
119 | int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, | ||
120 | perf_event__handler_t process, | ||
121 | struct perf_session *session); | ||
122 | int perf_event__process_tracing_data(union perf_event *event, | ||
123 | struct perf_session *session); | ||
124 | |||
125 | int perf_event__synthesize_build_id(struct dso *pos, u16 misc, | ||
126 | perf_event__handler_t process, | ||
127 | struct machine *machine, | ||
128 | struct perf_session *session); | ||
129 | int perf_event__process_build_id(union perf_event *event, | ||
130 | struct perf_session *session); | ||
131 | #endif /* __PERF_HEADER_H */ | 131 | #endif /* __PERF_HEADER_H */ |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 02ed318d7312..95887804dc8e 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -1182,7 +1182,7 @@ size_t hists__fprintf_nr_events(struct hists *self, FILE *fp) | |||
1182 | size_t ret = 0; | 1182 | size_t ret = 0; |
1183 | 1183 | ||
1184 | for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) { | 1184 | for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) { |
1185 | const char *name = event__get_event_name(i); | 1185 | const char *name = perf_event__name(i); |
1186 | 1186 | ||
1187 | if (!strcmp(name, "UNKNOWN")) | 1187 | if (!strcmp(name, "UNKNOWN")) |
1188 | continue; | 1188 | continue; |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index ee0b61102571..a3a871f7bda3 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -165,7 +165,7 @@ struct perf_session *perf_session__new(const char *filename, int mode, | |||
165 | } else if (mode == O_WRONLY) { | 165 | } else if (mode == O_WRONLY) { |
166 | /* | 166 | /* |
167 | * In O_RDONLY mode this will be performed when reading the | 167 | * In O_RDONLY mode this will be performed when reading the |
168 | * kernel MMAP event, in event__process_mmap(). | 168 | * kernel MMAP event, in perf_event__process_mmap(). |
169 | */ | 169 | */ |
170 | if (perf_session__create_kernel_maps(self) < 0) | 170 | if (perf_session__create_kernel_maps(self) < 0) |
171 | goto out_delete; | 171 | goto out_delete; |
@@ -291,14 +291,14 @@ int perf_session__resolve_callchain(struct perf_session *self, | |||
291 | return 0; | 291 | return 0; |
292 | } | 292 | } |
293 | 293 | ||
294 | static int process_event_synth_stub(event_t *event __used, | 294 | static int process_event_synth_stub(union perf_event *event __used, |
295 | struct perf_session *session __used) | 295 | struct perf_session *session __used) |
296 | { | 296 | { |
297 | dump_printf(": unhandled!\n"); | 297 | dump_printf(": unhandled!\n"); |
298 | return 0; | 298 | return 0; |
299 | } | 299 | } |
300 | 300 | ||
301 | static int process_event_stub(event_t *event __used, | 301 | static int process_event_stub(union perf_event *event __used, |
302 | struct perf_sample *sample __used, | 302 | struct perf_sample *sample __used, |
303 | struct perf_session *session __used) | 303 | struct perf_session *session __used) |
304 | { | 304 | { |
@@ -306,7 +306,7 @@ static int process_event_stub(event_t *event __used, | |||
306 | return 0; | 306 | return 0; |
307 | } | 307 | } |
308 | 308 | ||
309 | static int process_finished_round_stub(event_t *event __used, | 309 | static int process_finished_round_stub(union perf_event *event __used, |
310 | struct perf_session *session __used, | 310 | struct perf_session *session __used, |
311 | struct perf_event_ops *ops __used) | 311 | struct perf_event_ops *ops __used) |
312 | { | 312 | { |
@@ -314,7 +314,7 @@ static int process_finished_round_stub(event_t *event __used, | |||
314 | return 0; | 314 | return 0; |
315 | } | 315 | } |
316 | 316 | ||
317 | static int process_finished_round(event_t *event, | 317 | static int process_finished_round(union perf_event *event, |
318 | struct perf_session *session, | 318 | struct perf_session *session, |
319 | struct perf_event_ops *ops); | 319 | struct perf_event_ops *ops); |
320 | 320 | ||
@@ -331,7 +331,7 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler) | |||
331 | if (handler->exit == NULL) | 331 | if (handler->exit == NULL) |
332 | handler->exit = process_event_stub; | 332 | handler->exit = process_event_stub; |
333 | if (handler->lost == NULL) | 333 | if (handler->lost == NULL) |
334 | handler->lost = event__process_lost; | 334 | handler->lost = perf_event__process_lost; |
335 | if (handler->read == NULL) | 335 | if (handler->read == NULL) |
336 | handler->read = process_event_stub; | 336 | handler->read = process_event_stub; |
337 | if (handler->throttle == NULL) | 337 | if (handler->throttle == NULL) |
@@ -365,98 +365,98 @@ void mem_bswap_64(void *src, int byte_size) | |||
365 | } | 365 | } |
366 | } | 366 | } |
367 | 367 | ||
368 | static void event__all64_swap(event_t *self) | 368 | static void perf_event__all64_swap(union perf_event *event) |
369 | { | 369 | { |
370 | struct perf_event_header *hdr = &self->header; | 370 | struct perf_event_header *hdr = &event->header; |
371 | mem_bswap_64(hdr + 1, self->header.size - sizeof(*hdr)); | 371 | mem_bswap_64(hdr + 1, event->header.size - sizeof(*hdr)); |
372 | } | 372 | } |
373 | 373 | ||
374 | static void event__comm_swap(event_t *self) | 374 | static void perf_event__comm_swap(union perf_event *event) |
375 | { | 375 | { |
376 | self->comm.pid = bswap_32(self->comm.pid); | 376 | event->comm.pid = bswap_32(event->comm.pid); |
377 | self->comm.tid = bswap_32(self->comm.tid); | 377 | event->comm.tid = bswap_32(event->comm.tid); |
378 | } | 378 | } |
379 | 379 | ||
380 | static void event__mmap_swap(event_t *self) | 380 | static void perf_event__mmap_swap(union perf_event *event) |
381 | { | 381 | { |
382 | self->mmap.pid = bswap_32(self->mmap.pid); | 382 | event->mmap.pid = bswap_32(event->mmap.pid); |
383 | self->mmap.tid = bswap_32(self->mmap.tid); | 383 | event->mmap.tid = bswap_32(event->mmap.tid); |
384 | self->mmap.start = bswap_64(self->mmap.start); | 384 | event->mmap.start = bswap_64(event->mmap.start); |
385 | self->mmap.len = bswap_64(self->mmap.len); | 385 | event->mmap.len = bswap_64(event->mmap.len); |
386 | self->mmap.pgoff = bswap_64(self->mmap.pgoff); | 386 | event->mmap.pgoff = bswap_64(event->mmap.pgoff); |
387 | } | 387 | } |
388 | 388 | ||
389 | static void event__task_swap(event_t *self) | 389 | static void perf_event__task_swap(union perf_event *event) |
390 | { | 390 | { |
391 | self->fork.pid = bswap_32(self->fork.pid); | 391 | event->fork.pid = bswap_32(event->fork.pid); |
392 | self->fork.tid = bswap_32(self->fork.tid); | 392 | event->fork.tid = bswap_32(event->fork.tid); |
393 | self->fork.ppid = bswap_32(self->fork.ppid); | 393 | event->fork.ppid = bswap_32(event->fork.ppid); |
394 | self->fork.ptid = bswap_32(self->fork.ptid); | 394 | event->fork.ptid = bswap_32(event->fork.ptid); |
395 | self->fork.time = bswap_64(self->fork.time); | 395 | event->fork.time = bswap_64(event->fork.time); |
396 | } | 396 | } |
397 | 397 | ||
398 | static void event__read_swap(event_t *self) | 398 | static void perf_event__read_swap(union perf_event *event) |
399 | { | 399 | { |
400 | self->read.pid = bswap_32(self->read.pid); | 400 | event->read.pid = bswap_32(event->read.pid); |
401 | self->read.tid = bswap_32(self->read.tid); | 401 | event->read.tid = bswap_32(event->read.tid); |
402 | self->read.value = bswap_64(self->read.value); | 402 | event->read.value = bswap_64(event->read.value); |
403 | self->read.time_enabled = bswap_64(self->read.time_enabled); | 403 | event->read.time_enabled = bswap_64(event->read.time_enabled); |
404 | self->read.time_running = bswap_64(self->read.time_running); | 404 | event->read.time_running = bswap_64(event->read.time_running); |
405 | self->read.id = bswap_64(self->read.id); | 405 | event->read.id = bswap_64(event->read.id); |
406 | } | 406 | } |
407 | 407 | ||
408 | static void event__attr_swap(event_t *self) | 408 | static void perf_event__attr_swap(union perf_event *event) |
409 | { | 409 | { |
410 | size_t size; | 410 | size_t size; |
411 | 411 | ||
412 | self->attr.attr.type = bswap_32(self->attr.attr.type); | 412 | event->attr.attr.type = bswap_32(event->attr.attr.type); |
413 | self->attr.attr.size = bswap_32(self->attr.attr.size); | 413 | event->attr.attr.size = bswap_32(event->attr.attr.size); |
414 | self->attr.attr.config = bswap_64(self->attr.attr.config); | 414 | event->attr.attr.config = bswap_64(event->attr.attr.config); |
415 | self->attr.attr.sample_period = bswap_64(self->attr.attr.sample_period); | 415 | event->attr.attr.sample_period = bswap_64(event->attr.attr.sample_period); |
416 | self->attr.attr.sample_type = bswap_64(self->attr.attr.sample_type); | 416 | event->attr.attr.sample_type = bswap_64(event->attr.attr.sample_type); |
417 | self->attr.attr.read_format = bswap_64(self->attr.attr.read_format); | 417 | event->attr.attr.read_format = bswap_64(event->attr.attr.read_format); |
418 | self->attr.attr.wakeup_events = bswap_32(self->attr.attr.wakeup_events); | 418 | event->attr.attr.wakeup_events = bswap_32(event->attr.attr.wakeup_events); |
419 | self->attr.attr.bp_type = bswap_32(self->attr.attr.bp_type); | 419 | event->attr.attr.bp_type = bswap_32(event->attr.attr.bp_type); |
420 | self->attr.attr.bp_addr = bswap_64(self->attr.attr.bp_addr); | 420 | event->attr.attr.bp_addr = bswap_64(event->attr.attr.bp_addr); |
421 | self->attr.attr.bp_len = bswap_64(self->attr.attr.bp_len); | 421 | event->attr.attr.bp_len = bswap_64(event->attr.attr.bp_len); |
422 | 422 | ||
423 | size = self->header.size; | 423 | size = event->header.size; |
424 | size -= (void *)&self->attr.id - (void *)self; | 424 | size -= (void *)&event->attr.id - (void *)event; |
425 | mem_bswap_64(self->attr.id, size); | 425 | mem_bswap_64(event->attr.id, size); |
426 | } | 426 | } |
427 | 427 | ||
428 | static void event__event_type_swap(event_t *self) | 428 | static void perf_event__event_type_swap(union perf_event *event) |
429 | { | 429 | { |
430 | self->event_type.event_type.event_id = | 430 | event->event_type.event_type.event_id = |
431 | bswap_64(self->event_type.event_type.event_id); | 431 | bswap_64(event->event_type.event_type.event_id); |
432 | } | 432 | } |
433 | 433 | ||
434 | static void event__tracing_data_swap(event_t *self) | 434 | static void perf_event__tracing_data_swap(union perf_event *event) |
435 | { | 435 | { |
436 | self->tracing_data.size = bswap_32(self->tracing_data.size); | 436 | event->tracing_data.size = bswap_32(event->tracing_data.size); |
437 | } | 437 | } |
438 | 438 | ||
439 | typedef void (*event__swap_op)(event_t *self); | 439 | typedef void (*perf_event__swap_op)(union perf_event *event); |
440 | 440 | ||
441 | static event__swap_op event__swap_ops[] = { | 441 | static perf_event__swap_op perf_event__swap_ops[] = { |
442 | [PERF_RECORD_MMAP] = event__mmap_swap, | 442 | [PERF_RECORD_MMAP] = perf_event__mmap_swap, |
443 | [PERF_RECORD_COMM] = event__comm_swap, | 443 | [PERF_RECORD_COMM] = perf_event__comm_swap, |
444 | [PERF_RECORD_FORK] = event__task_swap, | 444 | [PERF_RECORD_FORK] = perf_event__task_swap, |
445 | [PERF_RECORD_EXIT] = event__task_swap, | 445 | [PERF_RECORD_EXIT] = perf_event__task_swap, |
446 | [PERF_RECORD_LOST] = event__all64_swap, | 446 | [PERF_RECORD_LOST] = perf_event__all64_swap, |
447 | [PERF_RECORD_READ] = event__read_swap, | 447 | [PERF_RECORD_READ] = perf_event__read_swap, |
448 | [PERF_RECORD_SAMPLE] = event__all64_swap, | 448 | [PERF_RECORD_SAMPLE] = perf_event__all64_swap, |
449 | [PERF_RECORD_HEADER_ATTR] = event__attr_swap, | 449 | [PERF_RECORD_HEADER_ATTR] = perf_event__attr_swap, |
450 | [PERF_RECORD_HEADER_EVENT_TYPE] = event__event_type_swap, | 450 | [PERF_RECORD_HEADER_EVENT_TYPE] = perf_event__event_type_swap, |
451 | [PERF_RECORD_HEADER_TRACING_DATA] = event__tracing_data_swap, | 451 | [PERF_RECORD_HEADER_TRACING_DATA] = perf_event__tracing_data_swap, |
452 | [PERF_RECORD_HEADER_BUILD_ID] = NULL, | 452 | [PERF_RECORD_HEADER_BUILD_ID] = NULL, |
453 | [PERF_RECORD_HEADER_MAX] = NULL, | 453 | [PERF_RECORD_HEADER_MAX] = NULL, |
454 | }; | 454 | }; |
455 | 455 | ||
456 | struct sample_queue { | 456 | struct sample_queue { |
457 | u64 timestamp; | 457 | u64 timestamp; |
458 | u64 file_offset; | 458 | u64 file_offset; |
459 | event_t *event; | 459 | union perf_event *event; |
460 | struct list_head list; | 460 | struct list_head list; |
461 | }; | 461 | }; |
462 | 462 | ||
@@ -474,7 +474,7 @@ static void perf_session_free_sample_buffers(struct perf_session *session) | |||
474 | } | 474 | } |
475 | 475 | ||
476 | static int perf_session_deliver_event(struct perf_session *session, | 476 | static int perf_session_deliver_event(struct perf_session *session, |
477 | event_t *event, | 477 | union perf_event *event, |
478 | struct perf_sample *sample, | 478 | struct perf_sample *sample, |
479 | struct perf_event_ops *ops, | 479 | struct perf_event_ops *ops, |
480 | u64 file_offset); | 480 | u64 file_offset); |
@@ -552,7 +552,7 @@ static void flush_sample_queue(struct perf_session *s, | |||
552 | * Flush every events below timestamp 7 | 552 | * Flush every events below timestamp 7 |
553 | * etc... | 553 | * etc... |
554 | */ | 554 | */ |
555 | static int process_finished_round(event_t *event __used, | 555 | static int process_finished_round(union perf_event *event __used, |
556 | struct perf_session *session, | 556 | struct perf_session *session, |
557 | struct perf_event_ops *ops) | 557 | struct perf_event_ops *ops) |
558 | { | 558 | { |
@@ -609,7 +609,7 @@ static void __queue_event(struct sample_queue *new, struct perf_session *s) | |||
609 | 609 | ||
610 | #define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct sample_queue)) | 610 | #define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct sample_queue)) |
611 | 611 | ||
612 | static int perf_session_queue_event(struct perf_session *s, event_t *event, | 612 | static int perf_session_queue_event(struct perf_session *s, union perf_event *event, |
613 | struct perf_sample *sample, u64 file_offset) | 613 | struct perf_sample *sample, u64 file_offset) |
614 | { | 614 | { |
615 | struct ordered_samples *os = &s->ordered_samples; | 615 | struct ordered_samples *os = &s->ordered_samples; |
@@ -662,7 +662,7 @@ static void callchain__printf(struct perf_sample *sample) | |||
662 | } | 662 | } |
663 | 663 | ||
664 | static void perf_session__print_tstamp(struct perf_session *session, | 664 | static void perf_session__print_tstamp(struct perf_session *session, |
665 | event_t *event, | 665 | union perf_event *event, |
666 | struct perf_sample *sample) | 666 | struct perf_sample *sample) |
667 | { | 667 | { |
668 | if (event->header.type != PERF_RECORD_SAMPLE && | 668 | if (event->header.type != PERF_RECORD_SAMPLE && |
@@ -678,7 +678,7 @@ static void perf_session__print_tstamp(struct perf_session *session, | |||
678 | printf("%" PRIu64 " ", sample->time); | 678 | printf("%" PRIu64 " ", sample->time); |
679 | } | 679 | } |
680 | 680 | ||
681 | static void dump_event(struct perf_session *session, event_t *event, | 681 | static void dump_event(struct perf_session *session, union perf_event *event, |
682 | u64 file_offset, struct perf_sample *sample) | 682 | u64 file_offset, struct perf_sample *sample) |
683 | { | 683 | { |
684 | if (!dump_trace) | 684 | if (!dump_trace) |
@@ -693,10 +693,10 @@ static void dump_event(struct perf_session *session, event_t *event, | |||
693 | perf_session__print_tstamp(session, event, sample); | 693 | perf_session__print_tstamp(session, event, sample); |
694 | 694 | ||
695 | printf("%#" PRIx64 " [%#x]: PERF_RECORD_%s", file_offset, | 695 | printf("%#" PRIx64 " [%#x]: PERF_RECORD_%s", file_offset, |
696 | event->header.size, event__get_event_name(event->header.type)); | 696 | event->header.size, perf_event__name(event->header.type)); |
697 | } | 697 | } |
698 | 698 | ||
699 | static void dump_sample(struct perf_session *session, event_t *event, | 699 | static void dump_sample(struct perf_session *session, union perf_event *event, |
700 | struct perf_sample *sample) | 700 | struct perf_sample *sample) |
701 | { | 701 | { |
702 | if (!dump_trace) | 702 | if (!dump_trace) |
@@ -711,7 +711,7 @@ static void dump_sample(struct perf_session *session, event_t *event, | |||
711 | } | 711 | } |
712 | 712 | ||
713 | static int perf_session_deliver_event(struct perf_session *session, | 713 | static int perf_session_deliver_event(struct perf_session *session, |
714 | event_t *event, | 714 | union perf_event *event, |
715 | struct perf_sample *sample, | 715 | struct perf_sample *sample, |
716 | struct perf_event_ops *ops, | 716 | struct perf_event_ops *ops, |
717 | u64 file_offset) | 717 | u64 file_offset) |
@@ -745,7 +745,7 @@ static int perf_session_deliver_event(struct perf_session *session, | |||
745 | } | 745 | } |
746 | 746 | ||
747 | static int perf_session__preprocess_sample(struct perf_session *session, | 747 | static int perf_session__preprocess_sample(struct perf_session *session, |
748 | event_t *event, struct perf_sample *sample) | 748 | union perf_event *event, struct perf_sample *sample) |
749 | { | 749 | { |
750 | if (event->header.type != PERF_RECORD_SAMPLE || | 750 | if (event->header.type != PERF_RECORD_SAMPLE || |
751 | !(session->sample_type & PERF_SAMPLE_CALLCHAIN)) | 751 | !(session->sample_type & PERF_SAMPLE_CALLCHAIN)) |
@@ -760,7 +760,7 @@ static int perf_session__preprocess_sample(struct perf_session *session, | |||
760 | return 0; | 760 | return 0; |
761 | } | 761 | } |
762 | 762 | ||
763 | static int perf_session__process_user_event(struct perf_session *session, event_t *event, | 763 | static int perf_session__process_user_event(struct perf_session *session, union perf_event *event, |
764 | struct perf_event_ops *ops, u64 file_offset) | 764 | struct perf_event_ops *ops, u64 file_offset) |
765 | { | 765 | { |
766 | dump_event(session, event, file_offset, NULL); | 766 | dump_event(session, event, file_offset, NULL); |
@@ -785,15 +785,16 @@ static int perf_session__process_user_event(struct perf_session *session, event_ | |||
785 | } | 785 | } |
786 | 786 | ||
787 | static int perf_session__process_event(struct perf_session *session, | 787 | static int perf_session__process_event(struct perf_session *session, |
788 | event_t *event, | 788 | union perf_event *event, |
789 | struct perf_event_ops *ops, | 789 | struct perf_event_ops *ops, |
790 | u64 file_offset) | 790 | u64 file_offset) |
791 | { | 791 | { |
792 | struct perf_sample sample; | 792 | struct perf_sample sample; |
793 | int ret; | 793 | int ret; |
794 | 794 | ||
795 | if (session->header.needs_swap && event__swap_ops[event->header.type]) | 795 | if (session->header.needs_swap && |
796 | event__swap_ops[event->header.type](event); | 796 | perf_event__swap_ops[event->header.type]) |
797 | perf_event__swap_ops[event->header.type](event); | ||
797 | 798 | ||
798 | if (event->header.type >= PERF_RECORD_HEADER_MAX) | 799 | if (event->header.type >= PERF_RECORD_HEADER_MAX) |
799 | return -EINVAL; | 800 | return -EINVAL; |
@@ -845,7 +846,7 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se | |||
845 | static void perf_session__warn_about_errors(const struct perf_session *session, | 846 | static void perf_session__warn_about_errors(const struct perf_session *session, |
846 | const struct perf_event_ops *ops) | 847 | const struct perf_event_ops *ops) |
847 | { | 848 | { |
848 | if (ops->lost == event__process_lost && | 849 | if (ops->lost == perf_event__process_lost && |
849 | session->hists.stats.total_lost != 0) { | 850 | session->hists.stats.total_lost != 0) { |
850 | ui__warning("Processed %" PRIu64 " events and LOST %" PRIu64 | 851 | ui__warning("Processed %" PRIu64 " events and LOST %" PRIu64 |
851 | "!\n\nCheck IO/CPU overload!\n\n", | 852 | "!\n\nCheck IO/CPU overload!\n\n", |
@@ -877,7 +878,7 @@ volatile int session_done; | |||
877 | static int __perf_session__process_pipe_events(struct perf_session *self, | 878 | static int __perf_session__process_pipe_events(struct perf_session *self, |
878 | struct perf_event_ops *ops) | 879 | struct perf_event_ops *ops) |
879 | { | 880 | { |
880 | event_t event; | 881 | union perf_event event; |
881 | uint32_t size; | 882 | uint32_t size; |
882 | int skip = 0; | 883 | int skip = 0; |
883 | u64 head; | 884 | u64 head; |
@@ -958,7 +959,7 @@ int __perf_session__process_events(struct perf_session *session, | |||
958 | struct ui_progress *progress; | 959 | struct ui_progress *progress; |
959 | size_t page_size, mmap_size; | 960 | size_t page_size, mmap_size; |
960 | char *buf, *mmaps[8]; | 961 | char *buf, *mmaps[8]; |
961 | event_t *event; | 962 | union perf_event *event; |
962 | uint32_t size; | 963 | uint32_t size; |
963 | 964 | ||
964 | perf_event_ops__fill_defaults(ops); | 965 | perf_event_ops__fill_defaults(ops); |
@@ -1003,7 +1004,7 @@ remap: | |||
1003 | file_pos = file_offset + head; | 1004 | file_pos = file_offset + head; |
1004 | 1005 | ||
1005 | more: | 1006 | more: |
1006 | event = (event_t *)(buf + head); | 1007 | event = (union perf_event *)(buf + head); |
1007 | 1008 | ||
1008 | if (session->header.needs_swap) | 1009 | if (session->header.needs_swap) |
1009 | perf_event_header__bswap(&event->header); | 1010 | perf_event_header__bswap(&event->header); |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 365bf533a396..977b3a1b14aa 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -57,10 +57,11 @@ struct perf_session { | |||
57 | 57 | ||
58 | struct perf_event_ops; | 58 | struct perf_event_ops; |
59 | 59 | ||
60 | typedef int (*event_op)(event_t *self, struct perf_sample *sample, | 60 | typedef int (*event_op)(union perf_event *self, struct perf_sample *sample, |
61 | struct perf_session *session); | 61 | struct perf_session *session); |
62 | typedef int (*event_synth_op)(event_t *self, struct perf_session *session); | 62 | typedef int (*event_synth_op)(union perf_event *self, |
63 | typedef int (*event_op2)(event_t *self, struct perf_session *session, | 63 | struct perf_session *session); |
64 | typedef int (*event_op2)(union perf_event *self, struct perf_session *session, | ||
64 | struct perf_event_ops *ops); | 65 | struct perf_event_ops *ops); |
65 | 66 | ||
66 | struct perf_event_ops { | 67 | struct perf_event_ops { |
@@ -157,11 +158,11 @@ size_t perf_session__fprintf_nr_events(struct perf_session *self, FILE *fp) | |||
157 | } | 158 | } |
158 | 159 | ||
159 | static inline int perf_session__parse_sample(struct perf_session *session, | 160 | static inline int perf_session__parse_sample(struct perf_session *session, |
160 | const event_t *event, | 161 | const union perf_event *event, |
161 | struct perf_sample *sample) | 162 | struct perf_sample *sample) |
162 | { | 163 | { |
163 | return event__parse_sample(event, session->sample_type, | 164 | return perf_event__parse_sample(event, session->sample_type, |
164 | session->sample_id_all, sample); | 165 | session->sample_id_all, sample); |
165 | } | 166 | } |
166 | 167 | ||
167 | #endif /* __PERF_SESSION_H */ | 168 | #endif /* __PERF_SESSION_H */ |