From d20deb64e0490ee9442b5181bc08a62d2cadcb90 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 25 Nov 2011 08:19:45 -0200 Subject: perf tools: Pass tool context in the the perf_event_ops functions So that we don't need to have that many globals. Next steps will remove the 'session' pointer, that in most cases is not needed. Then we can rename perf_event_ops to 'perf_tool' that better describes this class hierarchy. Cc: David Ahern Cc: Frederic Weisbecker Cc: Mike Galbraith Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-wp4djox7x6w1i2bab1pt4xxp@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/build-id.c | 7 +++-- tools/perf/util/callchain.h | 3 +++ tools/perf/util/event.c | 66 ++++++++++++++++++++++++++------------------- tools/perf/util/event.h | 38 +++++++++++++++++--------- tools/perf/util/header.c | 36 +++++++++++++++---------- tools/perf/util/header.h | 27 ++++++++++++------- tools/perf/util/session.c | 60 ++++++++++++++++++++++++----------------- tools/perf/util/session.h | 23 +++++++++------- tools/perf/util/top.h | 3 ++- 9 files changed, 163 insertions(+), 100 deletions(-) (limited to 'tools/perf/util') diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index f2fe6ec..0e4de18 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -13,8 +13,10 @@ #include "symbol.h" #include #include "debug.h" +#include "session.h" -static int build_id__mark_dso_hit(union perf_event *event, +static int build_id__mark_dso_hit(struct perf_event_ops *ops __used, + union perf_event *event, struct perf_sample *sample __used, struct perf_evsel *evsel __used, struct perf_session *session) @@ -38,7 +40,8 @@ static int build_id__mark_dso_hit(union perf_event *event, return 0; } -static int perf_event__exit_del_thread(union perf_event *event, +static int perf_event__exit_del_thread(struct perf_event_ops *ops __used, + union perf_event *event, struct perf_sample *sample __used, struct perf_session *session) { diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 9b4ff16c..7f9c0f1 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h @@ -101,6 +101,9 @@ int callchain_append(struct callchain_root *root, int callchain_merge(struct callchain_cursor *cursor, struct callchain_root *dst, struct callchain_root *src); +struct ip_callchain; +union perf_event; + bool ip_callchain__valid(struct ip_callchain *chain, const union perf_event *event); /* diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 437f8ca..4800f38 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -44,7 +44,8 @@ static struct perf_sample synth_sample = { .period = 1, }; -static pid_t perf_event__synthesize_comm(union perf_event *event, pid_t pid, +static pid_t perf_event__synthesize_comm(struct perf_event_ops *ops, + union perf_event *event, pid_t pid, int full, perf_event__handler_t process, struct perf_session *session) { @@ -99,7 +100,7 @@ out_race: if (!full) { event->comm.tid = pid; - process(event, &synth_sample, session); + process(ops, event, &synth_sample, session); goto out; } @@ -117,7 +118,7 @@ out_race: event->comm.tid = pid; - process(event, &synth_sample, session); + process(ops, event, &synth_sample, session); } closedir(tasks); @@ -127,7 +128,8 @@ out: return tgid; } -static int perf_event__synthesize_mmap_events(union perf_event *event, +static int perf_event__synthesize_mmap_events(struct perf_event_ops *ops, + union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct perf_session *session) @@ -198,7 +200,7 @@ static int perf_event__synthesize_mmap_events(union perf_event *event, event->mmap.pid = tgid; event->mmap.tid = pid; - process(event, &synth_sample, session); + process(ops, event, &synth_sample, session); } } @@ -206,7 +208,8 @@ static int perf_event__synthesize_mmap_events(union perf_event *event, return 0; } -int perf_event__synthesize_modules(perf_event__handler_t process, +int perf_event__synthesize_modules(struct perf_event_ops *ops, + perf_event__handler_t process, struct perf_session *session, struct machine *machine) { @@ -251,7 +254,7 @@ int perf_event__synthesize_modules(perf_event__handler_t process, memcpy(event->mmap.filename, pos->dso->long_name, pos->dso->long_name_len + 1); - process(event, &synth_sample, session); + process(ops, event, &synth_sample, session); } free(event); @@ -261,17 +264,19 @@ int perf_event__synthesize_modules(perf_event__handler_t process, static int __event__synthesize_thread(union perf_event *comm_event, union perf_event *mmap_event, pid_t pid, perf_event__handler_t process, + struct perf_event_ops *ops, struct perf_session *session) { - pid_t tgid = perf_event__synthesize_comm(comm_event, pid, 1, process, + pid_t tgid = perf_event__synthesize_comm(ops, comm_event, pid, 1, process, session); if (tgid == -1) return -1; - return perf_event__synthesize_mmap_events(mmap_event, pid, tgid, + return perf_event__synthesize_mmap_events(ops, mmap_event, pid, tgid, process, session); } -int perf_event__synthesize_thread_map(struct thread_map *threads, +int perf_event__synthesize_thread_map(struct perf_event_ops *ops, + struct thread_map *threads, perf_event__handler_t process, struct perf_session *session) { @@ -290,7 +295,7 @@ int perf_event__synthesize_thread_map(struct thread_map *threads, for (thread = 0; thread < threads->nr; ++thread) { if (__event__synthesize_thread(comm_event, mmap_event, threads->map[thread], - process, session)) { + process, ops, session)) { err = -1; break; } @@ -302,7 +307,8 @@ out: return err; } -int perf_event__synthesize_threads(perf_event__handler_t process, +int perf_event__synthesize_threads(struct perf_event_ops *ops, + perf_event__handler_t process, struct perf_session *session) { DIR *proc; @@ -330,7 +336,7 @@ int perf_event__synthesize_threads(perf_event__handler_t process, continue; __event__synthesize_thread(comm_event, mmap_event, pid, - process, session); + process, ops, session); } closedir(proc); @@ -365,7 +371,8 @@ static int find_symbol_cb(void *arg, const char *name, char type, return 1; } -int perf_event__synthesize_kernel_mmap(perf_event__handler_t process, +int perf_event__synthesize_kernel_mmap(struct perf_event_ops *ops, + perf_event__handler_t process, struct perf_session *session, struct machine *machine, const char *symbol_name) @@ -423,13 +430,14 @@ int perf_event__synthesize_kernel_mmap(perf_event__handler_t process, event->mmap.len = map->end - event->mmap.start; event->mmap.pid = machine->pid; - err = process(event, &synth_sample, session); + err = process(ops, event, &synth_sample, session); free(event); return err; } -int perf_event__process_comm(union perf_event *event, +int perf_event__process_comm(struct perf_event_ops *ops __used, + union perf_event *event, struct perf_sample *sample __used, struct perf_session *session) { @@ -445,7 +453,8 @@ int perf_event__process_comm(union perf_event *event, return 0; } -int perf_event__process_lost(union perf_event *event, +int perf_event__process_lost(struct perf_event_ops *ops __used, + union perf_event *event, struct perf_sample *sample __used, struct perf_session *session) { @@ -468,7 +477,8 @@ static void perf_event__set_kernel_mmap_len(union perf_event *event, maps[MAP__FUNCTION]->end = ~0ULL; } -static int perf_event__process_kernel_mmap(union perf_event *event, +static int perf_event__process_kernel_mmap(struct perf_event_ops *ops __used, + union perf_event *event, struct perf_session *session) { struct map *map; @@ -567,7 +577,8 @@ out_problem: return -1; } -int perf_event__process_mmap(union perf_event *event, +int perf_event__process_mmap(struct perf_event_ops *ops, + union perf_event *event, struct perf_sample *sample __used, struct perf_session *session) { @@ -583,7 +594,7 @@ int perf_event__process_mmap(union perf_event *event, if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL || cpumode == PERF_RECORD_MISC_KERNEL) { - ret = perf_event__process_kernel_mmap(event, session); + ret = perf_event__process_kernel_mmap(ops, event, session); if (ret < 0) goto out_problem; return 0; @@ -610,7 +621,8 @@ out_problem: return 0; } -int perf_event__process_task(union perf_event *event, +int perf_event__process_task(struct perf_event_ops *ops __used, + union perf_event *event, struct perf_sample *sample __used, struct perf_session *session) { @@ -634,22 +646,22 @@ int perf_event__process_task(union perf_event *event, return 0; } -int perf_event__process(union perf_event *event, struct perf_sample *sample, - struct perf_session *session) +int perf_event__process(struct perf_event_ops *ops, union perf_event *event, + struct perf_sample *sample, struct perf_session *session) { switch (event->header.type) { case PERF_RECORD_COMM: - perf_event__process_comm(event, sample, session); + perf_event__process_comm(ops, event, sample, session); break; case PERF_RECORD_MMAP: - perf_event__process_mmap(event, sample, session); + perf_event__process_mmap(ops, event, sample, session); break; case PERF_RECORD_FORK: case PERF_RECORD_EXIT: - perf_event__process_task(event, sample, session); + perf_event__process_task(ops, event, sample, session); break; case PERF_RECORD_LOST: - perf_event__process_lost(event, sample, session); + perf_event__process_lost(ops, event, sample, session); default: break; } diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 357a85b..669409d 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -141,38 +141,52 @@ union perf_event { void perf_event__print_totals(void); +struct perf_event_ops; struct perf_session; struct thread_map; -typedef int (*perf_event__handler_synth_t)(union perf_event *event, - struct perf_session *session); -typedef int (*perf_event__handler_t)(union perf_event *event, +typedef int (*perf_event__handler_t)(struct perf_event_ops *ops, + union perf_event *event, struct perf_sample *sample, struct perf_session *session); -int perf_event__synthesize_thread_map(struct thread_map *threads, +int perf_event__synthesize_thread_map(struct perf_event_ops *ops, + struct thread_map *threads, perf_event__handler_t process, struct perf_session *session); -int perf_event__synthesize_threads(perf_event__handler_t process, +int perf_event__synthesize_threads(struct perf_event_ops *ops, + perf_event__handler_t process, struct perf_session *session); -int perf_event__synthesize_kernel_mmap(perf_event__handler_t process, +int perf_event__synthesize_kernel_mmap(struct perf_event_ops *ops, + perf_event__handler_t process, struct perf_session *session, struct machine *machine, const char *symbol_name); -int perf_event__synthesize_modules(perf_event__handler_t process, +int perf_event__synthesize_modules(struct perf_event_ops *ops, + perf_event__handler_t process, struct perf_session *session, struct machine *machine); -int perf_event__process_comm(union perf_event *event, struct perf_sample *sample, +int perf_event__process_comm(struct perf_event_ops *ops, + union perf_event *event, + struct perf_sample *sample, struct perf_session *session); -int perf_event__process_lost(union perf_event *event, struct perf_sample *sample, +int perf_event__process_lost(struct perf_event_ops *ops, + union perf_event *event, + struct perf_sample *sample, struct perf_session *session); -int perf_event__process_mmap(union perf_event *event, struct perf_sample *sample, +int perf_event__process_mmap(struct perf_event_ops *ops, + union perf_event *event, + struct perf_sample *sample, struct perf_session *session); -int perf_event__process_task(union perf_event *event, struct perf_sample *sample, +int perf_event__process_task(struct perf_event_ops *ops, + union perf_event *event, + struct perf_sample *sample, struct perf_session *session); -int perf_event__process(union perf_event *event, struct perf_sample *sample, +int perf_event__process(struct perf_event_ops *ops, + union perf_event *event, + struct perf_sample *sample, struct perf_session *session); struct addr_location; diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 1fa97dd..ab3a2b0 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2070,7 +2070,8 @@ out_delete_evlist: return -ENOMEM; } -int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, +int perf_event__synthesize_attr(struct perf_event_ops *ops, + struct perf_event_attr *attr, u16 ids, u64 *id, perf_event__handler_t process, struct perf_session *session) { @@ -2094,21 +2095,22 @@ int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, ev->attr.header.type = PERF_RECORD_HEADER_ATTR; ev->attr.header.size = size; - err = process(ev, NULL, session); + err = process(ops, ev, NULL, session); free(ev); return err; } -int perf_session__synthesize_attrs(struct perf_session *session, +int perf_event__synthesize_attrs(struct perf_event_ops *ops, + struct perf_session *session, perf_event__handler_t process) { struct perf_evsel *attr; int err = 0; list_for_each_entry(attr, &session->evlist->entries, node) { - err = perf_event__synthesize_attr(&attr->attr, attr->ids, + err = perf_event__synthesize_attr(ops, &attr->attr, attr->ids, attr->id, process, session); if (err) { pr_debug("failed to create perf header attribute\n"); @@ -2156,7 +2158,8 @@ int perf_event__process_attr(union perf_event *event, return 0; } -int perf_event__synthesize_event_type(u64 event_id, char *name, +int perf_event__synthesize_event_type(struct perf_event_ops *ops, + u64 event_id, char *name, perf_event__handler_t process, struct perf_session *session) { @@ -2176,12 +2179,13 @@ int perf_event__synthesize_event_type(u64 event_id, char *name, ev.event_type.header.size = sizeof(ev.event_type) - (sizeof(ev.event_type.event_type.name) - size); - err = process(&ev, NULL, session); + err = process(ops, &ev, NULL, session); return err; } -int perf_event__synthesize_event_types(perf_event__handler_t process, +int perf_event__synthesize_event_types(struct perf_event_ops *ops, + perf_event__handler_t process, struct perf_session *session) { struct perf_trace_event_type *type; @@ -2190,7 +2194,7 @@ int perf_event__synthesize_event_types(perf_event__handler_t process, for (i = 0; i < event_count; i++) { type = &events[i]; - err = perf_event__synthesize_event_type(type->event_id, + err = perf_event__synthesize_event_type(ops, type->event_id, type->name, process, session); if (err) { @@ -2202,7 +2206,8 @@ int perf_event__synthesize_event_types(perf_event__handler_t process, return err; } -int perf_event__process_event_type(union perf_event *event, +int perf_event__process_event_type(struct perf_event_ops *ops __unused, + union perf_event *event, struct perf_session *session __unused) { if (perf_header__push_event(event->event_type.event_type.event_id, @@ -2212,7 +2217,8 @@ int perf_event__process_event_type(union perf_event *event, return 0; } -int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, +int perf_event__synthesize_tracing_data(struct perf_event_ops *ops, int fd, + struct perf_evlist *evlist, perf_event__handler_t process, struct perf_session *session __unused) { @@ -2245,7 +2251,7 @@ int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, ev.tracing_data.header.size = sizeof(ev.tracing_data); ev.tracing_data.size = aligned_size; - process(&ev, NULL, session); + process(ops, &ev, NULL, session); /* * The put function will copy all the tracing data @@ -2287,7 +2293,8 @@ int perf_event__process_tracing_data(union perf_event *event, return size_read + padding; } -int perf_event__synthesize_build_id(struct dso *pos, u16 misc, +int perf_event__synthesize_build_id(struct perf_event_ops *ops, + struct dso *pos, u16 misc, perf_event__handler_t process, struct machine *machine, struct perf_session *session) @@ -2310,12 +2317,13 @@ int perf_event__synthesize_build_id(struct dso *pos, u16 misc, ev.build_id.header.size = sizeof(ev.build_id) + len; memcpy(&ev.build_id.filename, pos->long_name, pos->long_name_len); - err = process(&ev, NULL, session); + err = process(ops, &ev, NULL, session); return err; } -int perf_event__process_build_id(union perf_event *event, +int perf_event__process_build_id(struct perf_event_ops *ops __used, + union perf_event *event, struct perf_session *session) { __event_process_build_id(&event->build_id, diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index 0a88982..54dae5f 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -68,6 +68,7 @@ struct perf_header { }; struct perf_evlist; +struct perf_session; int perf_session__read_header(struct perf_session *session, int fd); int perf_session__write_header(struct perf_session *session, @@ -96,32 +97,40 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, const char *name, bool is_kallsyms); int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir); -int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, +int perf_event__synthesize_attr(struct perf_event_ops *ops, + struct perf_event_attr *attr, u16 ids, u64 *id, perf_event__handler_t process, struct perf_session *session); -int perf_session__synthesize_attrs(struct perf_session *session, - perf_event__handler_t process); +int perf_event__synthesize_attrs(struct perf_event_ops *ops, + struct perf_session *session, + perf_event__handler_t process); int perf_event__process_attr(union perf_event *event, struct perf_evlist **pevlist); -int perf_event__synthesize_event_type(u64 event_id, char *name, +int perf_event__synthesize_event_type(struct perf_event_ops *ops, + u64 event_id, char *name, perf_event__handler_t process, struct perf_session *session); -int perf_event__synthesize_event_types(perf_event__handler_t process, +int perf_event__synthesize_event_types(struct perf_event_ops *ops, + perf_event__handler_t process, struct perf_session *session); -int perf_event__process_event_type(union perf_event *event, +int perf_event__process_event_type(struct perf_event_ops *ops, + union perf_event *event, struct perf_session *session); -int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, +int perf_event__synthesize_tracing_data(struct perf_event_ops *ops, + int fd, struct perf_evlist *evlist, perf_event__handler_t process, struct perf_session *session); int perf_event__process_tracing_data(union perf_event *event, struct perf_session *session); -int perf_event__synthesize_build_id(struct dso *pos, u16 misc, +int perf_event__synthesize_build_id(struct perf_event_ops *ops, + struct dso *pos, u16 misc, perf_event__handler_t process, struct machine *machine, struct perf_session *session); -int perf_event__process_build_id(union perf_event *event, +int perf_event__process_build_id(struct perf_event_ops *ops, + union perf_event *event, struct perf_session *session); /* diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 734358b..a36023a 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -270,13 +270,21 @@ int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel return 0; } -static int process_event_synth_stub(union perf_event *event __used, +static int process_event_synth_stub(struct perf_event_ops *ops __used, + union perf_event *event __used, struct perf_session *session __used) { dump_printf(": unhandled!\n"); return 0; } +static int process_event_synth_tracing_data_stub(union perf_event *event __used, + struct perf_session *session __used) +{ + dump_printf(": unhandled!\n"); + return 0; +} + static int process_event_synth_attr_stub(union perf_event *event __used, struct perf_evlist **pevlist __used) { @@ -284,7 +292,8 @@ static int process_event_synth_attr_stub(union perf_event *event __used, return 0; } -static int process_event_sample_stub(union perf_event *event __used, +static int process_event_sample_stub(struct perf_event_ops *ops __used, + union perf_event *event __used, struct perf_sample *sample __used, struct perf_evsel *evsel __used, struct perf_session *session __used) @@ -293,7 +302,8 @@ static int process_event_sample_stub(union perf_event *event __used, return 0; } -static int process_event_stub(union perf_event *event __used, +static int process_event_stub(struct perf_event_ops *ops __used, + union perf_event *event __used, struct perf_sample *sample __used, struct perf_session *session __used) { @@ -301,17 +311,17 @@ static int process_event_stub(union perf_event *event __used, return 0; } -static int process_finished_round_stub(union perf_event *event __used, - struct perf_session *session __used, - struct perf_event_ops *ops __used) +static int process_finished_round_stub(struct perf_event_ops *ops __used, + union perf_event *event __used, + struct perf_session *session __used) { dump_printf(": unhandled!\n"); return 0; } -static int process_finished_round(union perf_event *event, - struct perf_session *session, - struct perf_event_ops *ops); +static int process_finished_round(struct perf_event_ops *ops, + union perf_event *event, + struct perf_session *session); static void perf_event_ops__fill_defaults(struct perf_event_ops *handler) { @@ -338,7 +348,7 @@ static void perf_event_ops__fill_defaults(struct perf_event_ops *handler) if (handler->event_type == NULL) handler->event_type = process_event_synth_stub; if (handler->tracing_data == NULL) - handler->tracing_data = process_event_synth_stub; + handler->tracing_data = process_event_synth_tracing_data_stub; if (handler->build_id == NULL) handler->build_id = process_event_synth_stub; if (handler->finished_round == NULL) { @@ -565,9 +575,9 @@ static void flush_sample_queue(struct perf_session *s, * Flush every events below timestamp 7 * etc... */ -static int process_finished_round(union perf_event *event __used, - struct perf_session *session, - struct perf_event_ops *ops) +static int process_finished_round(struct perf_event_ops *ops, + union perf_event *event __used, + struct perf_session *session) { flush_sample_queue(session, ops); session->ordered_samples.next_flush = session->ordered_samples.max_timestamp; @@ -759,23 +769,23 @@ static int perf_session_deliver_event(struct perf_session *session, ++session->hists.stats.nr_unknown_id; return -1; } - return ops->sample(event, sample, evsel, session); + return ops->sample(ops, event, sample, evsel, session); case PERF_RECORD_MMAP: - return ops->mmap(event, sample, session); + return ops->mmap(ops, event, sample, session); case PERF_RECORD_COMM: - return ops->comm(event, sample, session); + return ops->comm(ops, event, sample, session); case PERF_RECORD_FORK: - return ops->fork(event, sample, session); + return ops->fork(ops, event, sample, session); case PERF_RECORD_EXIT: - return ops->exit(event, sample, session); + return ops->exit(ops, event, sample, session); case PERF_RECORD_LOST: - return ops->lost(event, sample, session); + return ops->lost(ops, event, sample, session); case PERF_RECORD_READ: - return ops->read(event, sample, session); + return ops->read(ops, event, sample, session); case PERF_RECORD_THROTTLE: - return ops->throttle(event, sample, session); + return ops->throttle(ops, event, sample, session); case PERF_RECORD_UNTHROTTLE: - return ops->unthrottle(event, sample, session); + return ops->unthrottle(ops, event, sample, session); default: ++session->hists.stats.nr_unknown_events; return -1; @@ -813,15 +823,15 @@ static int perf_session__process_user_event(struct perf_session *session, union perf_session__update_sample_type(session); return err; case PERF_RECORD_HEADER_EVENT_TYPE: - return ops->event_type(event, session); + return ops->event_type(ops, event, session); case PERF_RECORD_HEADER_TRACING_DATA: /* setup for reading amidst mmap */ lseek(session->fd, file_offset, SEEK_SET); return ops->tracing_data(event, session); case PERF_RECORD_HEADER_BUILD_ID: - return ops->build_id(event, session); + return ops->build_id(ops, event, session); case PERF_RECORD_FINISHED_ROUND: - return ops->finished_round(event, session, ops); + return ops->finished_round(ops, event, session); default: return -EINVAL; } diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index d2f4303..6de3d13 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -56,16 +56,18 @@ struct perf_session { struct perf_evsel; struct perf_event_ops; -typedef int (*event_sample)(union perf_event *event, struct perf_sample *sample, +typedef int (*event_sample)(struct perf_event_ops *ops, + union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct perf_session *session); -typedef int (*event_op)(union perf_event *self, struct perf_sample *sample, +typedef int (*event_op)(struct perf_event_ops *ops, union perf_event *event, + struct perf_sample *sample, struct perf_session *session); typedef int (*event_synth_op)(union perf_event *self, struct perf_session *session); typedef int (*event_attr_op)(union perf_event *event, struct perf_evlist **pevlist); -typedef int (*event_op2)(union perf_event *self, struct perf_session *session, - struct perf_event_ops *ops); +typedef int (*event_op2)(struct perf_event_ops *ops, union perf_event *event, + struct perf_session *session); struct perf_event_ops { event_sample sample; @@ -78,10 +80,10 @@ struct perf_event_ops { throttle, unthrottle; event_attr_op attr; - event_synth_op event_type, - tracing_data, - build_id; - event_op2 finished_round; + event_synth_op tracing_data; + event_op2 event_type, + build_id, + finished_round; bool ordered_samples; bool ordering_requires_timestamps; }; @@ -142,10 +144,11 @@ struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t p static inline void perf_session__process_machines(struct perf_session *self, + struct perf_event_ops *ops, machine__process_t process) { - process(&self->host_machine, self); - return machines__process(&self->machines, process, self); + process(&self->host_machine, ops); + return machines__process(&self->machines, process, ops); } size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp); diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index 3996509..44eda6f 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h @@ -2,14 +2,15 @@ #define __PERF_TOP_H 1 #include "types.h" +#include "session.h" #include "../perf.h" #include struct perf_evlist; struct perf_evsel; -struct perf_session; struct perf_top { + struct perf_event_ops ops; struct perf_evlist *evlist; /* * Symbols will be added here in perf_event__process_sample and will -- cgit v1.1