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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 8d50e5b4
...@@ -58,12 +58,13 @@ static int hists__add_entry(struct hists *self, struct addr_location *al) ...@@ -58,12 +58,13 @@ static int hists__add_entry(struct hists *self, struct addr_location *al)
return hist_entry__inc_addr_samples(he, al->addr); return hist_entry__inc_addr_samples(he, al->addr);
} }
static int process_sample_event(event_t *event, struct perf_sample *sample, static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session) struct perf_session *session)
{ {
struct addr_location al; struct addr_location al;
if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) { if (perf_event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
pr_warning("problem processing %d event, skipping it.\n", pr_warning("problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
return -1; return -1;
...@@ -372,9 +373,9 @@ static void hists__find_annotations(struct hists *self) ...@@ -372,9 +373,9 @@ static void hists__find_annotations(struct hists *self)
static struct perf_event_ops event_ops = { static struct perf_event_ops event_ops = {
.sample = process_sample_event, .sample = process_sample_event,
.mmap = event__process_mmap, .mmap = perf_event__process_mmap,
.comm = event__process_comm, .comm = perf_event__process_comm,
.fork = event__process_task, .fork = perf_event__process_task,
.ordered_samples = true, .ordered_samples = true,
.ordering_requires_timestamps = true, .ordering_requires_timestamps = true,
}; };
......
...@@ -30,13 +30,13 @@ static int hists__add_entry(struct hists *self, ...@@ -30,13 +30,13 @@ static int hists__add_entry(struct hists *self,
return -ENOMEM; return -ENOMEM;
} }
static int diff__process_sample_event(event_t *event, static int diff__process_sample_event(union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session) struct perf_session *session)
{ {
struct addr_location al; struct addr_location al;
if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) { if (perf_event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
pr_warning("problem processing %d event, skipping it.\n", pr_warning("problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
return -1; return -1;
...@@ -56,11 +56,11 @@ static int diff__process_sample_event(event_t *event, ...@@ -56,11 +56,11 @@ static int diff__process_sample_event(event_t *event,
static struct perf_event_ops event_ops = { static struct perf_event_ops event_ops = {
.sample = diff__process_sample_event, .sample = diff__process_sample_event,
.mmap = event__process_mmap, .mmap = perf_event__process_mmap,
.comm = event__process_comm, .comm = perf_event__process_comm,
.exit = event__process_task, .exit = perf_event__process_task,
.fork = event__process_task, .fork = perf_event__process_task,
.lost = event__process_lost, .lost = perf_event__process_lost,
.ordered_samples = true, .ordered_samples = true,
.ordering_requires_timestamps = true, .ordering_requires_timestamps = true,
}; };
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
static char const *input_name = "-"; static char const *input_name = "-";
static bool inject_build_ids; static bool inject_build_ids;
static int event__repipe_synth(event_t *event, static int perf_event__repipe_synth(union perf_event *event,
struct perf_session *session __used) struct perf_session *session __used)
{ {
uint32_t size; uint32_t size;
void *buf = event; void *buf = event;
...@@ -36,41 +36,44 @@ static int event__repipe_synth(event_t *event, ...@@ -36,41 +36,44 @@ static int event__repipe_synth(event_t *event,
return 0; return 0;
} }
static int event__repipe(event_t *event, struct perf_sample *sample __used, static int perf_event__repipe(union perf_event *event,
struct perf_session *session) struct perf_sample *sample __used,
struct perf_session *session)
{ {
return event__repipe_synth(event, session); return perf_event__repipe_synth(event, session);
} }
static int event__repipe_mmap(event_t *self, struct perf_sample *sample, static int perf_event__repipe_mmap(union perf_event *event,
struct perf_session *session) struct perf_sample *sample,
struct perf_session *session)
{ {
int err; int err;
err = event__process_mmap(self, sample, session); err = perf_event__process_mmap(event, sample, session);
event__repipe(self, sample, session); perf_event__repipe(event, sample, session);
return err; return err;
} }
static int event__repipe_task(event_t *self, struct perf_sample *sample, static int perf_event__repipe_task(union perf_event *event,
struct perf_session *session) struct perf_sample *sample,
struct perf_session *session)
{ {
int err; int err;
err = event__process_task(self, sample, session); err = perf_event__process_task(event, sample, session);
event__repipe(self, sample, session); perf_event__repipe(event, sample, session);
return err; return err;
} }
static int event__repipe_tracing_data(event_t *self, static int perf_event__repipe_tracing_data(union perf_event *event,
struct perf_session *session) struct perf_session *session)
{ {
int err; int err;
event__repipe_synth(self, session); perf_event__repipe_synth(event, session);
err = event__process_tracing_data(self, session); err = perf_event__process_tracing_data(event, session);
return err; return err;
} }
...@@ -109,8 +112,8 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session) ...@@ -109,8 +112,8 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)
if (self->kernel) if (self->kernel)
misc = PERF_RECORD_MISC_KERNEL; misc = PERF_RECORD_MISC_KERNEL;
err = event__synthesize_build_id(self, misc, event__repipe, err = perf_event__synthesize_build_id(self, misc, perf_event__repipe,
machine, session); machine, session);
if (err) { if (err) {
pr_err("Can't synthesize build_id event for %s\n", self->long_name); pr_err("Can't synthesize build_id event for %s\n", self->long_name);
return -1; return -1;
...@@ -119,8 +122,9 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session) ...@@ -119,8 +122,9 @@ static int dso__inject_build_id(struct dso *self, struct perf_session *session)
return 0; return 0;
} }
static int event__inject_buildid(event_t *event, struct perf_sample *sample, static int perf_event__inject_buildid(union perf_event *event,
struct perf_session *session) struct perf_sample *sample,
struct perf_session *session)
{ {
struct addr_location al; struct addr_location al;
struct thread *thread; struct thread *thread;
...@@ -155,24 +159,24 @@ static int event__inject_buildid(event_t *event, struct perf_sample *sample, ...@@ -155,24 +159,24 @@ static int event__inject_buildid(event_t *event, struct perf_sample *sample,
} }
repipe: repipe:
event__repipe(event, sample, session); perf_event__repipe(event, sample, session);
return 0; return 0;
} }
struct perf_event_ops inject_ops = { struct perf_event_ops inject_ops = {
.sample = event__repipe, .sample = perf_event__repipe,
.mmap = event__repipe, .mmap = perf_event__repipe,
.comm = event__repipe, .comm = perf_event__repipe,
.fork = event__repipe, .fork = perf_event__repipe,
.exit = event__repipe, .exit = perf_event__repipe,
.lost = event__repipe, .lost = perf_event__repipe,
.read = event__repipe, .read = perf_event__repipe,
.throttle = event__repipe, .throttle = perf_event__repipe,
.unthrottle = event__repipe, .unthrottle = perf_event__repipe,
.attr = event__repipe_synth, .attr = perf_event__repipe_synth,
.event_type = event__repipe_synth, .event_type = perf_event__repipe_synth,
.tracing_data = event__repipe_synth, .tracing_data = perf_event__repipe_synth,
.build_id = event__repipe_synth, .build_id = perf_event__repipe_synth,
}; };
extern volatile int session_done; extern volatile int session_done;
...@@ -190,10 +194,10 @@ static int __cmd_inject(void) ...@@ -190,10 +194,10 @@ static int __cmd_inject(void)
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
if (inject_build_ids) { if (inject_build_ids) {
inject_ops.sample = event__inject_buildid; inject_ops.sample = perf_event__inject_buildid;
inject_ops.mmap = event__repipe_mmap; inject_ops.mmap = perf_event__repipe_mmap;
inject_ops.fork = event__repipe_task; inject_ops.fork = perf_event__repipe_task;
inject_ops.tracing_data = event__repipe_tracing_data; inject_ops.tracing_data = perf_event__repipe_tracing_data;
} }
session = perf_session__new(input_name, O_RDONLY, false, true, &inject_ops); session = perf_session__new(input_name, O_RDONLY, false, true, &inject_ops);
......
...@@ -275,9 +275,8 @@ static void process_free_event(void *data, ...@@ -275,9 +275,8 @@ static void process_free_event(void *data,
s_alloc->alloc_cpu = -1; s_alloc->alloc_cpu = -1;
} }
static void static void process_raw_event(union perf_event *raw_event __used, void *data,
process_raw_event(event_t *raw_event __used, void *data, int cpu, u64 timestamp, struct thread *thread)
int cpu, u64 timestamp, struct thread *thread)
{ {
struct event *event; struct event *event;
int type; int type;
...@@ -304,7 +303,8 @@ process_raw_event(event_t *raw_event __used, void *data, ...@@ -304,7 +303,8 @@ process_raw_event(event_t *raw_event __used, void *data,
} }
} }
static int process_sample_event(event_t *event, struct perf_sample *sample, static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session) struct perf_session *session)
{ {
struct thread *thread = perf_session__findnew(session, event->ip.pid); struct thread *thread = perf_session__findnew(session, event->ip.pid);
...@@ -325,7 +325,7 @@ static int process_sample_event(event_t *event, struct perf_sample *sample, ...@@ -325,7 +325,7 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
static struct perf_event_ops event_ops = { static struct perf_event_ops event_ops = {
.sample = process_sample_event, .sample = process_sample_event,
.comm = event__process_comm, .comm = perf_event__process_comm,
.ordered_samples = true, .ordered_samples = true,
}; };
......
...@@ -834,14 +834,14 @@ static void dump_info(void) ...@@ -834,14 +834,14 @@ static void dump_info(void)
die("Unknown type of information\n"); die("Unknown type of information\n");
} }
static int process_sample_event(event_t *self, struct perf_sample *sample, static int process_sample_event(union perf_event *event, struct perf_sample *sample,
struct perf_session *s) struct perf_session *s)
{ {
struct thread *thread = perf_session__findnew(s, sample->tid); struct thread *thread = perf_session__findnew(s, sample->tid);
if (thread == NULL) { if (thread == NULL) {
pr_debug("problem processing %d event, skipping it.\n", pr_debug("problem processing %d event, skipping it.\n",
self->header.type); event->header.type);
return -1; return -1;
} }
...@@ -852,7 +852,7 @@ static int process_sample_event(event_t *self, struct perf_sample *sample, ...@@ -852,7 +852,7 @@ static int process_sample_event(event_t *self, struct perf_sample *sample,
static struct perf_event_ops eops = { static struct perf_event_ops eops = {
.sample = process_sample_event, .sample = process_sample_event,
.comm = event__process_comm, .comm = perf_event__process_comm,
.ordered_samples = true, .ordered_samples = true,
}; };
......
...@@ -100,7 +100,7 @@ static void write_output(void *buf, size_t size) ...@@ -100,7 +100,7 @@ static void write_output(void *buf, size_t size)
} }
} }
static int process_synthesized_event(event_t *event, static int process_synthesized_event(union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_session *self __used) struct perf_session *self __used)
{ {
...@@ -404,7 +404,7 @@ static void atexit_header(void) ...@@ -404,7 +404,7 @@ static void atexit_header(void)
} }
} }
static void event__synthesize_guest_os(struct machine *machine, void *data) static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
{ {
int err; int err;
struct perf_session *psession = data; struct perf_session *psession = data;
...@@ -420,8 +420,8 @@ static void event__synthesize_guest_os(struct machine *machine, void *data) ...@@ -420,8 +420,8 @@ static void event__synthesize_guest_os(struct machine *machine, void *data)
*method is used to avoid symbol missing when the first addr is *method is used to avoid symbol missing when the first addr is
*in module instead of in guest kernel. *in module instead of in guest kernel.
*/ */
err = event__synthesize_modules(process_synthesized_event, err = perf_event__synthesize_modules(process_synthesized_event,
psession, machine); psession, machine);
if (err < 0) if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference" pr_err("Couldn't record guest kernel [%d]'s reference"
" relocation symbol.\n", machine->pid); " relocation symbol.\n", machine->pid);
...@@ -430,11 +430,12 @@ static void event__synthesize_guest_os(struct machine *machine, void *data) ...@@ -430,11 +430,12 @@ static void event__synthesize_guest_os(struct machine *machine, void *data)
* We use _stext for guest kernel because guest kernel's /proc/kallsyms * We use _stext for guest kernel because guest kernel's /proc/kallsyms
* have no _text sometimes. * have no _text sometimes.
*/ */
err = event__synthesize_kernel_mmap(process_synthesized_event, err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
psession, machine, "_text"); psession, machine, "_text");
if (err < 0) if (err < 0)
err = event__synthesize_kernel_mmap(process_synthesized_event, err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
psession, machine, "_stext"); psession, machine,
"_stext");
if (err < 0) if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference" pr_err("Couldn't record guest kernel [%d]'s reference"
" relocation symbol.\n", machine->pid); " relocation symbol.\n", machine->pid);
...@@ -617,16 +618,16 @@ static int __cmd_record(int argc, const char **argv) ...@@ -617,16 +618,16 @@ static int __cmd_record(int argc, const char **argv)
perf_session__set_sample_id_all(session, sample_id_all_avail); perf_session__set_sample_id_all(session, sample_id_all_avail);
if (pipe_output) { if (pipe_output) {
err = event__synthesize_attrs(&session->header, err = perf_event__synthesize_attrs(&session->header,
process_synthesized_event, process_synthesized_event,
session); session);
if (err < 0) { if (err < 0) {
pr_err("Couldn't synthesize attrs.\n"); pr_err("Couldn't synthesize attrs.\n");
return err; return err;
} }
err = event__synthesize_event_types(process_synthesized_event, err = perf_event__synthesize_event_types(process_synthesized_event,
session); session);
if (err < 0) { if (err < 0) {
pr_err("Couldn't synthesize event_types.\n"); pr_err("Couldn't synthesize event_types.\n");
return err; return err;
...@@ -641,9 +642,9 @@ static int __cmd_record(int argc, const char **argv) ...@@ -641,9 +642,9 @@ static int __cmd_record(int argc, const char **argv)
* return this more properly and also * return this more properly and also
* propagate errors that now are calling die() * propagate errors that now are calling die()
*/ */
err = event__synthesize_tracing_data(output, evsel_list, err = perf_event__synthesize_tracing_data(output, evsel_list,
process_synthesized_event, process_synthesized_event,
session); session);
if (err <= 0) { if (err <= 0) {
pr_err("Couldn't record tracing data.\n"); pr_err("Couldn't record tracing data.\n");
return err; return err;
...@@ -658,31 +659,34 @@ static int __cmd_record(int argc, const char **argv) ...@@ -658,31 +659,34 @@ static int __cmd_record(int argc, const char **argv)
return -1; return -1;
} }
err = event__synthesize_kernel_mmap(process_synthesized_event, err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
session, machine, "_text"); session, machine, "_text");
if (err < 0) if (err < 0)
err = event__synthesize_kernel_mmap(process_synthesized_event, err = perf_event__synthesize_kernel_mmap(process_synthesized_event,
session, machine, "_stext"); session, machine, "_stext");
if (err < 0) if (err < 0)
pr_err("Couldn't record kernel reference relocation symbol\n" pr_err("Couldn't record kernel reference relocation symbol\n"
"Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
"Check /proc/kallsyms permission or run as root.\n"); "Check /proc/kallsyms permission or run as root.\n");
err = event__synthesize_modules(process_synthesized_event, err = perf_event__synthesize_modules(process_synthesized_event,
session, machine); session, machine);
if (err < 0) if (err < 0)
pr_err("Couldn't record kernel module information.\n" pr_err("Couldn't record kernel module information.\n"
"Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
"Check /proc/modules permission or run as root.\n"); "Check /proc/modules permission or run as root.\n");
if (perf_guest) if (perf_guest)
perf_session__process_machines(session, event__synthesize_guest_os); perf_session__process_machines(session,
perf_event__synthesize_guest_os);
if (!system_wide) if (!system_wide)
event__synthesize_thread(target_tid, process_synthesized_event, perf_event__synthesize_thread(target_tid,
session); process_synthesized_event,
session);
else else
event__synthesize_threads(process_synthesized_event, session); perf_event__synthesize_threads(process_synthesized_event,
session);
if (realtime_prio) { if (realtime_prio) {
struct sched_param param; struct sched_param param;
......
...@@ -149,13 +149,14 @@ static int add_event_total(struct perf_session *session, ...@@ -149,13 +149,14 @@ static int add_event_total(struct perf_session *session,
return 0; return 0;
} }
static int process_sample_event(event_t *event, struct perf_sample *sample, static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session) struct perf_session *session)
{ {
struct addr_location al; struct addr_location al;
struct perf_event_attr *attr; struct perf_event_attr *attr;
if (event__preprocess_sample(event, session, &al, sample, NULL) < 0) { if (perf_event__preprocess_sample(event, session, &al, sample, NULL) < 0) {
fprintf(stderr, "problem processing %d event, skipping it.\n", fprintf(stderr, "problem processing %d event, skipping it.\n",
event->header.type); event->header.type);
return -1; return -1;
...@@ -179,7 +180,8 @@ static int process_sample_event(event_t *event, struct perf_sample *sample, ...@@ -179,7 +180,8 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
return 0; return 0;
} }
static int process_read_event(event_t *event, struct perf_sample *sample __used, static int process_read_event(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session __used) struct perf_session *session __used)
{ {
struct perf_event_attr *attr; struct perf_event_attr *attr;
...@@ -232,17 +234,17 @@ static int perf_session__setup_sample_type(struct perf_session *self) ...@@ -232,17 +234,17 @@ static int perf_session__setup_sample_type(struct perf_session *self)
} }
static struct perf_event_ops event_ops = { static struct perf_event_ops event_ops = {
.sample = process_sample_event, .sample = process_sample_event,
.mmap = event__process_mmap, .mmap = perf_event__process_mmap,
.comm = event__process_comm, .comm = perf_event__process_comm,
.exit = event__process_task, .exit = perf_event__process_task,
.fork = event__process_task, .fork = perf_event__process_task,
.lost = event__process_lost, .lost = perf_event__process_lost,
.read = process_read_event, .read = process_read_event,
.attr = event__process_attr, .attr = perf_event__process_attr,
.event_type = event__process_event_type, .event_type = perf_event__process_event_type,
.tracing_data = event__process_tracing_data, .tracing_data = perf_event__process_tracing_data,
.build_id = event__process_build_id, .build_id = perf_event__process_build_id,
.ordered_samples = true, .ordered_samples = true,
.ordering_requires_timestamps = true, .ordering_requires_timestamps = true,
}; };
......
...@@ -1580,9 +1580,9 @@ process_sched_migrate_task_event(void *data, struct perf_session *session, ...@@ -1580,9 +1580,9 @@ process_sched_migrate_task_event(void *data, struct perf_session *session,
event, cpu, timestamp, thread); event, cpu, timestamp, thread);
} }
static void static void process_raw_event(union perf_event *raw_event __used,
process_raw_event(event_t *raw_event __used, struct perf_session *session, struct perf_session *session, void *data, int cpu,
void *data, int cpu, u64 timestamp, struct thread *thread) u64 timestamp, struct thread *thread)
{ {
struct event *event; struct event *event;
int type; int type;
...@@ -1607,7 +1607,8 @@ process_raw_event(event_t *raw_event __used, struct perf_session *session, ...@@ -1607,7 +1607,8 @@ process_raw_event(event_t *raw_event __used, struct perf_session *session,
process_sched_migrate_task_event(data, session, event, cpu, timestamp, thread); process_sched_migrate_task_event(data, session, event, cpu, timestamp, thread);
} }
static int process_sample_event(event_t *event, struct perf_sample *sample, static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session) struct perf_session *session)
{ {
struct thread *thread; struct thread *thread;
...@@ -1635,9 +1636,9 @@ static int process_sample_event(event_t *event, struct perf_sample *sample, ...@@ -1635,9 +1636,9 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
static struct perf_event_ops event_ops = { static struct perf_event_ops event_ops = {
.sample = process_sample_event, .sample = process_sample_event,
.comm = event__process_comm, .comm = perf_event__process_comm,
.lost = event__process_lost, .lost = perf_event__process_lost,
.fork = event__process_task, .fork = perf_event__process_task,
.ordered_samples = true, .ordered_samples = true,
}; };
......
...@@ -63,7 +63,8 @@ static int cleanup_scripting(void) ...@@ -63,7 +63,8 @@ static int cleanup_scripting(void)
static char const *input_name = "perf.data"; static char const *input_name = "perf.data";
static int process_sample_event(event_t *event, struct perf_sample *sample, static int process_sample_event(union perf_event *event,
struct perf_sample *sample,
struct perf_session *session) struct perf_session *session)
{ {
struct thread *thread = perf_session__findnew(session, event->ip.pid); struct thread *thread = perf_session__findnew(session, event->ip.pid);
...@@ -100,14 +101,14 @@ static int process_sample_event(event_t *event, struct perf_sample *sample, ...@@ -100,14 +101,14 @@ static int process_sample_event(event_t *event, struct perf_sample *sample,
} }
static struct perf_event_ops event_ops = { static struct perf_event_ops event_ops = {
.sample = process_sample_event, .sample = process_sample_event,
.comm = event__process_comm, .comm = perf_event__process_comm,
.attr = event__process_attr, .attr = perf_event__process_attr,
.event_type = event__process_event_type, .event_type = perf_event__process_event_type,
.tracing_data = event__process_tracing_data, .tracing_data = perf_event__process_tracing_data,
.build_id = event__process_build_id, .build_id = perf_event__process_build_id,
.ordering_requires_timestamps = true,
.ordered_samples = true, .ordered_samples = true,
.ordering_requires_timestamps = true,
}; };
extern volatile int session_done; extern volatile int session_done;
......
...@@ -454,7 +454,7 @@ static int test__open_syscall_event_on_all_cpus(void) ...@@ -454,7 +454,7 @@ static int test__open_syscall_event_on_all_cpus(void)
static int test__basic_mmap(void) static int test__basic_mmap(void)
{ {
int err = -1; int err = -1;
event_t *event; union perf_event *event;
struct thread_map *threads; struct thread_map *threads;
struct cpu_map *cpus; struct cpu_map *cpus;
struct perf_evlist *evlist; struct perf_evlist *evlist;
...@@ -554,11 +554,11 @@ static int test__basic_mmap(void) ...@@ -554,11 +554,11 @@ static int test__basic_mmap(void)
if (event->header.type != PERF_RECORD_SAMPLE) { if (event->header.type != PERF_RECORD_SAMPLE) {
pr_debug("unexpected %s event\n", pr_debug("unexpected %s event\n",
event__get_event_name(event->header.type)); perf_event__name(event->header.type));
goto out_munmap; goto out_munmap;
} }
event__parse_sample(event, attr.sample_type, false, &sample); perf_event__parse_sample(event, attr.sample_type, false, &sample);
evsel = perf_evlist__id2evsel(evlist, sample.id); evsel = perf_evlist__id2evsel(evlist, sample.id);
if (evsel == NULL) { if (evsel == NULL) {
pr_debug("event with id %" PRIu64 pr_debug("event with id %" PRIu64
......
...@@ -276,21 +276,24 @@ static int cpus_cstate_state[MAX_CPUS]; ...@@ -276,21 +276,24 @@ static int cpus_cstate_state[MAX_CPUS];
static u64 cpus_pstate_start_times[MAX_CPUS]; static u64 cpus_pstate_start_times[MAX_CPUS];
static u64 cpus_pstate_state[MAX_CPUS]; static u64 cpus_pstate_state[MAX_CPUS];
static int process_comm_event(event_t *event, struct perf_sample *sample __used, static int process_comm_event(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session __used) struct perf_session *session __used)
{ {
pid_set_comm(event->comm.tid, event->comm.comm); pid_set_comm(event->comm.tid, event->comm.comm);
return 0; return 0;
} }
static int process_fork_event(event_t *event, struct perf_sample *sample __used, static int process_fork_event(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session __used) struct perf_session *session __used)
{ {
pid_fork(event->fork.pid, event->fork.ppid, event->fork.time); pid_fork(event->fork.pid, event->fork.ppid, event->fork.time);
return 0; return 0;
} }
static int process_exit_event(event_t *event, struct perf_sample *sample __used, static int process_exit_event(union perf_event *event,
struct perf_sample *sample __used,
struct perf_session *session __used) struct perf_session *session __used)
{ {
pid_exit(event->fork.pid, event->fork.time); pid_exit(event->fork.pid, event->fork.time);
...@@ -486,7 +489,7 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te) ...@@ -486,7 +489,7 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te)
} }
static int process_sample_event(event_t *event __used, static int process_sample_event(union perf_event *event __used,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session) struct perf_session *session)
{ {
......
...@@ -401,7 +401,7 @@ static void show_details(struct sym_entry *syme) ...@@ -401,7 +401,7 @@ static void show_details(struct sym_entry *syme)
} }
/* /*
* Symbols will be added here in event__process_sample and will get out * Symbols will be added here in perf_event__process_sample and will get out
* after decayed. * after decayed.
*/ */
static LIST_HEAD(active_symbols); static LIST_HEAD(active_symbols);
...@@ -996,15 +996,15 @@ static int symbol_filter(struct map *map, struct symbol *sym) ...@@ -996,15 +996,15 @@ static int symbol_filter(struct map *map, struct symbol *sym)
return 0; return 0;
} }
static void event__process_sample(const event_t *self, static void perf_event__process_sample(const union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_session *session) struct perf_session *session)
{ {
u64 ip = self->ip.ip; u64 ip = event->ip.ip;
struct sym_entry *syme; struct sym_entry *syme;
struct addr_location al; struct addr_location al;
struct machine *machine; struct machine *machine;
u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; u8 origin = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
++samples; ++samples;
...@@ -1023,7 +1023,7 @@ static void event__process_sample(const event_t *self, ...@@ -1023,7 +1023,7 @@ static void event__process_sample(const event_t *self,
break; break;
case PERF_RECORD_MISC_GUEST_KERNEL: case PERF_RECORD_MISC_GUEST_KERNEL:
++guest_kernel_samples; ++guest_kernel_samples;
machine = perf_session__find_machine(session, self->ip.pid); machine = perf_session__find_machine(session, event->ip.pid);
break; break;
case PERF_RECORD_MISC_GUEST_USER: case PERF_RECORD_MISC_GUEST_USER:
++guest_us_samples; ++guest_us_samples;
...@@ -1038,15 +1038,15 @@ static void event__process_sample(const event_t *self, ...@@ -1038,15 +1038,15 @@ static void event__process_sample(const event_t *self,
if (!machine && perf_guest) { if (!machine && perf_guest) {
pr_err("Can't find guest [%d]'s kernel information\n", pr_err("Can't find guest [%d]'s kernel information\n",
self->ip.pid); event->ip.pid);
return; return;
} }
if (self->header.misc & PERF_RECORD_MISC_EXACT_IP) if (event->header.misc & PERF_RECORD_MISC_EXACT_IP)
exact_samples++; exact_samples++;
if (event__preprocess_sample(self, session, &al, sample, if (perf_event__preprocess_sample(event, session, &al, sample,
symbol_filter) < 0 || symbol_filter) < 0 ||
al.filtered) al.filtered)
return; return;
...@@ -1108,15 +1108,15 @@ static void event__process_sample(const event_t *self, ...@@ -1108,15 +1108,15 @@ static void event__process_sample(const event_t *self,
static void perf_session__mmap_read_cpu(struct perf_session *self, int cpu) static void perf_session__mmap_read_cpu(struct perf_session *self, int cpu)
{ {
struct perf_sample sample; struct perf_sample sample;
event_t *event; union perf_event *event;
while ((event = perf_evlist__read_on_cpu(evsel_list, cpu)) != NULL) { while ((event = perf_evlist__read_on_cpu(evsel_list, cpu)) != NULL) {
perf_session__parse_sample(self, event, &sample); perf_session__parse_sample(self, event, &sample);
if (event->header.type == PERF_RECORD_SAMPLE) if (event->header.type == PERF_RECORD_SAMPLE)
event__process_sample(event, &sample, self); perf_event__process_sample(event, &sample, self);
else else
event__process(event, &sample, self); perf_event__process(event, &sample, self);
} }
} }
...@@ -1199,9 +1199,10 @@ static int __cmd_top(void) ...@@ -1199,9 +1199,10 @@ static int __cmd_top(void)
return -ENOMEM; return -ENOMEM;
if (target_tid != -1) if (target_tid != -1)
event__synthesize_thread(target_tid, event__process, session); perf_event__synthesize_thread(target_tid, perf_event__process,
session);
else else
event__synthesize_threads(event__process, session); perf_event__synthesize_threads(perf_event__process, session);
start_counters(evsel_list); start_counters(evsel_list);
first = list_entry(evsel_list->entries.next, struct perf_evsel, node); first = list_entry(evsel_list->entries.next, struct perf_evsel, node);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include "debug.h" #include "debug.h"
static int build_id__mark_dso_hit(event_t *event, static int build_id__mark_dso_hit(union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_session *session) struct perf_session *session)
{ {
...@@ -37,13 +37,14 @@ static int build_id__mark_dso_hit(event_t *event, ...@@ -37,13 +37,14 @@ static int build_id__mark_dso_hit(event_t *event,
return 0; return 0;
} }
static int event__exit_del_thread(event_t *self, struct perf_sample *sample __used, static int perf_event__exit_del_thread(union perf_event *event,
struct perf_session *session) struct perf_sample *sample __used,
struct perf_session *session)
{ {
struct thread *thread = perf_session__findnew(session, self->fork.tid); struct thread *thread = perf_session__findnew(session, event->fork.tid);
dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid, dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
self->fork.ppid, self->fork.ptid); event->fork.ppid, event->fork.ptid);
if (thread) { if (thread) {
rb_erase(&thread->rb_node, &session->threads); 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,9 +57,9 @@ static int event__exit_del_thread(event_t *self, struct perf_sample *sample __us
struct perf_event_ops build_id__mark_dso_hit_ops = { struct perf_event_ops build_id__mark_dso_hit_ops = {
.sample = build_id__mark_dso_hit, .sample = build_id__mark_dso_hit,
.mmap = event__process_mmap, .mmap = perf_event__process_mmap,
.fork = event__process_task, .fork = perf_event__process_task,
.exit = event__exit_del_thread, .exit = perf_event__exit_del_thread,
}; };
char *dso__build_id_filename(struct dso *self, char *bf, size_t size) char *dso__build_id_filename(struct dso *self, char *bf, size_t size)
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
#include "util.h" #include "util.h"
#include "callchain.h" #include "callchain.h"
bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event) bool ip_callchain__valid(struct ip_callchain *chain,
const union perf_event *event)
{ {
unsigned int chain_size = event->header.size; unsigned int chain_size = event->header.size;
chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event; chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event;
......
...@@ -95,8 +95,8 @@ int callchain_append(struct callchain_root *root, ...@@ -95,8 +95,8 @@ int callchain_append(struct callchain_root *root,
int callchain_merge(struct callchain_cursor *cursor, int callchain_merge(struct callchain_cursor *cursor,
struct callchain_root *dst, struct callchain_root *src); struct callchain_root *dst, struct callchain_root *src);
bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event); bool ip_callchain__valid(struct ip_callchain *chain,
const union perf_event *event);
/* /*
* Initialize a cursor before adding entries inside, but keep * Initialize a cursor before adding entries inside, but keep
* the previously allocated entries as a cache. * the previously allocated entries as a cache.
......
...@@ -57,7 +57,7 @@ void ui__warning(const char *format, ...) ...@@ -57,7 +57,7 @@ void ui__warning(const char *format, ...)
} }
#endif #endif
void trace_event(event_t *event) void trace_event(union perf_event *event)
{ {
unsigned char *raw_event = (void *)event; unsigned char *raw_event = (void *)event;
const char *color = PERF_COLOR_BLUE; const char *color = PERF_COLOR_BLUE;
......
...@@ -9,7 +9,7 @@ extern int verbose; ...@@ -9,7 +9,7 @@ extern int verbose;
extern bool quiet, dump_trace; extern bool quiet, dump_trace;
int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
void trace_event(event_t *event); void trace_event(union perf_event *event);
struct ui_progress; struct ui_progress;
......
This diff is collapsed.
...@@ -117,7 +117,7 @@ struct tracing_data_event { ...@@ -117,7 +117,7 @@ struct tracing_data_event {
u32 size; u32 size;
}; };
typedef union event_union { union perf_event {
struct perf_event_header header; struct perf_event_header header;
struct ip_event ip; struct ip_event ip;
struct mmap_event mmap; struct mmap_event mmap;
...@@ -130,49 +130,52 @@ typedef union event_union { ...@@ -130,49 +130,52 @@ typedef union event_union {
struct event_type_event event_type; struct event_type_event event_type;
struct tracing_data_event tracing_data; struct tracing_data_event tracing_data;
struct build_id_event build_id; struct build_id_event build_id;
} event_t; };
void event__print_totals(void); void perf_event__print_totals(void);
struct perf_session; struct perf_session;
typedef int (*event__handler_synth_t)(event_t *event, 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,
struct perf_sample *sample,
struct perf_session *session); struct perf_session *session);
typedef int (*event__handler_t)(event_t *event, struct perf_sample *sample,
struct perf_session *session);
int event__synthesize_thread(pid_t pid, event__handler_t process, int perf_event__synthesize_thread(pid_t pid, perf_event__handler_t process,
struct perf_session *session);
int perf_event__synthesize_threads(perf_event__handler_t process,
struct perf_session *session);
int perf_event__synthesize_kernel_mmap(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,
struct perf_session *session,
struct machine *machine);
int perf_event__process_comm(union perf_event *event, struct perf_sample *sample,
struct perf_session *session); struct perf_session *session);
int event__synthesize_threads(event__handler_t process, int perf_event__process_lost(union perf_event *event, struct perf_sample *sample,
struct perf_session *session); struct perf_session *session);
int event__synthesize_kernel_mmap(event__handler_t process, int perf_event__process_mmap(union perf_event *event, struct perf_sample *sample,
struct perf_session *session, struct perf_session *session);
struct machine *machine, int perf_event__process_task(union perf_event *event, struct perf_sample *sample,
const char *symbol_name); struct perf_session *session);
int perf_event__process(union perf_event *event, struct perf_sample *sample,
int event__synthesize_modules(event__handler_t process,
struct perf_session *session,
struct machine *machine);
int event__process_comm(event_t *event, struct perf_sample *sample,
struct perf_session *session);
int event__process_lost(event_t *event, struct perf_sample *sample,
struct perf_session *session);
int event__process_mmap(event_t *event, struct perf_sample *sample,
struct perf_session *session);
int event__process_task(event_t *event, struct perf_sample *sample,
struct perf_session *session); struct perf_session *session);
int event__process(event_t *event, struct perf_sample *sample,
struct perf_session *session);
struct addr_location; struct addr_location;
int event__preprocess_sample(const event_t *self, struct perf_session *session, int perf_event__preprocess_sample(const union perf_event *self,
struct addr_location *al, struct perf_sample *sample, struct perf_session *session,
symbol_filter_t filter); struct addr_location *al,
struct perf_sample *sample,
symbol_filter_t filter);
const char *event__get_event_name(unsigned int id); const char *perf_event__name(unsigned int id);
int event__parse_sample(const event_t *event, u64 type, bool sample_id_all, int perf_event__parse_sample(const union perf_event *event, u64 type,
struct perf_sample *sample); bool sample_id_all, struct perf_sample *sample);
#endif /* __PERF_RECORD_H */ #endif /* __PERF_RECORD_H */
...@@ -107,7 +107,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id) ...@@ -107,7 +107,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
return NULL; return NULL;
} }
event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
{ {
/* XXX Move this to perf.c, making it generally available */ /* XXX Move this to perf.c, making it generally available */
unsigned int page_size = sysconf(_SC_PAGE_SIZE); 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,7 +115,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
unsigned int head = perf_mmap__read_head(md); unsigned int head = perf_mmap__read_head(md);
unsigned int old = md->prev; unsigned int old = md->prev;
unsigned char *data = md->base + page_size; unsigned char *data = md->base + page_size;
event_t *event = NULL; union perf_event *event = NULL;
if (evlist->overwrite) { if (evlist->overwrite) {
/* /*
...@@ -140,7 +140,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu) ...@@ -140,7 +140,7 @@ event_t *perf_evlist__read_on_cpu(struct perf_evlist *evlist, int cpu)
if (old != head) { if (old != head) {
size_t size; size_t size;
event = (event_t *)&data[old & md->mask]; event = (union perf_event *)&data[old & md->mask];
size = event->header.size; size = event->header.size;
/* /*
......
...@@ -17,7 +17,7 @@ struct perf_evlist { ...@@ -17,7 +17,7 @@ struct perf_evlist {
int nr_fds; int nr_fds;
int mmap_len; int mmap_len;
bool overwrite; bool overwrite;
event_t event_copy; union perf_event event_copy;
struct perf_mmap *mmap; struct perf_mmap *mmap;
struct pollfd *pollfd; struct pollfd *pollfd;
}; };
...@@ -37,6 +37,6 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd); ...@@ -37,6 +37,6 @@ void perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd);
struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id); struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
event_t *perf_evlist__read_on_cpu(struct perf_evlist *self, int cpu); union perf_event *perf_evlist__read_on_cpu(struct perf_evlist *self, int cpu);
#endif /* __PERF_EVLIST_H */ #endif /* __PERF_EVLIST_H */
...@@ -367,8 +367,8 @@ int perf_evlist__mmap(struct perf_evlist *evlist, struct cpu_map *cpus, ...@@ -367,8 +367,8 @@ int perf_evlist__mmap(struct perf_evlist *evlist, struct cpu_map *cpus,
return -1; return -1;
} }
static int event__parse_id_sample(const event_t *event, u64 type, static int perf_event__parse_id_sample(const union perf_event *event, u64 type,
struct perf_sample *sample) struct perf_sample *sample)
{ {
const u64 *array = event->sample.array; const u64 *array = event->sample.array;
...@@ -405,8 +405,8 @@ static int event__parse_id_sample(const event_t *event, u64 type, ...@@ -405,8 +405,8 @@ static int event__parse_id_sample(const event_t *event, u64 type,
return 0; return 0;
} }
int event__parse_sample(const event_t *event, u64 type, bool sample_id_all, int perf_event__parse_sample(const union perf_event *event, u64 type,
struct perf_sample *data) bool sample_id_all, struct perf_sample *data)
{ {
const u64 *array; const u64 *array;
...@@ -416,7 +416,7 @@ int event__parse_sample(const event_t *event, u64 type, bool sample_id_all, ...@@ -416,7 +416,7 @@ int event__parse_sample(const event_t *event, u64 type, bool sample_id_all,
if (event->header.type != PERF_RECORD_SAMPLE) { if (event->header.type != PERF_RECORD_SAMPLE) {
if (!sample_id_all) if (!sample_id_all)
return 0; return 0;
return event__parse_id_sample(event, type, data); return perf_event__parse_id_sample(event, type, data);
} }
array = event->sample.array; array = event->sample.array;
......
...@@ -1000,11 +1000,11 @@ perf_header__find_attr(u64 id, struct perf_header *header) ...@@ -1000,11 +1000,11 @@ perf_header__find_attr(u64 id, struct perf_header *header)
return NULL; return NULL;
} }
int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
event__handler_t process, perf_event__handler_t process,
struct perf_session *session) struct perf_session *session)
{ {
event_t *ev; union perf_event *ev;
size_t size; size_t size;
int err; int err;
...@@ -1031,8 +1031,9 @@ int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, ...@@ -1031,8 +1031,9 @@ int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
return err; return err;
} }
int event__synthesize_attrs(struct perf_header *self, event__handler_t process, int perf_event__synthesize_attrs(struct perf_header *self,
struct perf_session *session) perf_event__handler_t process,
struct perf_session *session)
{ {
struct perf_header_attr *attr; struct perf_header_attr *attr;
int i, err = 0; int i, err = 0;
...@@ -1040,8 +1041,8 @@ int event__synthesize_attrs(struct perf_header *self, event__handler_t process, ...@@ -1040,8 +1041,8 @@ int event__synthesize_attrs(struct perf_header *self, event__handler_t process,
for (i = 0; i < self->attrs; i++) { for (i = 0; i < self->attrs; i++) {
attr = self->attr[i]; attr = self->attr[i];
err = event__synthesize_attr(&attr->attr, attr->ids, attr->id, err = perf_event__synthesize_attr(&attr->attr, attr->ids,
process, session); attr->id, process, session);
if (err) { if (err) {
pr_debug("failed to create perf header attribute\n"); pr_debug("failed to create perf header attribute\n");
return err; return err;
...@@ -1051,21 +1052,22 @@ int event__synthesize_attrs(struct perf_header *self, event__handler_t process, ...@@ -1051,21 +1052,22 @@ int event__synthesize_attrs(struct perf_header *self, event__handler_t process,
return err; return err;
} }
int event__process_attr(event_t *self, struct perf_session *session) int perf_event__process_attr(union perf_event *event,
struct perf_session *session)
{ {
struct perf_header_attr *attr; struct perf_header_attr *attr;
unsigned int i, ids, n_ids; unsigned int i, ids, n_ids;
attr = perf_header_attr__new(&self->attr.attr); attr = perf_header_attr__new(&event->attr.attr);
if (attr == NULL) if (attr == NULL)
return -ENOMEM; return -ENOMEM;
ids = self->header.size; ids = event->header.size;
ids -= (void *)&self->attr.id - (void *)self; ids -= (void *)&event->attr.id - (void *)event;
n_ids = ids / sizeof(u64); n_ids = ids / sizeof(u64);
for (i = 0; i < n_ids; i++) { for (i = 0; i < n_ids; i++) {
if (perf_header_attr__add_id(attr, self->attr.id[i]) < 0) { if (perf_header_attr__add_id(attr, event->attr.id[i]) < 0) {
perf_header_attr__delete(attr); perf_header_attr__delete(attr);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1081,11 +1083,11 @@ int event__process_attr(event_t *self, struct perf_session *session) ...@@ -1081,11 +1083,11 @@ int event__process_attr(event_t *self, struct perf_session *session)
return 0; return 0;
} }
int event__synthesize_event_type(u64 event_id, char *name, int perf_event__synthesize_event_type(u64 event_id, char *name,
event__handler_t process, perf_event__handler_t process,
struct perf_session *session) struct perf_session *session)
{ {
event_t ev; union perf_event ev;
size_t size = 0; size_t size = 0;
int err = 0; int err = 0;
...@@ -1106,8 +1108,8 @@ int event__synthesize_event_type(u64 event_id, char *name, ...@@ -1106,8 +1108,8 @@ int event__synthesize_event_type(u64 event_id, char *name,
return err; return err;
} }
int event__synthesize_event_types(event__handler_t process, int perf_event__synthesize_event_types(perf_event__handler_t process,
struct perf_session *session) struct perf_session *session)
{ {
struct perf_trace_event_type *type; struct perf_trace_event_type *type;
int i, err = 0; int i, err = 0;
...@@ -1115,8 +1117,9 @@ int event__synthesize_event_types(event__handler_t process, ...@@ -1115,8 +1117,9 @@ int event__synthesize_event_types(event__handler_t process,
for (i = 0; i < event_count; i++) { for (i = 0; i < event_count; i++) {
type = &events[i]; type = &events[i];
err = event__synthesize_event_type(type->event_id, type->name, err = perf_event__synthesize_event_type(type->event_id,
process, session); type->name, process,
session);
if (err) { if (err) {
pr_debug("failed to create perf header event type\n"); pr_debug("failed to create perf header event type\n");
return err; return err;
...@@ -1126,21 +1129,21 @@ int event__synthesize_event_types(event__handler_t process, ...@@ -1126,21 +1129,21 @@ int event__synthesize_event_types(event__handler_t process,
return err; return err;
} }
int event__process_event_type(event_t *self, int perf_event__process_event_type(union perf_event *event,
struct perf_session *session __unused) struct perf_session *session __unused)
{ {
if (perf_header__push_event(self->event_type.event_type.event_id, if (perf_header__push_event(event->event_type.event_type.event_id,
self->event_type.event_type.name) < 0) event->event_type.event_type.name) < 0)
return -ENOMEM; return -ENOMEM;
return 0; return 0;
} }
int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
event__handler_t process, perf_event__handler_t process,
struct perf_session *session __unused) struct perf_session *session __unused)
{ {
event_t ev; union perf_event ev;
ssize_t size = 0, aligned_size = 0, padding; ssize_t size = 0, aligned_size = 0, padding;
int err = 0; int err = 0;
...@@ -1163,10 +1166,10 @@ int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, ...@@ -1163,10 +1166,10 @@ int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
return aligned_size; return aligned_size;
} }
int event__process_tracing_data(event_t *self, int perf_event__process_tracing_data(union perf_event *event,
struct perf_session *session) struct perf_session *session)
{ {
ssize_t size_read, padding, size = self->tracing_data.size; ssize_t size_read, padding, size = event->tracing_data.size;
off_t offset = lseek(session->fd, 0, SEEK_CUR); off_t offset = lseek(session->fd, 0, SEEK_CUR);
char buf[BUFSIZ]; char buf[BUFSIZ];
...@@ -1192,12 +1195,12 @@ int event__process_tracing_data(event_t *self, ...@@ -1192,12 +1195,12 @@ int event__process_tracing_data(event_t *self,
return size_read + padding; return size_read + padding;
} }
int event__synthesize_build_id(struct dso *pos, u16 misc, int perf_event__synthesize_build_id(struct dso *pos, u16 misc,
event__handler_t process, perf_event__handler_t process,
struct machine *machine, struct machine *machine,
struct perf_session *session) struct perf_session *session)
{ {
event_t ev; union perf_event ev;
size_t len; size_t len;
int err = 0; int err = 0;
...@@ -1220,11 +1223,11 @@ int event__synthesize_build_id(struct dso *pos, u16 misc, ...@@ -1220,11 +1223,11 @@ int event__synthesize_build_id(struct dso *pos, u16 misc,
return err; return err;
} }
int event__process_build_id(event_t *self, int perf_event__process_build_id(union perf_event *event,
struct perf_session *session) struct perf_session *session)
{ {
__event_process_build_id(&self->build_id, __event_process_build_id(&event->build_id,
self->build_id.filename, event->build_id.filename,
session); session);
return 0; return 0;
} }
......
...@@ -100,32 +100,32 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, ...@@ -100,32 +100,32 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
const char *name, bool is_kallsyms); const char *name, bool is_kallsyms);
int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir); int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
event__handler_t process, perf_event__handler_t process,
struct perf_session *session); struct perf_session *session);
int event__synthesize_attrs(struct perf_header *self, int perf_event__synthesize_attrs(struct perf_header *self,
event__handler_t process, perf_event__handler_t process,
struct perf_session *session);
int event__process_attr(event_t *self, struct perf_session *session);
int event__synthesize_event_type(u64 event_id, char *name,
event__handler_t process,
struct perf_session *session); struct perf_session *session);
int event__synthesize_event_types(event__handler_t process, int perf_event__process_attr(union perf_event *event, struct perf_session *session);
struct perf_session *session);
int event__process_event_type(event_t *self, int perf_event__synthesize_event_type(u64 event_id, char *name,
struct perf_session *session); perf_event__handler_t process,
struct perf_session *session);
int event__synthesize_tracing_data(int fd, struct perf_evlist *evlist, int perf_event__synthesize_event_types(perf_event__handler_t process,
event__handler_t process, struct perf_session *session);
int perf_event__process_event_type(union perf_event *event,
struct perf_session *session); struct perf_session *session);
int event__process_tracing_data(event_t *self,
struct perf_session *session);
int event__synthesize_build_id(struct dso *pos, u16 misc,
event__handler_t process,
struct machine *machine,
struct perf_session *session);
int event__process_build_id(event_t *self, struct perf_session *session);
int perf_event__synthesize_tracing_data(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,
perf_event__handler_t process,
struct machine *machine,
struct perf_session *session);
int perf_event__process_build_id(union perf_event *event,
struct perf_session *session);
#endif /* __PERF_HEADER_H */ #endif /* __PERF_HEADER_H */
...@@ -1182,7 +1182,7 @@ size_t hists__fprintf_nr_events(struct hists *self, FILE *fp) ...@@ -1182,7 +1182,7 @@ size_t hists__fprintf_nr_events(struct hists *self, FILE *fp)
size_t ret = 0; size_t ret = 0;
for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) { for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) {
const char *name = event__get_event_name(i); const char *name = perf_event__name(i);
if (!strcmp(name, "UNKNOWN")) if (!strcmp(name, "UNKNOWN"))
continue; continue;
......
This diff is collapsed.
...@@ -57,10 +57,11 @@ struct perf_session { ...@@ -57,10 +57,11 @@ struct perf_session {
struct perf_event_ops; struct perf_event_ops;
typedef int (*event_op)(event_t *self, struct perf_sample *sample, typedef int (*event_op)(union perf_event *self, struct perf_sample *sample,
struct perf_session *session); struct perf_session *session);
typedef int (*event_synth_op)(event_t *self, struct perf_session *session); typedef int (*event_synth_op)(union perf_event *self,
typedef int (*event_op2)(event_t *self, struct perf_session *session, struct perf_session *session);
typedef int (*event_op2)(union perf_event *self, struct perf_session *session,
struct perf_event_ops *ops); struct perf_event_ops *ops);
struct perf_event_ops { struct perf_event_ops {
...@@ -157,11 +158,11 @@ size_t perf_session__fprintf_nr_events(struct perf_session *self, FILE *fp) ...@@ -157,11 +158,11 @@ size_t perf_session__fprintf_nr_events(struct perf_session *self, FILE *fp)
} }
static inline int perf_session__parse_sample(struct perf_session *session, static inline int perf_session__parse_sample(struct perf_session *session,
const event_t *event, const union perf_event *event,
struct perf_sample *sample) struct perf_sample *sample)
{ {
return event__parse_sample(event, session->sample_type, return perf_event__parse_sample(event, session->sample_type,
session->sample_id_all, sample); session->sample_id_all, sample);
} }
#endif /* __PERF_SESSION_H */ #endif /* __PERF_SESSION_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment