perf tools: Rename perf_event_ops to perf_tool

To better reflect that it became the base class for all tools, that must
be in each tool struct and where common stuff will be put.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-qgpc4msetqlwr8y2k7537cxe@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 743eb868
...@@ -278,6 +278,7 @@ LIB_H += util/strbuf.h ...@@ -278,6 +278,7 @@ LIB_H += util/strbuf.h
LIB_H += util/strlist.h LIB_H += util/strlist.h
LIB_H += util/strfilter.h LIB_H += util/strfilter.h
LIB_H += util/svghelper.h LIB_H += util/svghelper.h
LIB_H += util/tool.h
LIB_H += util/run-command.h LIB_H += util/run-command.h
LIB_H += util/sigchain.h LIB_H += util/sigchain.h
LIB_H += util/symbol.h LIB_H += util/symbol.h
......
...@@ -27,11 +27,12 @@ ...@@ -27,11 +27,12 @@
#include "util/sort.h" #include "util/sort.h"
#include "util/hist.h" #include "util/hist.h"
#include "util/session.h" #include "util/session.h"
#include "util/tool.h"
#include <linux/bitmap.h> #include <linux/bitmap.h>
struct perf_annotate { struct perf_annotate {
struct perf_event_ops ops; struct perf_tool tool;
char const *input_name; char const *input_name;
bool force, use_tui, use_stdio; bool force, use_tui, use_stdio;
bool full_paths; bool full_paths;
...@@ -79,13 +80,13 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel, ...@@ -79,13 +80,13 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
return ret; return ret;
} }
static int process_sample_event(struct perf_event_ops *ops, static int process_sample_event(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct machine *machine) struct machine *machine)
{ {
struct perf_annotate *ann = container_of(ops, struct perf_annotate, ops); struct perf_annotate *ann = container_of(tool, struct perf_annotate, tool);
struct addr_location al; struct addr_location al;
if (perf_event__preprocess_sample(event, machine, &al, sample, if (perf_event__preprocess_sample(event, machine, &al, sample,
...@@ -174,7 +175,7 @@ static int __cmd_annotate(struct perf_annotate *ann) ...@@ -174,7 +175,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
u64 total_nr_samples; u64 total_nr_samples;
session = perf_session__new(ann->input_name, O_RDONLY, session = perf_session__new(ann->input_name, O_RDONLY,
ann->force, false, &ann->ops); ann->force, false, &ann->tool);
if (session == NULL) if (session == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -185,7 +186,7 @@ static int __cmd_annotate(struct perf_annotate *ann) ...@@ -185,7 +186,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
goto out_delete; goto out_delete;
} }
ret = perf_session__process_events(session, &ann->ops); ret = perf_session__process_events(session, &ann->tool);
if (ret) if (ret)
goto out_delete; goto out_delete;
...@@ -241,7 +242,7 @@ static const char * const annotate_usage[] = { ...@@ -241,7 +242,7 @@ static const char * const annotate_usage[] = {
int cmd_annotate(int argc, const char **argv, const char *prefix __used) int cmd_annotate(int argc, const char **argv, const char *prefix __used)
{ {
struct perf_annotate annotate = { struct perf_annotate annotate = {
.ops = { .tool = {
.sample = process_sample_event, .sample = process_sample_event,
.mmap = perf_event__process_mmap, .mmap = perf_event__process_mmap,
.comm = perf_event__process_comm, .comm = perf_event__process_comm,
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "util/hist.h" #include "util/hist.h"
#include "util/evsel.h" #include "util/evsel.h"
#include "util/session.h" #include "util/session.h"
#include "util/tool.h"
#include "util/sort.h" #include "util/sort.h"
#include "util/symbol.h" #include "util/symbol.h"
#include "util/util.h" #include "util/util.h"
...@@ -31,7 +32,7 @@ static int hists__add_entry(struct hists *self, ...@@ -31,7 +32,7 @@ static int hists__add_entry(struct hists *self,
return -ENOMEM; return -ENOMEM;
} }
static int diff__process_sample_event(struct perf_event_ops *ops __used, static int diff__process_sample_event(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
...@@ -57,7 +58,7 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used, ...@@ -57,7 +58,7 @@ static int diff__process_sample_event(struct perf_event_ops *ops __used,
return 0; return 0;
} }
static struct perf_event_ops event_ops = { static struct perf_tool perf_diff = {
.sample = diff__process_sample_event, .sample = diff__process_sample_event,
.mmap = perf_event__process_mmap, .mmap = perf_event__process_mmap,
.comm = perf_event__process_comm, .comm = perf_event__process_comm,
...@@ -147,13 +148,13 @@ static int __cmd_diff(void) ...@@ -147,13 +148,13 @@ static int __cmd_diff(void)
int ret, i; int ret, i;
struct perf_session *session[2]; struct perf_session *session[2];
session[0] = perf_session__new(input_old, O_RDONLY, force, false, &event_ops); session[0] = perf_session__new(input_old, O_RDONLY, force, false, &perf_diff);
session[1] = perf_session__new(input_new, O_RDONLY, force, false, &event_ops); session[1] = perf_session__new(input_new, O_RDONLY, force, false, &perf_diff);
if (session[0] == NULL || session[1] == NULL) if (session[0] == NULL || session[1] == NULL)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < 2; ++i) { for (i = 0; i < 2; ++i) {
ret = perf_session__process_events(session[i], &event_ops); ret = perf_session__process_events(session[i], &perf_diff);
if (ret) if (ret)
goto out_delete; goto out_delete;
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "perf.h" #include "perf.h"
#include "util/session.h" #include "util/session.h"
#include "util/tool.h"
#include "util/debug.h" #include "util/debug.h"
#include "util/parse-options.h" #include "util/parse-options.h"
...@@ -16,7 +17,7 @@ ...@@ -16,7 +17,7 @@
static char const *input_name = "-"; static char const *input_name = "-";
static bool inject_build_ids; static bool inject_build_ids;
static int perf_event__repipe_synth(struct perf_event_ops *ops __used, static int perf_event__repipe_synth(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct machine *machine __used) struct machine *machine __used)
{ {
...@@ -37,17 +38,17 @@ static int perf_event__repipe_synth(struct perf_event_ops *ops __used, ...@@ -37,17 +38,17 @@ static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
return 0; return 0;
} }
static int perf_event__repipe_op2_synth(struct perf_event_ops *ops, static int perf_event__repipe_op2_synth(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_session *session __used) struct perf_session *session __used)
{ {
return perf_event__repipe_synth(ops, event, NULL); return perf_event__repipe_synth(tool, event, NULL);
} }
static int perf_event__repipe_event_type_synth(struct perf_event_ops *ops, static int perf_event__repipe_event_type_synth(struct perf_tool *tool,
union perf_event *event) union perf_event *event)
{ {
return perf_event__repipe_synth(ops, event, NULL); return perf_event__repipe_synth(tool, event, NULL);
} }
static int perf_event__repipe_tracing_data_synth(union perf_event *event, static int perf_event__repipe_tracing_data_synth(union perf_event *event,
...@@ -62,45 +63,45 @@ static int perf_event__repipe_attr(union perf_event *event, ...@@ -62,45 +63,45 @@ static int perf_event__repipe_attr(union perf_event *event,
return perf_event__repipe_synth(NULL, event, NULL); return perf_event__repipe_synth(NULL, event, NULL);
} }
static int perf_event__repipe(struct perf_event_ops *ops, static int perf_event__repipe(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct machine *machine) struct machine *machine)
{ {
return perf_event__repipe_synth(ops, event, machine); return perf_event__repipe_synth(tool, event, machine);
} }
static int perf_event__repipe_sample(struct perf_event_ops *ops, static int perf_event__repipe_sample(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
struct machine *machine) struct machine *machine)
{ {
return perf_event__repipe_synth(ops, event, machine); return perf_event__repipe_synth(tool, event, machine);
} }
static int perf_event__repipe_mmap(struct perf_event_ops *ops, static int perf_event__repipe_mmap(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct machine *machine) struct machine *machine)
{ {
int err; int err;
err = perf_event__process_mmap(ops, event, sample, machine); err = perf_event__process_mmap(tool, event, sample, machine);
perf_event__repipe(ops, event, sample, machine); perf_event__repipe(tool, event, sample, machine);
return err; return err;
} }
static int perf_event__repipe_task(struct perf_event_ops *ops, static int perf_event__repipe_task(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct machine *machine) struct machine *machine)
{ {
int err; int err;
err = perf_event__process_task(ops, event, sample, machine); err = perf_event__process_task(tool, event, sample, machine);
perf_event__repipe(ops, event, sample, machine); perf_event__repipe(tool, event, sample, machine);
return err; return err;
} }
...@@ -130,7 +131,7 @@ static int dso__read_build_id(struct dso *self) ...@@ -130,7 +131,7 @@ static int dso__read_build_id(struct dso *self)
return -1; return -1;
} }
static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops, static int dso__inject_build_id(struct dso *self, struct perf_tool *tool,
struct machine *machine) struct machine *machine)
{ {
u16 misc = PERF_RECORD_MISC_USER; u16 misc = PERF_RECORD_MISC_USER;
...@@ -144,7 +145,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops, ...@@ -144,7 +145,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
if (self->kernel) if (self->kernel)
misc = PERF_RECORD_MISC_KERNEL; misc = PERF_RECORD_MISC_KERNEL;
err = perf_event__synthesize_build_id(ops, self, misc, perf_event__repipe, err = perf_event__synthesize_build_id(tool, self, misc, perf_event__repipe,
machine); machine);
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);
...@@ -154,7 +155,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops, ...@@ -154,7 +155,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops,
return 0; return 0;
} }
static int perf_event__inject_buildid(struct perf_event_ops *ops, static int perf_event__inject_buildid(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
...@@ -180,7 +181,7 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops, ...@@ -180,7 +181,7 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
if (!al.map->dso->hit) { if (!al.map->dso->hit) {
al.map->dso->hit = 1; al.map->dso->hit = 1;
if (map__load(al.map, NULL) >= 0) { if (map__load(al.map, NULL) >= 0) {
dso__inject_build_id(al.map->dso, ops, machine); dso__inject_build_id(al.map->dso, tool, machine);
/* /*
* If this fails, too bad, let the other side * If this fails, too bad, let the other side
* account this as unresolved. * account this as unresolved.
...@@ -193,11 +194,11 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops, ...@@ -193,11 +194,11 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
} }
repipe: repipe:
perf_event__repipe(ops, event, sample, machine); perf_event__repipe(tool, event, sample, machine);
return 0; return 0;
} }
struct perf_event_ops inject_ops = { struct perf_tool perf_inject = {
.sample = perf_event__repipe_sample, .sample = perf_event__repipe_sample,
.mmap = perf_event__repipe, .mmap = perf_event__repipe,
.comm = perf_event__repipe, .comm = perf_event__repipe,
...@@ -228,17 +229,17 @@ static int __cmd_inject(void) ...@@ -228,17 +229,17 @@ static int __cmd_inject(void)
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
if (inject_build_ids) { if (inject_build_ids) {
inject_ops.sample = perf_event__inject_buildid; perf_inject.sample = perf_event__inject_buildid;
inject_ops.mmap = perf_event__repipe_mmap; perf_inject.mmap = perf_event__repipe_mmap;
inject_ops.fork = perf_event__repipe_task; perf_inject.fork = perf_event__repipe_task;
inject_ops.tracing_data = perf_event__repipe_tracing_data; perf_inject.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, &perf_inject);
if (session == NULL) if (session == NULL)
return -ENOMEM; return -ENOMEM;
ret = perf_session__process_events(session, &inject_ops); ret = perf_session__process_events(session, &perf_inject);
perf_session__delete(session); perf_session__delete(session);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "util/thread.h" #include "util/thread.h"
#include "util/header.h" #include "util/header.h"
#include "util/session.h" #include "util/session.h"
#include "util/tool.h"
#include "util/parse-options.h" #include "util/parse-options.h"
#include "util/trace-event.h" #include "util/trace-event.h"
...@@ -303,7 +304,7 @@ static void process_raw_event(union perf_event *raw_event __used, void *data, ...@@ -303,7 +304,7 @@ static void process_raw_event(union perf_event *raw_event __used, void *data,
} }
} }
static int process_sample_event(struct perf_event_ops *ops __used, static int process_sample_event(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
...@@ -325,7 +326,7 @@ static int process_sample_event(struct perf_event_ops *ops __used, ...@@ -325,7 +326,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,
return 0; return 0;
} }
static struct perf_event_ops event_ops = { static struct perf_tool perf_kmem = {
.sample = process_sample_event, .sample = process_sample_event,
.comm = perf_event__process_comm, .comm = perf_event__process_comm,
.ordered_samples = true, .ordered_samples = true,
...@@ -484,7 +485,7 @@ static int __cmd_kmem(void) ...@@ -484,7 +485,7 @@ static int __cmd_kmem(void)
{ {
int err = -EINVAL; int err = -EINVAL;
struct perf_session *session = perf_session__new(input_name, O_RDONLY, struct perf_session *session = perf_session__new(input_name, O_RDONLY,
0, false, &event_ops); 0, false, &perf_kmem);
if (session == NULL) if (session == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -495,7 +496,7 @@ static int __cmd_kmem(void) ...@@ -495,7 +496,7 @@ static int __cmd_kmem(void)
goto out_delete; goto out_delete;
setup_pager(); setup_pager();
err = perf_session__process_events(session, &event_ops); err = perf_session__process_events(session, &perf_kmem);
if (err != 0) if (err != 0)
goto out_delete; goto out_delete;
sort_result(); sort_result();
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "util/debug.h" #include "util/debug.h"
#include "util/session.h" #include "util/session.h"
#include "util/tool.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/prctl.h> #include <sys/prctl.h>
...@@ -845,7 +846,7 @@ static void dump_info(void) ...@@ -845,7 +846,7 @@ static void dump_info(void)
die("Unknown type of information\n"); die("Unknown type of information\n");
} }
static int process_sample_event(struct perf_event_ops *ops __used, static int process_sample_event(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
...@@ -864,7 +865,7 @@ static int process_sample_event(struct perf_event_ops *ops __used, ...@@ -864,7 +865,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,
return 0; return 0;
} }
static struct perf_event_ops eops = { static struct perf_tool eops = {
.sample = process_sample_event, .sample = process_sample_event,
.comm = perf_event__process_comm, .comm = perf_event__process_comm,
.ordered_samples = true, .ordered_samples = true,
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "util/evsel.h" #include "util/evsel.h"
#include "util/debug.h" #include "util/debug.h"
#include "util/session.h" #include "util/session.h"
#include "util/tool.h"
#include "util/symbol.h" #include "util/symbol.h"
#include "util/cpumap.h" #include "util/cpumap.h"
#include "util/thread_map.h" #include "util/thread_map.h"
...@@ -36,7 +37,7 @@ enum write_mode_t { ...@@ -36,7 +37,7 @@ enum write_mode_t {
}; };
struct perf_record { struct perf_record {
struct perf_event_ops ops; struct perf_tool tool;
struct perf_record_opts opts; struct perf_record_opts opts;
u64 bytes_written; u64 bytes_written;
const char *output_name; const char *output_name;
...@@ -76,12 +77,12 @@ static void write_output(struct perf_record *rec, void *buf, size_t size) ...@@ -76,12 +77,12 @@ static void write_output(struct perf_record *rec, void *buf, size_t size)
} }
} }
static int process_synthesized_event(struct perf_event_ops *ops, static int process_synthesized_event(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct machine *machine __used) struct machine *machine __used)
{ {
struct perf_record *rec = container_of(ops, struct perf_record, ops); struct perf_record *rec = container_of(tool, struct perf_record, tool);
write_output(rec, event, event->header.size); write_output(rec, event, event->header.size);
return 0; return 0;
} }
...@@ -319,7 +320,7 @@ static void perf_record__exit(int status __used, void *arg) ...@@ -319,7 +320,7 @@ static void perf_record__exit(int status __used, void *arg)
static void perf_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_event_ops *ops = data; struct perf_tool *tool = data;
if (machine__is_host(machine)) if (machine__is_host(machine))
return; return;
...@@ -332,7 +333,7 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data) ...@@ -332,7 +333,7 @@ static void perf_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 = perf_event__synthesize_modules(ops, process_synthesized_event, err = perf_event__synthesize_modules(tool, process_synthesized_event,
machine); 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"
...@@ -342,10 +343,10 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data) ...@@ -342,10 +343,10 @@ static void perf_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 = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
machine, "_text"); machine, "_text");
if (err < 0) if (err < 0)
err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
machine, "_stext"); 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"
...@@ -378,7 +379,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) ...@@ -378,7 +379,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
unsigned long waking = 0; unsigned long waking = 0;
const bool forks = argc > 0; const bool forks = argc > 0;
struct machine *machine; struct machine *machine;
struct perf_event_ops *ops = &rec->ops; struct perf_tool *tool = &rec->tool;
struct perf_record_opts *opts = &rec->opts; struct perf_record_opts *opts = &rec->opts;
struct perf_evlist *evsel_list = rec->evlist; struct perf_evlist *evsel_list = rec->evlist;
const char *output_name = rec->output_name; const char *output_name = rec->output_name;
...@@ -501,14 +502,14 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) ...@@ -501,14 +502,14 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
} }
if (opts->pipe_output) { if (opts->pipe_output) {
err = perf_event__synthesize_attrs(ops, session, err = perf_event__synthesize_attrs(tool, session,
process_synthesized_event); process_synthesized_event);
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 = perf_event__synthesize_event_types(ops, process_synthesized_event, err = perf_event__synthesize_event_types(tool, process_synthesized_event,
machine); machine);
if (err < 0) { if (err < 0) {
pr_err("Couldn't synthesize event_types.\n"); pr_err("Couldn't synthesize event_types.\n");
...@@ -524,7 +525,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) ...@@ -524,7 +525,7 @@ static int __cmd_record(struct perf_record *rec, 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 = perf_event__synthesize_tracing_data(ops, output, evsel_list, err = perf_event__synthesize_tracing_data(tool, output, evsel_list,
process_synthesized_event); process_synthesized_event);
if (err <= 0) { if (err <= 0) {
pr_err("Couldn't record tracing data.\n"); pr_err("Couldn't record tracing data.\n");
...@@ -534,17 +535,17 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) ...@@ -534,17 +535,17 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
} }
} }
err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
machine, "_text"); machine, "_text");
if (err < 0) if (err < 0)
err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event, err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
machine, "_stext"); 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 = perf_event__synthesize_modules(ops, process_synthesized_event, err = perf_event__synthesize_modules(tool, process_synthesized_event,
machine); 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"
...@@ -552,15 +553,15 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) ...@@ -552,15 +553,15 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
"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, ops, perf_session__process_machines(session, tool,
perf_event__synthesize_guest_os); perf_event__synthesize_guest_os);
if (!opts->system_wide) if (!opts->system_wide)
perf_event__synthesize_thread_map(ops, evsel_list->threads, perf_event__synthesize_thread_map(tool, evsel_list->threads,
process_synthesized_event, process_synthesized_event,
machine); machine);
else else
perf_event__synthesize_threads(ops, process_synthesized_event, perf_event__synthesize_threads(tool, process_synthesized_event,
machine); machine);
if (rec->realtime_prio) { if (rec->realtime_prio) {
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "util/evsel.h" #include "util/evsel.h"
#include "util/header.h" #include "util/header.h"
#include "util/session.h" #include "util/session.h"
#include "util/tool.h"
#include "util/parse-options.h" #include "util/parse-options.h"
#include "util/parse-events.h" #include "util/parse-events.h"
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
#include <linux/bitmap.h> #include <linux/bitmap.h>
struct perf_report { struct perf_report {
struct perf_event_ops ops; struct perf_tool tool;
struct perf_session *session; struct perf_session *session;
char const *input_name; char const *input_name;
bool force, use_tui, use_stdio; bool force, use_tui, use_stdio;
...@@ -103,13 +104,13 @@ static int perf_evsel__add_hist_entry(struct perf_evsel *evsel, ...@@ -103,13 +104,13 @@ static int perf_evsel__add_hist_entry(struct perf_evsel *evsel,
} }
static int process_sample_event(struct perf_event_ops *ops, static int process_sample_event(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct machine *machine) struct machine *machine)
{ {
struct perf_report *rep = container_of(ops, struct perf_report, ops); struct perf_report *rep = container_of(tool, struct perf_report, tool);
struct addr_location al; struct addr_location al;
if (perf_event__preprocess_sample(event, machine, &al, sample, if (perf_event__preprocess_sample(event, machine, &al, sample,
...@@ -136,13 +137,13 @@ static int process_sample_event(struct perf_event_ops *ops, ...@@ -136,13 +137,13 @@ static int process_sample_event(struct perf_event_ops *ops,
return 0; return 0;
} }
static int process_read_event(struct perf_event_ops *ops, static int process_read_event(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_evsel *evsel, struct perf_evsel *evsel,
struct machine *machine __used) struct machine *machine __used)
{ {
struct perf_report *rep = container_of(ops, struct perf_report, ops); struct perf_report *rep = container_of(tool, struct perf_report, tool);
if (rep->show_threads) { if (rep->show_threads) {
const char *name = evsel ? event_name(evsel) : "unknown"; const char *name = evsel ? event_name(evsel) : "unknown";
...@@ -254,7 +255,7 @@ static int __cmd_report(struct perf_report *rep) ...@@ -254,7 +255,7 @@ static int __cmd_report(struct perf_report *rep)
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
session = perf_session__new(rep->input_name, O_RDONLY, session = perf_session__new(rep->input_name, O_RDONLY,
rep->force, false, &rep->ops); rep->force, false, &rep->tool);
if (session == NULL) if (session == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -277,7 +278,7 @@ static int __cmd_report(struct perf_report *rep) ...@@ -277,7 +278,7 @@ static int __cmd_report(struct perf_report *rep)
if (ret) if (ret)
goto out_delete; goto out_delete;
ret = perf_session__process_events(session, &rep->ops); ret = perf_session__process_events(session, &rep->tool);
if (ret) if (ret)
goto out_delete; goto out_delete;
...@@ -435,7 +436,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used) ...@@ -435,7 +436,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
NULL NULL
}; };
struct perf_report report = { struct perf_report report = {
.ops = { .tool = {
.sample = process_sample_event, .sample = process_sample_event,
.mmap = perf_event__process_mmap, .mmap = perf_event__process_mmap,
.comm = perf_event__process_comm, .comm = perf_event__process_comm,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "util/thread.h" #include "util/thread.h"
#include "util/header.h" #include "util/header.h"
#include "util/session.h" #include "util/session.h"
#include "util/tool.h"
#include "util/parse-options.h" #include "util/parse-options.h"
#include "util/trace-event.h" #include "util/trace-event.h"
...@@ -1602,7 +1603,7 @@ static void process_raw_event(union perf_event *raw_event __used, ...@@ -1602,7 +1603,7 @@ static void process_raw_event(union perf_event *raw_event __used,
process_sched_migrate_task_event(data, machine, event, cpu, timestamp, thread); process_sched_migrate_task_event(data, machine, event, cpu, timestamp, thread);
} }
static int process_sample_event(struct perf_event_ops *ops __used, static int process_sample_event(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
...@@ -1631,7 +1632,7 @@ static int process_sample_event(struct perf_event_ops *ops __used, ...@@ -1631,7 +1632,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,
return 0; return 0;
} }
static struct perf_event_ops event_ops = { static struct perf_tool perf_sched = {
.sample = process_sample_event, .sample = process_sample_event,
.comm = perf_event__process_comm, .comm = perf_event__process_comm,
.lost = perf_event__process_lost, .lost = perf_event__process_lost,
...@@ -1643,12 +1644,12 @@ static void read_events(bool destroy, struct perf_session **psession) ...@@ -1643,12 +1644,12 @@ static void read_events(bool destroy, struct perf_session **psession)
{ {
int err = -EINVAL; int err = -EINVAL;
struct perf_session *session = perf_session__new(input_name, O_RDONLY, struct perf_session *session = perf_session__new(input_name, O_RDONLY,
0, false, &event_ops); 0, false, &perf_sched);
if (session == NULL) if (session == NULL)
die("No Memory"); die("No Memory");
if (perf_session__has_traces(session, "record -R")) { if (perf_session__has_traces(session, "record -R")) {
err = perf_session__process_events(session, &event_ops); err = perf_session__process_events(session, &perf_sched);
if (err) if (err)
die("Failed to process events, error %d", err); die("Failed to process events, error %d", err);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "util/header.h" #include "util/header.h"
#include "util/parse-options.h" #include "util/parse-options.h"
#include "util/session.h" #include "util/session.h"
#include "util/tool.h"
#include "util/symbol.h" #include "util/symbol.h"
#include "util/thread.h" #include "util/thread.h"
#include "util/trace-event.h" #include "util/trace-event.h"
...@@ -434,7 +435,7 @@ static int cleanup_scripting(void) ...@@ -434,7 +435,7 @@ static int cleanup_scripting(void)
static char const *input_name = "perf.data"; static char const *input_name = "perf.data";
static int process_sample_event(struct perf_event_ops *ops __used, static int process_sample_event(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
...@@ -468,7 +469,7 @@ static int process_sample_event(struct perf_event_ops *ops __used, ...@@ -468,7 +469,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,
return 0; return 0;
} }
static struct perf_event_ops event_ops = { static struct perf_tool perf_script = {
.sample = process_sample_event, .sample = process_sample_event,
.mmap = perf_event__process_mmap, .mmap = perf_event__process_mmap,
.comm = perf_event__process_comm, .comm = perf_event__process_comm,
...@@ -495,7 +496,7 @@ static int __cmd_script(struct perf_session *session) ...@@ -495,7 +496,7 @@ static int __cmd_script(struct perf_session *session)
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
ret = perf_session__process_events(session, &event_ops); ret = perf_session__process_events(session, &perf_script);
if (debug_mode) if (debug_mode)
pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered); pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered);
...@@ -1262,7 +1263,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __used) ...@@ -1262,7 +1263,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)
if (!script_name) if (!script_name)
setup_pager(); setup_pager();
session = perf_session__new(input_name, O_RDONLY, 0, false, &event_ops); session = perf_session__new(input_name, O_RDONLY, 0, false, &perf_script);
if (session == NULL) if (session == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "util/event.h" #include "util/event.h"
#include "util/session.h" #include "util/session.h"
#include "util/svghelper.h" #include "util/svghelper.h"
#include "util/tool.h"
#define SUPPORT_OLD_POWER_EVENTS 1 #define SUPPORT_OLD_POWER_EVENTS 1
#define PWR_EVENT_EXIT -1 #define PWR_EVENT_EXIT -1
...@@ -274,7 +275,7 @@ static int cpus_cstate_state[MAX_CPUS]; ...@@ -274,7 +275,7 @@ 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(struct perf_event_ops *ops __used, static int process_comm_event(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct machine *machine __used) struct machine *machine __used)
...@@ -283,7 +284,7 @@ static int process_comm_event(struct perf_event_ops *ops __used, ...@@ -283,7 +284,7 @@ static int process_comm_event(struct perf_event_ops *ops __used,
return 0; return 0;
} }
static int process_fork_event(struct perf_event_ops *ops __used, static int process_fork_event(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct machine *machine __used) struct machine *machine __used)
...@@ -292,7 +293,7 @@ static int process_fork_event(struct perf_event_ops *ops __used, ...@@ -292,7 +293,7 @@ static int process_fork_event(struct perf_event_ops *ops __used,
return 0; return 0;
} }
static int process_exit_event(struct perf_event_ops *ops __used, static int process_exit_event(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct machine *machine __used) struct machine *machine __used)
...@@ -490,7 +491,7 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te) ...@@ -490,7 +491,7 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te)
} }
static int process_sample_event(struct perf_event_ops *ops __used, static int process_sample_event(struct perf_tool *tool __used,
union perf_event *event __used, union perf_event *event __used,
struct perf_sample *sample, struct perf_sample *sample,
struct perf_evsel *evsel, struct perf_evsel *evsel,
...@@ -979,7 +980,7 @@ static void write_svg_file(const char *filename) ...@@ -979,7 +980,7 @@ static void write_svg_file(const char *filename)
svg_close(); svg_close();
} }
static struct perf_event_ops event_ops = { static struct perf_tool perf_timechart = {
.comm = process_comm_event, .comm = process_comm_event,
.fork = process_fork_event, .fork = process_fork_event,
.exit = process_exit_event, .exit = process_exit_event,
...@@ -990,7 +991,7 @@ static struct perf_event_ops event_ops = { ...@@ -990,7 +991,7 @@ static struct perf_event_ops event_ops = {
static int __cmd_timechart(void) static int __cmd_timechart(void)
{ {
struct perf_session *session = perf_session__new(input_name, O_RDONLY, struct perf_session *session = perf_session__new(input_name, O_RDONLY,
0, false, &event_ops); 0, false, &perf_timechart);
int ret = -EINVAL; int ret = -EINVAL;
if (session == NULL) if (session == NULL)
...@@ -999,7 +1000,7 @@ static int __cmd_timechart(void) ...@@ -999,7 +1000,7 @@ static int __cmd_timechart(void)
if (!perf_session__has_traces(session, "timechart record")) if (!perf_session__has_traces(session, "timechart record"))
goto out_delete; goto out_delete;
ret = perf_session__process_events(session, &event_ops); ret = perf_session__process_events(session, &perf_timechart);
if (ret) if (ret)
goto out_delete; goto out_delete;
......
...@@ -826,7 +826,7 @@ static void perf_session__mmap_read_idx(struct perf_session *self, int idx) ...@@ -826,7 +826,7 @@ static void perf_session__mmap_read_idx(struct perf_session *self, int idx)
perf_event__process_sample(event, evsel, &sample, machine); perf_event__process_sample(event, evsel, &sample, machine);
else if (event->header.type < PERF_RECORD_MAX) { else if (event->header.type < PERF_RECORD_MAX) {
hists__inc_nr_events(&evsel->hists, event->header.type); hists__inc_nr_events(&evsel->hists, event->header.type);
perf_event__process(&top.ops, event, &sample, machine); perf_event__process(&top.tool, event, &sample, machine);
} else } else
++self->hists.stats.nr_unknown_events; ++self->hists.stats.nr_unknown_events;
} }
...@@ -968,11 +968,11 @@ static int __cmd_top(void) ...@@ -968,11 +968,11 @@ static int __cmd_top(void)
goto out_delete; goto out_delete;
if (top.target_tid != -1) if (top.target_tid != -1)
perf_event__synthesize_thread_map(&top.ops, top.evlist->threads, perf_event__synthesize_thread_map(&top.tool, top.evlist->threads,
perf_event__process, perf_event__process,
&top.session->host_machine); &top.session->host_machine);
else else
perf_event__synthesize_threads(&top.ops, perf_event__process, perf_event__synthesize_threads(&top.tool, perf_event__process,
&top.session->host_machine); &top.session->host_machine);
start_counters(top.evlist); start_counters(top.evlist);
top.session->evlist = top.evlist; top.session->evlist = top.evlist;
......
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include "debug.h" #include "debug.h"
#include "session.h" #include "session.h"
#include "tool.h"
static int build_id__mark_dso_hit(struct perf_event_ops *ops __used, static int build_id__mark_dso_hit(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct perf_evsel *evsel __used, struct perf_evsel *evsel __used,
...@@ -40,7 +41,7 @@ static int build_id__mark_dso_hit(struct perf_event_ops *ops __used, ...@@ -40,7 +41,7 @@ static int build_id__mark_dso_hit(struct perf_event_ops *ops __used,
return 0; return 0;
} }
static int perf_event__exit_del_thread(struct perf_event_ops *ops __used, static int perf_event__exit_del_thread(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct machine *machine) struct machine *machine)
...@@ -59,7 +60,7 @@ static int perf_event__exit_del_thread(struct perf_event_ops *ops __used, ...@@ -59,7 +60,7 @@ static int perf_event__exit_del_thread(struct perf_event_ops *ops __used,
return 0; return 0;
} }
struct perf_event_ops build_id__mark_dso_hit_ops = { struct perf_tool build_id__mark_dso_hit_ops = {
.sample = build_id__mark_dso_hit, .sample = build_id__mark_dso_hit,
.mmap = perf_event__process_mmap, .mmap = perf_event__process_mmap,
.fork = perf_event__process_task, .fork = perf_event__process_task,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "session.h" #include "session.h"
extern struct perf_event_ops build_id__mark_dso_hit_ops; extern struct perf_tool build_id__mark_dso_hit_ops;
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);
......
...@@ -43,7 +43,7 @@ static struct perf_sample synth_sample = { ...@@ -43,7 +43,7 @@ static struct perf_sample synth_sample = {
.period = 1, .period = 1,
}; };
static pid_t perf_event__synthesize_comm(struct perf_event_ops *ops, static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
union perf_event *event, pid_t pid, union perf_event *event, pid_t pid,
int full, perf_event__handler_t process, int full, perf_event__handler_t process,
struct machine *machine) struct machine *machine)
...@@ -99,7 +99,7 @@ static pid_t perf_event__synthesize_comm(struct perf_event_ops *ops, ...@@ -99,7 +99,7 @@ static pid_t perf_event__synthesize_comm(struct perf_event_ops *ops,
if (!full) { if (!full) {
event->comm.tid = pid; event->comm.tid = pid;
process(ops, event, &synth_sample, machine); process(tool, event, &synth_sample, machine);
goto out; goto out;
} }
...@@ -117,7 +117,7 @@ static pid_t perf_event__synthesize_comm(struct perf_event_ops *ops, ...@@ -117,7 +117,7 @@ static pid_t perf_event__synthesize_comm(struct perf_event_ops *ops,
event->comm.tid = pid; event->comm.tid = pid;
process(ops, event, &synth_sample, machine); process(tool, event, &synth_sample, machine);
} }
closedir(tasks); closedir(tasks);
...@@ -127,7 +127,7 @@ static pid_t perf_event__synthesize_comm(struct perf_event_ops *ops, ...@@ -127,7 +127,7 @@ static pid_t perf_event__synthesize_comm(struct perf_event_ops *ops,
return tgid; return tgid;
} }
static int perf_event__synthesize_mmap_events(struct perf_event_ops *ops, static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
pid_t pid, pid_t tgid, pid_t pid, pid_t tgid,
perf_event__handler_t process, perf_event__handler_t process,
...@@ -199,7 +199,7 @@ static int perf_event__synthesize_mmap_events(struct perf_event_ops *ops, ...@@ -199,7 +199,7 @@ static int perf_event__synthesize_mmap_events(struct perf_event_ops *ops,
event->mmap.pid = tgid; event->mmap.pid = tgid;
event->mmap.tid = pid; event->mmap.tid = pid;
process(ops, event, &synth_sample, machine); process(tool, event, &synth_sample, machine);
} }
} }
...@@ -207,7 +207,7 @@ static int perf_event__synthesize_mmap_events(struct perf_event_ops *ops, ...@@ -207,7 +207,7 @@ static int perf_event__synthesize_mmap_events(struct perf_event_ops *ops,
return 0; return 0;
} }
int perf_event__synthesize_modules(struct perf_event_ops *ops, int perf_event__synthesize_modules(struct perf_tool *tool,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine) struct machine *machine)
{ {
...@@ -252,7 +252,7 @@ int perf_event__synthesize_modules(struct perf_event_ops *ops, ...@@ -252,7 +252,7 @@ int perf_event__synthesize_modules(struct perf_event_ops *ops,
memcpy(event->mmap.filename, pos->dso->long_name, memcpy(event->mmap.filename, pos->dso->long_name,
pos->dso->long_name_len + 1); pos->dso->long_name_len + 1);
process(ops, event, &synth_sample, machine); process(tool, event, &synth_sample, machine);
} }
free(event); free(event);
...@@ -262,18 +262,18 @@ int perf_event__synthesize_modules(struct perf_event_ops *ops, ...@@ -262,18 +262,18 @@ int perf_event__synthesize_modules(struct perf_event_ops *ops,
static int __event__synthesize_thread(union perf_event *comm_event, static int __event__synthesize_thread(union perf_event *comm_event,
union perf_event *mmap_event, union perf_event *mmap_event,
pid_t pid, perf_event__handler_t process, pid_t pid, perf_event__handler_t process,
struct perf_event_ops *ops, struct perf_tool *tool,
struct machine *machine) struct machine *machine)
{ {
pid_t tgid = perf_event__synthesize_comm(ops, comm_event, pid, 1, pid_t tgid = perf_event__synthesize_comm(tool, comm_event, pid, 1,
process, machine); process, machine);
if (tgid == -1) if (tgid == -1)
return -1; return -1;
return perf_event__synthesize_mmap_events(ops, mmap_event, pid, tgid, return perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid,
process, machine); process, machine);
} }
int perf_event__synthesize_thread_map(struct perf_event_ops *ops, int perf_event__synthesize_thread_map(struct perf_tool *tool,
struct thread_map *threads, struct thread_map *threads,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine) struct machine *machine)
...@@ -293,7 +293,7 @@ int perf_event__synthesize_thread_map(struct perf_event_ops *ops, ...@@ -293,7 +293,7 @@ int perf_event__synthesize_thread_map(struct perf_event_ops *ops,
for (thread = 0; thread < threads->nr; ++thread) { for (thread = 0; thread < threads->nr; ++thread) {
if (__event__synthesize_thread(comm_event, mmap_event, if (__event__synthesize_thread(comm_event, mmap_event,
threads->map[thread], threads->map[thread],
process, ops, machine)) { process, tool, machine)) {
err = -1; err = -1;
break; break;
} }
...@@ -305,7 +305,7 @@ int perf_event__synthesize_thread_map(struct perf_event_ops *ops, ...@@ -305,7 +305,7 @@ int perf_event__synthesize_thread_map(struct perf_event_ops *ops,
return err; return err;
} }
int perf_event__synthesize_threads(struct perf_event_ops *ops, int perf_event__synthesize_threads(struct perf_tool *tool,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine) struct machine *machine)
{ {
...@@ -334,7 +334,7 @@ int perf_event__synthesize_threads(struct perf_event_ops *ops, ...@@ -334,7 +334,7 @@ int perf_event__synthesize_threads(struct perf_event_ops *ops,
continue; continue;
__event__synthesize_thread(comm_event, mmap_event, pid, __event__synthesize_thread(comm_event, mmap_event, pid,
process, ops, machine); process, tool, machine);
} }
closedir(proc); closedir(proc);
...@@ -369,7 +369,7 @@ static int find_symbol_cb(void *arg, const char *name, char type, ...@@ -369,7 +369,7 @@ static int find_symbol_cb(void *arg, const char *name, char type,
return 1; return 1;
} }
int perf_event__synthesize_kernel_mmap(struct perf_event_ops *ops, int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine, struct machine *machine,
const char *symbol_name) const char *symbol_name)
...@@ -427,13 +427,13 @@ int perf_event__synthesize_kernel_mmap(struct perf_event_ops *ops, ...@@ -427,13 +427,13 @@ int perf_event__synthesize_kernel_mmap(struct perf_event_ops *ops,
event->mmap.len = map->end - event->mmap.start; event->mmap.len = map->end - event->mmap.start;
event->mmap.pid = machine->pid; event->mmap.pid = machine->pid;
err = process(ops, event, &synth_sample, machine); err = process(tool, event, &synth_sample, machine);
free(event); free(event);
return err; return err;
} }
int perf_event__process_comm(struct perf_event_ops *ops __used, int perf_event__process_comm(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct machine *machine) struct machine *machine)
...@@ -450,7 +450,7 @@ int perf_event__process_comm(struct perf_event_ops *ops __used, ...@@ -450,7 +450,7 @@ int perf_event__process_comm(struct perf_event_ops *ops __used,
return 0; return 0;
} }
int perf_event__process_lost(struct perf_event_ops *ops __used, int perf_event__process_lost(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct machine *machine __used) struct machine *machine __used)
...@@ -473,7 +473,7 @@ static void perf_event__set_kernel_mmap_len(union perf_event *event, ...@@ -473,7 +473,7 @@ static void perf_event__set_kernel_mmap_len(union perf_event *event,
maps[MAP__FUNCTION]->end = ~0ULL; maps[MAP__FUNCTION]->end = ~0ULL;
} }
static int perf_event__process_kernel_mmap(struct perf_event_ops *ops __used, static int perf_event__process_kernel_mmap(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct machine *machine) struct machine *machine)
{ {
...@@ -566,7 +566,7 @@ static int perf_event__process_kernel_mmap(struct perf_event_ops *ops __used, ...@@ -566,7 +566,7 @@ static int perf_event__process_kernel_mmap(struct perf_event_ops *ops __used,
return -1; return -1;
} }
int perf_event__process_mmap(struct perf_event_ops *ops, int perf_event__process_mmap(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct machine *machine) struct machine *machine)
...@@ -582,7 +582,7 @@ int perf_event__process_mmap(struct perf_event_ops *ops, ...@@ -582,7 +582,7 @@ int perf_event__process_mmap(struct perf_event_ops *ops,
if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL || if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
cpumode == PERF_RECORD_MISC_KERNEL) { cpumode == PERF_RECORD_MISC_KERNEL) {
ret = perf_event__process_kernel_mmap(ops, event, machine); ret = perf_event__process_kernel_mmap(tool, event, machine);
if (ret < 0) if (ret < 0)
goto out_problem; goto out_problem;
return 0; return 0;
...@@ -606,7 +606,7 @@ int perf_event__process_mmap(struct perf_event_ops *ops, ...@@ -606,7 +606,7 @@ int perf_event__process_mmap(struct perf_event_ops *ops,
return 0; return 0;
} }
int perf_event__process_task(struct perf_event_ops *ops __used, int perf_event__process_task(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __used, struct perf_sample *sample __used,
struct machine *machine) struct machine *machine)
...@@ -631,22 +631,22 @@ int perf_event__process_task(struct perf_event_ops *ops __used, ...@@ -631,22 +631,22 @@ int perf_event__process_task(struct perf_event_ops *ops __used,
return 0; return 0;
} }
int perf_event__process(struct perf_event_ops *ops, union perf_event *event, int perf_event__process(struct perf_tool *tool, union perf_event *event,
struct perf_sample *sample, struct machine *machine) struct perf_sample *sample, struct machine *machine)
{ {
switch (event->header.type) { switch (event->header.type) {
case PERF_RECORD_COMM: case PERF_RECORD_COMM:
perf_event__process_comm(ops, event, sample, machine); perf_event__process_comm(tool, event, sample, machine);
break; break;
case PERF_RECORD_MMAP: case PERF_RECORD_MMAP:
perf_event__process_mmap(ops, event, sample, machine); perf_event__process_mmap(tool, event, sample, machine);
break; break;
case PERF_RECORD_FORK: case PERF_RECORD_FORK:
case PERF_RECORD_EXIT: case PERF_RECORD_EXIT:
perf_event__process_task(ops, event, sample, machine); perf_event__process_task(tool, event, sample, machine);
break; break;
case PERF_RECORD_LOST: case PERF_RECORD_LOST:
perf_event__process_lost(ops, event, sample, machine); perf_event__process_lost(tool, event, sample, machine);
default: default:
break; break;
} }
......
...@@ -141,47 +141,47 @@ union perf_event { ...@@ -141,47 +141,47 @@ union perf_event {
void perf_event__print_totals(void); void perf_event__print_totals(void);
struct perf_event_ops; struct perf_tool;
struct thread_map; struct thread_map;
typedef int (*perf_event__handler_t)(struct perf_event_ops *ops, typedef int (*perf_event__handler_t)(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct machine *machine); struct machine *machine);
int perf_event__synthesize_thread_map(struct perf_event_ops *ops, int perf_event__synthesize_thread_map(struct perf_tool *tool,
struct thread_map *threads, struct thread_map *threads,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine); struct machine *machine);
int perf_event__synthesize_threads(struct perf_event_ops *ops, int perf_event__synthesize_threads(struct perf_tool *tool,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine); struct machine *machine);
int perf_event__synthesize_kernel_mmap(struct perf_event_ops *ops, int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine, struct machine *machine,
const char *symbol_name); const char *symbol_name);
int perf_event__synthesize_modules(struct perf_event_ops *ops, int perf_event__synthesize_modules(struct perf_tool *tool,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine); struct machine *machine);
int perf_event__process_comm(struct perf_event_ops *ops, int perf_event__process_comm(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct machine *machine); struct machine *machine);
int perf_event__process_lost(struct perf_event_ops *ops, int perf_event__process_lost(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct machine *machine); struct machine *machine);
int perf_event__process_mmap(struct perf_event_ops *ops, int perf_event__process_mmap(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct machine *machine); struct machine *machine);
int perf_event__process_task(struct perf_event_ops *ops, int perf_event__process_task(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct machine *machine); struct machine *machine);
int perf_event__process(struct perf_event_ops *ops, int perf_event__process(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_sample *sample, struct perf_sample *sample,
struct machine *machine); struct machine *machine);
......
...@@ -2070,7 +2070,7 @@ int perf_session__read_header(struct perf_session *session, int fd) ...@@ -2070,7 +2070,7 @@ int perf_session__read_header(struct perf_session *session, int fd)
return -ENOMEM; return -ENOMEM;
} }
int perf_event__synthesize_attr(struct perf_event_ops *ops, int perf_event__synthesize_attr(struct perf_tool *tool,
struct perf_event_attr *attr, u16 ids, u64 *id, struct perf_event_attr *attr, u16 ids, u64 *id,
perf_event__handler_t process) perf_event__handler_t process)
{ {
...@@ -2094,14 +2094,14 @@ int perf_event__synthesize_attr(struct perf_event_ops *ops, ...@@ -2094,14 +2094,14 @@ int perf_event__synthesize_attr(struct perf_event_ops *ops,
ev->attr.header.type = PERF_RECORD_HEADER_ATTR; ev->attr.header.type = PERF_RECORD_HEADER_ATTR;
ev->attr.header.size = size; ev->attr.header.size = size;
err = process(ops, ev, NULL, NULL); err = process(tool, ev, NULL, NULL);
free(ev); free(ev);
return err; return err;
} }
int perf_event__synthesize_attrs(struct perf_event_ops *ops, int perf_event__synthesize_attrs(struct perf_tool *tool,
struct perf_session *session, struct perf_session *session,
perf_event__handler_t process) perf_event__handler_t process)
{ {
...@@ -2109,7 +2109,7 @@ int perf_event__synthesize_attrs(struct perf_event_ops *ops, ...@@ -2109,7 +2109,7 @@ int perf_event__synthesize_attrs(struct perf_event_ops *ops,
int err = 0; int err = 0;
list_for_each_entry(attr, &session->evlist->entries, node) { list_for_each_entry(attr, &session->evlist->entries, node) {
err = perf_event__synthesize_attr(ops, &attr->attr, attr->ids, err = perf_event__synthesize_attr(tool, &attr->attr, attr->ids,
attr->id, process); attr->id, process);
if (err) { if (err) {
pr_debug("failed to create perf header attribute\n"); pr_debug("failed to create perf header attribute\n");
...@@ -2157,7 +2157,7 @@ int perf_event__process_attr(union perf_event *event, ...@@ -2157,7 +2157,7 @@ int perf_event__process_attr(union perf_event *event,
return 0; return 0;
} }
int perf_event__synthesize_event_type(struct perf_event_ops *ops, int perf_event__synthesize_event_type(struct perf_tool *tool,
u64 event_id, char *name, u64 event_id, char *name,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine) struct machine *machine)
...@@ -2178,12 +2178,12 @@ int perf_event__synthesize_event_type(struct perf_event_ops *ops, ...@@ -2178,12 +2178,12 @@ int perf_event__synthesize_event_type(struct perf_event_ops *ops,
ev.event_type.header.size = sizeof(ev.event_type) - ev.event_type.header.size = sizeof(ev.event_type) -
(sizeof(ev.event_type.event_type.name) - size); (sizeof(ev.event_type.event_type.name) - size);
err = process(ops, &ev, NULL, machine); err = process(tool, &ev, NULL, machine);
return err; return err;
} }
int perf_event__synthesize_event_types(struct perf_event_ops *ops, int perf_event__synthesize_event_types(struct perf_tool *tool,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine) struct machine *machine)
{ {
...@@ -2193,7 +2193,7 @@ int perf_event__synthesize_event_types(struct perf_event_ops *ops, ...@@ -2193,7 +2193,7 @@ int perf_event__synthesize_event_types(struct perf_event_ops *ops,
for (i = 0; i < event_count; i++) { for (i = 0; i < event_count; i++) {
type = &events[i]; type = &events[i];
err = perf_event__synthesize_event_type(ops, type->event_id, err = perf_event__synthesize_event_type(tool, type->event_id,
type->name, process, type->name, process,
machine); machine);
if (err) { if (err) {
...@@ -2205,7 +2205,7 @@ int perf_event__synthesize_event_types(struct perf_event_ops *ops, ...@@ -2205,7 +2205,7 @@ int perf_event__synthesize_event_types(struct perf_event_ops *ops,
return err; return err;
} }
int perf_event__process_event_type(struct perf_event_ops *ops __unused, int perf_event__process_event_type(struct perf_tool *tool __unused,
union perf_event *event) union perf_event *event)
{ {
if (perf_header__push_event(event->event_type.event_type.event_id, if (perf_header__push_event(event->event_type.event_type.event_id,
...@@ -2215,7 +2215,7 @@ int perf_event__process_event_type(struct perf_event_ops *ops __unused, ...@@ -2215,7 +2215,7 @@ int perf_event__process_event_type(struct perf_event_ops *ops __unused,
return 0; return 0;
} }
int perf_event__synthesize_tracing_data(struct perf_event_ops *ops, int fd, int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd,
struct perf_evlist *evlist, struct perf_evlist *evlist,
perf_event__handler_t process) perf_event__handler_t process)
{ {
...@@ -2248,7 +2248,7 @@ int perf_event__synthesize_tracing_data(struct perf_event_ops *ops, int fd, ...@@ -2248,7 +2248,7 @@ int perf_event__synthesize_tracing_data(struct perf_event_ops *ops, int fd,
ev.tracing_data.header.size = sizeof(ev.tracing_data); ev.tracing_data.header.size = sizeof(ev.tracing_data);
ev.tracing_data.size = aligned_size; ev.tracing_data.size = aligned_size;
process(ops, &ev, NULL, NULL); process(tool, &ev, NULL, NULL);
/* /*
* The put function will copy all the tracing data * The put function will copy all the tracing data
...@@ -2290,7 +2290,7 @@ int perf_event__process_tracing_data(union perf_event *event, ...@@ -2290,7 +2290,7 @@ int perf_event__process_tracing_data(union perf_event *event,
return size_read + padding; return size_read + padding;
} }
int perf_event__synthesize_build_id(struct perf_event_ops *ops, int perf_event__synthesize_build_id(struct perf_tool *tool,
struct dso *pos, u16 misc, struct dso *pos, u16 misc,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine) struct machine *machine)
...@@ -2313,12 +2313,12 @@ int perf_event__synthesize_build_id(struct perf_event_ops *ops, ...@@ -2313,12 +2313,12 @@ int perf_event__synthesize_build_id(struct perf_event_ops *ops,
ev.build_id.header.size = sizeof(ev.build_id) + len; ev.build_id.header.size = sizeof(ev.build_id) + len;
memcpy(&ev.build_id.filename, pos->long_name, pos->long_name_len); memcpy(&ev.build_id.filename, pos->long_name, pos->long_name_len);
err = process(ops, &ev, NULL, machine); err = process(tool, &ev, NULL, machine);
return err; return err;
} }
int perf_event__process_build_id(struct perf_event_ops *ops __used, int perf_event__process_build_id(struct perf_tool *tool __used,
union perf_event *event, union perf_event *event,
struct perf_session *session) struct perf_session *session)
{ {
......
...@@ -97,35 +97,35 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, ...@@ -97,35 +97,35 @@ 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 perf_event__synthesize_attr(struct perf_event_ops *ops, int perf_event__synthesize_attr(struct perf_tool *tool,
struct perf_event_attr *attr, u16 ids, u64 *id, struct perf_event_attr *attr, u16 ids, u64 *id,
perf_event__handler_t process); perf_event__handler_t process);
int perf_event__synthesize_attrs(struct perf_event_ops *ops, int perf_event__synthesize_attrs(struct perf_tool *tool,
struct perf_session *session, struct perf_session *session,
perf_event__handler_t process); perf_event__handler_t process);
int perf_event__process_attr(union perf_event *event, struct perf_evlist **pevlist); int perf_event__process_attr(union perf_event *event, struct perf_evlist **pevlist);
int perf_event__synthesize_event_type(struct perf_event_ops *ops, int perf_event__synthesize_event_type(struct perf_tool *tool,
u64 event_id, char *name, u64 event_id, char *name,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine); struct machine *machine);
int perf_event__synthesize_event_types(struct perf_event_ops *ops, int perf_event__synthesize_event_types(struct perf_tool *tool,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine); struct machine *machine);
int perf_event__process_event_type(struct perf_event_ops *ops, int perf_event__process_event_type(struct perf_tool *tool,
union perf_event *event); union perf_event *event);
int perf_event__synthesize_tracing_data(struct perf_event_ops *ops, int perf_event__synthesize_tracing_data(struct perf_tool *tool,
int fd, struct perf_evlist *evlist, int fd, struct perf_evlist *evlist,
perf_event__handler_t process); perf_event__handler_t process);
int perf_event__process_tracing_data(union perf_event *event, int perf_event__process_tracing_data(union perf_event *event,
struct perf_session *session); struct perf_session *session);
int perf_event__synthesize_build_id(struct perf_event_ops *ops, int perf_event__synthesize_build_id(struct perf_tool *tool,
struct dso *pos, u16 misc, struct dso *pos, u16 misc,
perf_event__handler_t process, perf_event__handler_t process,
struct machine *machine); struct machine *machine);
int perf_event__process_build_id(struct perf_event_ops *ops, int perf_event__process_build_id(struct perf_tool *tool,
union perf_event *event, union perf_event *event,
struct perf_session *session); struct perf_session *session);
......
This diff is collapsed.
...@@ -53,55 +53,20 @@ struct perf_session { ...@@ -53,55 +53,20 @@ struct perf_session {
char filename[0]; char filename[0];
}; };
struct perf_evsel; struct perf_tool;
struct perf_event_ops;
typedef int (*event_sample)(struct perf_event_ops *ops,
union perf_event *event, struct perf_sample *sample,
struct perf_evsel *evsel, struct machine *machine);
typedef int (*event_op)(struct perf_event_ops *ops, union perf_event *event,
struct perf_sample *sample,
struct machine *machine);
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_simple_op)(struct perf_event_ops *ops,
union perf_event *event);
typedef int (*event_op2)(struct perf_event_ops *ops, union perf_event *event,
struct perf_session *session);
struct perf_event_ops {
event_sample sample,
read;
event_op mmap,
comm,
fork,
exit,
lost,
throttle,
unthrottle;
event_attr_op attr;
event_synth_op tracing_data;
event_simple_op event_type;
event_op2 finished_round,
build_id;
bool ordered_samples;
bool ordering_requires_timestamps;
};
struct perf_session *perf_session__new(const char *filename, int mode, struct perf_session *perf_session__new(const char *filename, int mode,
bool force, bool repipe, bool force, bool repipe,
struct perf_event_ops *ops); struct perf_tool *tool);
void perf_session__delete(struct perf_session *self); void perf_session__delete(struct perf_session *self);
void perf_event_header__bswap(struct perf_event_header *self); void perf_event_header__bswap(struct perf_event_header *self);
int __perf_session__process_events(struct perf_session *self, int __perf_session__process_events(struct perf_session *self,
u64 data_offset, u64 data_size, u64 size, u64 data_offset, u64 data_size, u64 size,
struct perf_event_ops *ops); struct perf_tool *tool);
int perf_session__process_events(struct perf_session *self, int perf_session__process_events(struct perf_session *self,
struct perf_event_ops *event_ops); struct perf_tool *tool);
int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel, int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel,
struct thread *thread, struct thread *thread,
...@@ -142,11 +107,11 @@ struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t p ...@@ -142,11 +107,11 @@ struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t p
static inline static inline
void perf_session__process_machines(struct perf_session *self, void perf_session__process_machines(struct perf_session *self,
struct perf_event_ops *ops, struct perf_tool *tool,
machine__process_t process) machine__process_t process)
{ {
process(&self->host_machine, ops); process(&self->host_machine, tool);
return machines__process(&self->machines, process, ops); return machines__process(&self->machines, process, tool);
} }
struct thread *perf_session__findnew(struct perf_session *self, pid_t pid); struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
......
#ifndef __PERF_TOOL_H
#define __PERF_TOOL_H
struct perf_session;
struct perf_evsel;
struct perf_tool;
struct machine;
typedef int (*event_sample)(struct perf_tool *tool, union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel, struct machine *machine);
typedef int (*event_op)(struct perf_tool *tool, union perf_event *event,
struct perf_sample *sample, struct machine *machine);
typedef int (*event_attr_op)(union perf_event *event,
struct perf_evlist **pevlist);
typedef int (*event_simple_op)(struct perf_tool *tool, union perf_event *event);
typedef int (*event_synth_op)(union perf_event *event,
struct perf_session *session);
typedef int (*event_op2)(struct perf_tool *tool, union perf_event *event,
struct perf_session *session);
struct perf_tool {
event_sample sample,
read;
event_op mmap,
comm,
fork,
exit,
lost,
throttle,
unthrottle;
event_attr_op attr;
event_synth_op tracing_data;
event_simple_op event_type;
event_op2 finished_round,
build_id;
bool ordered_samples;
bool ordering_requires_timestamps;
};
#endif /* __PERF_TOOL_H */
#ifndef __PERF_TOP_H #ifndef __PERF_TOP_H
#define __PERF_TOP_H 1 #define __PERF_TOP_H 1
#include "tool.h"
#include "types.h" #include "types.h"
#include "session.h"
#include "../perf.h"
#include <stddef.h> #include <stddef.h>
#include <stdbool.h>
struct perf_evlist; struct perf_evlist;
struct perf_evsel; struct perf_evsel;
struct perf_session;
struct perf_top { struct perf_top {
struct perf_event_ops ops; struct perf_tool tool;
struct perf_evlist *evlist; struct perf_evlist *evlist;
/* /*
* Symbols will be added here in perf_event__process_sample and will * Symbols will be added here in perf_event__process_sample and will
......
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