LIB_H += util/strlist.h
LIB_H += util/strfilter.h
LIB_H += util/svghelper.h
+LIB_H += util/tool.h
LIB_H += util/run-command.h
LIB_H += util/sigchain.h
LIB_H += util/symbol.h
#include "util/sort.h"
#include "util/hist.h"
#include "util/session.h"
+#include "util/tool.h"
#include <linux/bitmap.h>
struct perf_annotate {
- struct perf_event_ops ops;
+ struct perf_tool tool;
char const *input_name;
bool force, use_tui, use_stdio;
bool full_paths;
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,
struct perf_sample *sample,
struct perf_evsel *evsel,
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;
if (perf_event__preprocess_sample(event, machine, &al, sample,
u64 total_nr_samples;
session = perf_session__new(ann->input_name, O_RDONLY,
- ann->force, false, &ann->ops);
+ ann->force, false, &ann->tool);
if (session == NULL)
return -ENOMEM;
goto out_delete;
}
- ret = perf_session__process_events(session, &ann->ops);
+ ret = perf_session__process_events(session, &ann->tool);
if (ret)
goto out_delete;
int cmd_annotate(int argc, const char **argv, const char *prefix __used)
{
struct perf_annotate annotate = {
- .ops = {
+ .tool = {
.sample = process_sample_event,
.mmap = perf_event__process_mmap,
.comm = perf_event__process_comm,
#include "util/hist.h"
#include "util/evsel.h"
#include "util/session.h"
+#include "util/tool.h"
#include "util/sort.h"
#include "util/symbol.h"
#include "util/util.h"
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,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
return 0;
}
-static struct perf_event_ops event_ops = {
+static struct perf_tool perf_diff = {
.sample = diff__process_sample_event,
.mmap = perf_event__process_mmap,
.comm = perf_event__process_comm,
int ret, i;
struct perf_session *session[2];
- session[0] = perf_session__new(input_old, O_RDONLY, force, false, &event_ops);
- session[1] = perf_session__new(input_new, 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, &perf_diff);
if (session[0] == NULL || session[1] == NULL)
return -ENOMEM;
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)
goto out_delete;
}
#include "perf.h"
#include "util/session.h"
+#include "util/tool.h"
#include "util/debug.h"
#include "util/parse-options.h"
static char const *input_name = "-";
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,
struct machine *machine __used)
{
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,
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)
{
- 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,
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,
struct perf_sample *sample __used,
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,
struct perf_sample *sample __used,
struct perf_evsel *evsel __used,
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,
struct perf_sample *sample,
struct machine *machine)
{
int err;
- err = perf_event__process_mmap(ops, event, sample, machine);
- perf_event__repipe(ops, event, sample, machine);
+ err = perf_event__process_mmap(tool, event, sample, machine);
+ perf_event__repipe(tool, event, sample, machine);
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,
struct perf_sample *sample,
struct machine *machine)
{
int err;
- err = perf_event__process_task(ops, event, sample, machine);
- perf_event__repipe(ops, event, sample, machine);
+ err = perf_event__process_task(tool, event, sample, machine);
+ perf_event__repipe(tool, event, sample, machine);
return err;
}
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)
{
u16 misc = PERF_RECORD_MISC_USER;
if (self->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);
if (err) {
pr_err("Can't synthesize build_id event for %s\n", self->long_name);
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,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
if (!al.map->dso->hit) {
al.map->dso->hit = 1;
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
* account this as unresolved.
}
repipe:
- perf_event__repipe(ops, event, sample, machine);
+ perf_event__repipe(tool, event, sample, machine);
return 0;
}
-struct perf_event_ops inject_ops = {
+struct perf_tool perf_inject = {
.sample = perf_event__repipe_sample,
.mmap = perf_event__repipe,
.comm = perf_event__repipe,
signal(SIGINT, sig_handler);
if (inject_build_ids) {
- inject_ops.sample = perf_event__inject_buildid;
- inject_ops.mmap = perf_event__repipe_mmap;
- inject_ops.fork = perf_event__repipe_task;
- inject_ops.tracing_data = perf_event__repipe_tracing_data;
+ perf_inject.sample = perf_event__inject_buildid;
+ perf_inject.mmap = perf_event__repipe_mmap;
+ perf_inject.fork = perf_event__repipe_task;
+ 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)
return -ENOMEM;
- ret = perf_session__process_events(session, &inject_ops);
+ ret = perf_session__process_events(session, &perf_inject);
perf_session__delete(session);
#include "util/thread.h"
#include "util/header.h"
#include "util/session.h"
+#include "util/tool.h"
#include "util/parse-options.h"
#include "util/trace-event.h"
}
}
-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,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
return 0;
}
-static struct perf_event_ops event_ops = {
+static struct perf_tool perf_kmem = {
.sample = process_sample_event,
.comm = perf_event__process_comm,
.ordered_samples = true,
{
int err = -EINVAL;
struct perf_session *session = perf_session__new(input_name, O_RDONLY,
- 0, false, &event_ops);
+ 0, false, &perf_kmem);
if (session == NULL)
return -ENOMEM;
goto out_delete;
setup_pager();
- err = perf_session__process_events(session, &event_ops);
+ err = perf_session__process_events(session, &perf_kmem);
if (err != 0)
goto out_delete;
sort_result();
#include "util/debug.h"
#include "util/session.h"
+#include "util/tool.h"
#include <sys/types.h>
#include <sys/prctl.h>
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,
struct perf_sample *sample,
struct perf_evsel *evsel __used,
return 0;
}
-static struct perf_event_ops eops = {
+static struct perf_tool eops = {
.sample = process_sample_event,
.comm = perf_event__process_comm,
.ordered_samples = true,
#include "util/evsel.h"
#include "util/debug.h"
#include "util/session.h"
+#include "util/tool.h"
#include "util/symbol.h"
#include "util/cpumap.h"
#include "util/thread_map.h"
};
struct perf_record {
- struct perf_event_ops ops;
+ struct perf_tool tool;
struct perf_record_opts opts;
u64 bytes_written;
const char *output_name;
}
}
-static int process_synthesized_event(struct perf_event_ops *ops,
+static int process_synthesized_event(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample __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);
return 0;
}
static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
{
int err;
- struct perf_event_ops *ops = data;
+ struct perf_tool *tool = data;
if (machine__is_host(machine))
return;
*method is used to avoid symbol missing when the first addr is
*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);
if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference"
* We use _stext for guest kernel because guest kernel's /proc/kallsyms
* 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");
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");
if (err < 0)
pr_err("Couldn't record guest kernel [%d]'s reference"
unsigned long waking = 0;
const bool forks = argc > 0;
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_evlist *evsel_list = rec->evlist;
const char *output_name = rec->output_name;
}
if (opts->pipe_output) {
- err = perf_event__synthesize_attrs(ops, session,
+ err = perf_event__synthesize_attrs(tool, session,
process_synthesized_event);
if (err < 0) {
pr_err("Couldn't synthesize attrs.\n");
return err;
}
- err = perf_event__synthesize_event_types(ops, process_synthesized_event,
+ err = perf_event__synthesize_event_types(tool, process_synthesized_event,
machine);
if (err < 0) {
pr_err("Couldn't synthesize event_types.\n");
* return this more properly and also
* 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);
if (err <= 0) {
pr_err("Couldn't record tracing data.\n");
}
}
- err = perf_event__synthesize_kernel_mmap(ops, process_synthesized_event,
+ err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
machine, "_text");
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");
if (err < 0)
pr_err("Couldn't record kernel reference relocation symbol\n"
"Symbol resolution may be skewed if relocation was used (e.g. kexec).\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);
if (err < 0)
pr_err("Couldn't record kernel module information.\n"
"Check /proc/modules permission or run as root.\n");
if (perf_guest)
- perf_session__process_machines(session, ops,
+ perf_session__process_machines(session, tool,
perf_event__synthesize_guest_os);
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,
machine);
else
- perf_event__synthesize_threads(ops, process_synthesized_event,
+ perf_event__synthesize_threads(tool, process_synthesized_event,
machine);
if (rec->realtime_prio) {
#include "util/evsel.h"
#include "util/header.h"
#include "util/session.h"
+#include "util/tool.h"
#include "util/parse-options.h"
#include "util/parse-events.h"
#include <linux/bitmap.h>
struct perf_report {
- struct perf_event_ops ops;
+ struct perf_tool tool;
struct perf_session *session;
char const *input_name;
bool force, use_tui, use_stdio;
}
-static int process_sample_event(struct perf_event_ops *ops,
+static int process_sample_event(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
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;
if (perf_event__preprocess_sample(event, machine, &al, sample,
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,
struct perf_sample *sample __used,
struct perf_evsel *evsel,
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) {
const char *name = evsel ? event_name(evsel) : "unknown";
signal(SIGINT, sig_handler);
session = perf_session__new(rep->input_name, O_RDONLY,
- rep->force, false, &rep->ops);
+ rep->force, false, &rep->tool);
if (session == NULL)
return -ENOMEM;
if (ret)
goto out_delete;
- ret = perf_session__process_events(session, &rep->ops);
+ ret = perf_session__process_events(session, &rep->tool);
if (ret)
goto out_delete;
NULL
};
struct perf_report report = {
- .ops = {
+ .tool = {
.sample = process_sample_event,
.mmap = perf_event__process_mmap,
.comm = perf_event__process_comm,
#include "util/thread.h"
#include "util/header.h"
#include "util/session.h"
+#include "util/tool.h"
#include "util/parse-options.h"
#include "util/trace-event.h"
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,
struct perf_sample *sample,
struct perf_evsel *evsel,
return 0;
}
-static struct perf_event_ops event_ops = {
+static struct perf_tool perf_sched = {
.sample = process_sample_event,
.comm = perf_event__process_comm,
.lost = perf_event__process_lost,
{
int err = -EINVAL;
struct perf_session *session = perf_session__new(input_name, O_RDONLY,
- 0, false, &event_ops);
+ 0, false, &perf_sched);
if (session == NULL)
die("No Memory");
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)
die("Failed to process events, error %d", err);
#include "util/header.h"
#include "util/parse-options.h"
#include "util/session.h"
+#include "util/tool.h"
#include "util/symbol.h"
#include "util/thread.h"
#include "util/trace-event.h"
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,
struct perf_sample *sample,
struct perf_evsel *evsel,
return 0;
}
-static struct perf_event_ops event_ops = {
+static struct perf_tool perf_script = {
.sample = process_sample_event,
.mmap = perf_event__process_mmap,
.comm = perf_event__process_comm,
signal(SIGINT, sig_handler);
- ret = perf_session__process_events(session, &event_ops);
+ ret = perf_session__process_events(session, &perf_script);
if (debug_mode)
pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered);
if (!script_name)
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)
return -ENOMEM;
#include "util/event.h"
#include "util/session.h"
#include "util/svghelper.h"
+#include "util/tool.h"
#define SUPPORT_OLD_POWER_EVENTS 1
#define PWR_EVENT_EXIT -1
static u64 cpus_pstate_start_times[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,
struct perf_sample *sample __used,
struct machine *machine __used)
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,
struct perf_sample *sample __used,
struct machine *machine __used)
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,
struct perf_sample *sample __used,
struct machine *machine __used)
}
-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,
struct perf_sample *sample,
struct perf_evsel *evsel,
svg_close();
}
-static struct perf_event_ops event_ops = {
+static struct perf_tool perf_timechart = {
.comm = process_comm_event,
.fork = process_fork_event,
.exit = process_exit_event,
static int __cmd_timechart(void)
{
struct perf_session *session = perf_session__new(input_name, O_RDONLY,
- 0, false, &event_ops);
+ 0, false, &perf_timechart);
int ret = -EINVAL;
if (session == NULL)
if (!perf_session__has_traces(session, "timechart record"))
goto out_delete;
- ret = perf_session__process_events(session, &event_ops);
+ ret = perf_session__process_events(session, &perf_timechart);
if (ret)
goto out_delete;
perf_event__process_sample(event, evsel, &sample, machine);
else if (event->header.type < PERF_RECORD_MAX) {
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
++self->hists.stats.nr_unknown_events;
}
goto out_delete;
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,
&top.session->host_machine);
else
- perf_event__synthesize_threads(&top.ops, perf_event__process,
+ perf_event__synthesize_threads(&top.tool, perf_event__process,
&top.session->host_machine);
start_counters(top.evlist);
top.session->evlist = top.evlist;
#include <linux/kernel.h>
#include "debug.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,
struct perf_sample *sample __used,
struct perf_evsel *evsel __used,
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,
struct perf_sample *sample __used,
struct machine *machine)
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,
.mmap = perf_event__process_mmap,
.fork = perf_event__process_task,
#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);
.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,
int full, perf_event__handler_t process,
struct machine *machine)
if (!full) {
event->comm.tid = pid;
- process(ops, event, &synth_sample, machine);
+ process(tool, event, &synth_sample, machine);
goto out;
}
event->comm.tid = pid;
- process(ops, event, &synth_sample, machine);
+ process(tool, event, &synth_sample, machine);
}
closedir(tasks);
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,
pid_t pid, pid_t tgid,
perf_event__handler_t process,
event->mmap.pid = tgid;
event->mmap.tid = pid;
- process(ops, event, &synth_sample, machine);
+ process(tool, event, &synth_sample, machine);
}
}
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,
struct machine *machine)
{
memcpy(event->mmap.filename, pos->dso->long_name,
pos->dso->long_name_len + 1);
- process(ops, event, &synth_sample, machine);
+ process(tool, event, &synth_sample, machine);
}
free(event);
static int __event__synthesize_thread(union perf_event *comm_event,
union perf_event *mmap_event,
pid_t pid, perf_event__handler_t process,
- struct perf_event_ops *ops,
+ struct perf_tool *tool,
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);
if (tgid == -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);
}
-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,
perf_event__handler_t process,
struct machine *machine)
for (thread = 0; thread < threads->nr; ++thread) {
if (__event__synthesize_thread(comm_event, mmap_event,
threads->map[thread],
- process, ops, machine)) {
+ process, tool, machine)) {
err = -1;
break;
}
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,
struct machine *machine)
{
continue;
__event__synthesize_thread(comm_event, mmap_event, pid,
- process, ops, machine);
+ process, tool, machine);
}
closedir(proc);
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,
struct machine *machine,
const char *symbol_name)
event->mmap.len = map->end - event->mmap.start;
event->mmap.pid = machine->pid;
- err = process(ops, event, &synth_sample, machine);
+ err = process(tool, event, &synth_sample, machine);
free(event);
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,
struct perf_sample *sample __used,
struct machine *machine)
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,
struct perf_sample *sample __used,
struct machine *machine __used)
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,
struct machine *machine)
{
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,
struct perf_sample *sample __used,
struct machine *machine)
if (cpumode == PERF_RECORD_MISC_GUEST_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)
goto out_problem;
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,
struct perf_sample *sample __used,
struct machine *machine)
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)
{
switch (event->header.type) {
case PERF_RECORD_COMM:
- perf_event__process_comm(ops, event, sample, machine);
+ perf_event__process_comm(tool, event, sample, machine);
break;
case PERF_RECORD_MMAP:
- perf_event__process_mmap(ops, event, sample, machine);
+ perf_event__process_mmap(tool, event, sample, machine);
break;
case PERF_RECORD_FORK:
case PERF_RECORD_EXIT:
- perf_event__process_task(ops, event, sample, machine);
+ perf_event__process_task(tool, event, sample, machine);
break;
case PERF_RECORD_LOST:
- perf_event__process_lost(ops, event, sample, machine);
+ perf_event__process_lost(tool, event, sample, machine);
default:
break;
}
void perf_event__print_totals(void);
-struct perf_event_ops;
+struct perf_tool;
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,
struct perf_sample *sample,
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,
perf_event__handler_t process,
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,
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,
struct machine *machine,
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,
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,
struct perf_sample *sample,
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,
struct perf_sample *sample,
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,
struct perf_sample *sample,
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,
struct perf_sample *sample,
struct machine *machine);
-int perf_event__process(struct perf_event_ops *ops,
+int perf_event__process(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
struct machine *machine);
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,
perf_event__handler_t process)
{
ev->attr.header.type = PERF_RECORD_HEADER_ATTR;
ev->attr.header.size = size;
- err = process(ops, ev, NULL, NULL);
+ err = process(tool, ev, NULL, NULL);
free(ev);
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,
perf_event__handler_t process)
{
int err = 0;
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);
if (err) {
pr_debug("failed to create perf header attribute\n");
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,
perf_event__handler_t process,
struct machine *machine)
ev.event_type.header.size = sizeof(ev.event_type) -
(sizeof(ev.event_type.event_type.name) - size);
- err = process(ops, &ev, NULL, machine);
+ err = process(tool, &ev, NULL, machine);
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,
struct machine *machine)
{
for (i = 0; i < event_count; 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,
machine);
if (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)
{
if (perf_header__push_event(event->event_type.event_type.event_id,
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,
perf_event__handler_t process)
{
ev.tracing_data.header.size = sizeof(ev.tracing_data);
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
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,
perf_event__handler_t process,
struct machine *machine)
ev.build_id.header.size = sizeof(ev.build_id) + 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;
}
-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,
struct perf_session *session)
{
const char *name, bool is_kallsyms);
int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
-int perf_event__synthesize_attr(struct perf_event_ops *ops,
+int perf_event__synthesize_attr(struct perf_tool *tool,
struct perf_event_attr *attr, u16 ids, u64 *id,
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,
perf_event__handler_t process);
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,
perf_event__handler_t process,
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,
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);
-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,
perf_event__handler_t process);
int perf_event__process_tracing_data(union perf_event *event,
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,
perf_event__handler_t process,
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,
struct perf_session *session);
#include "evlist.h"
#include "evsel.h"
#include "session.h"
+#include "tool.h"
#include "sort.h"
#include "util.h"
#include "cpumap.h"
struct perf_session *perf_session__new(const char *filename, int mode,
bool force, bool repipe,
- struct perf_event_ops *ops)
+ struct perf_tool *tool)
{
size_t len = filename ? strlen(filename) + 1 : 0;
struct perf_session *self = zalloc(sizeof(*self) + len);
goto out_delete;
}
- if (ops && ops->ordering_requires_timestamps &&
- ops->ordered_samples && !self->sample_id_all) {
+ if (tool && tool->ordering_requires_timestamps &&
+ tool->ordered_samples && !self->sample_id_all) {
dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n");
- ops->ordered_samples = false;
+ tool->ordered_samples = false;
}
out:
return 0;
}
-static int process_event_sample_stub(struct perf_event_ops *ops __used,
+static int process_event_sample_stub(struct perf_tool *tool __used,
union perf_event *event __used,
struct perf_sample *sample __used,
struct perf_evsel *evsel __used,
return 0;
}
-static int process_event_stub(struct perf_event_ops *ops __used,
+static int process_event_stub(struct perf_tool *tool __used,
union perf_event *event __used,
struct perf_sample *sample __used,
struct machine *machine __used)
return 0;
}
-static int process_finished_round_stub(struct perf_event_ops *ops __used,
+static int process_finished_round_stub(struct perf_tool *tool __used,
union perf_event *event __used,
struct perf_session *perf_session __used)
{
return 0;
}
-static int process_event_type_stub(struct perf_event_ops *ops __used,
+static int process_event_type_stub(struct perf_tool *tool __used,
union perf_event *event __used)
{
dump_printf(": unhandled!\n");
return 0;
}
-static int process_finished_round(struct perf_event_ops *ops,
+static int process_finished_round(struct perf_tool *tool,
union perf_event *event,
struct perf_session *session);
-static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
+static void perf_tool__fill_defaults(struct perf_tool *tool)
{
- if (handler->sample == NULL)
- handler->sample = process_event_sample_stub;
- if (handler->mmap == NULL)
- handler->mmap = process_event_stub;
- if (handler->comm == NULL)
- handler->comm = process_event_stub;
- if (handler->fork == NULL)
- handler->fork = process_event_stub;
- if (handler->exit == NULL)
- handler->exit = process_event_stub;
- if (handler->lost == NULL)
- handler->lost = perf_event__process_lost;
- if (handler->read == NULL)
- handler->read = process_event_sample_stub;
- if (handler->throttle == NULL)
- handler->throttle = process_event_stub;
- if (handler->unthrottle == NULL)
- handler->unthrottle = process_event_stub;
- if (handler->attr == NULL)
- handler->attr = process_event_synth_attr_stub;
- if (handler->event_type == NULL)
- handler->event_type = process_event_type_stub;
- if (handler->tracing_data == NULL)
- handler->tracing_data = process_event_synth_tracing_data_stub;
- if (handler->build_id == NULL)
- handler->build_id = process_finished_round_stub;
- if (handler->finished_round == NULL) {
- if (handler->ordered_samples)
- handler->finished_round = process_finished_round;
+ if (tool->sample == NULL)
+ tool->sample = process_event_sample_stub;
+ if (tool->mmap == NULL)
+ tool->mmap = process_event_stub;
+ if (tool->comm == NULL)
+ tool->comm = process_event_stub;
+ if (tool->fork == NULL)
+ tool->fork = process_event_stub;
+ if (tool->exit == NULL)
+ tool->exit = process_event_stub;
+ if (tool->lost == NULL)
+ tool->lost = perf_event__process_lost;
+ if (tool->read == NULL)
+ tool->read = process_event_sample_stub;
+ if (tool->throttle == NULL)
+ tool->throttle = process_event_stub;
+ if (tool->unthrottle == NULL)
+ tool->unthrottle = process_event_stub;
+ if (tool->attr == NULL)
+ tool->attr = process_event_synth_attr_stub;
+ if (tool->event_type == NULL)
+ tool->event_type = process_event_type_stub;
+ if (tool->tracing_data == NULL)
+ tool->tracing_data = process_event_synth_tracing_data_stub;
+ if (tool->build_id == NULL)
+ tool->build_id = process_finished_round_stub;
+ if (tool->finished_round == NULL) {
+ if (tool->ordered_samples)
+ tool->finished_round = process_finished_round;
else
- handler->finished_round = process_finished_round_stub;
+ tool->finished_round = process_finished_round_stub;
}
}
static int perf_session_deliver_event(struct perf_session *session,
union perf_event *event,
struct perf_sample *sample,
- struct perf_event_ops *ops,
+ struct perf_tool *tool,
u64 file_offset);
static void flush_sample_queue(struct perf_session *s,
- struct perf_event_ops *ops)
+ struct perf_tool *tool)
{
struct ordered_samples *os = &s->ordered_samples;
struct list_head *head = &os->samples;
unsigned idx = 0, progress_next = os->nr_samples / 16;
int ret;
- if (!ops->ordered_samples || !limit)
+ if (!tool->ordered_samples || !limit)
return;
list_for_each_entry_safe(iter, tmp, head, list) {
if (ret)
pr_err("Can't parse sample, err = %d\n", ret);
else
- perf_session_deliver_event(s, iter->event, &sample, ops,
+ perf_session_deliver_event(s, iter->event, &sample, tool,
iter->file_offset);
os->last_flush = iter->timestamp;
* Flush every events below timestamp 7
* etc...
*/
-static int process_finished_round(struct perf_event_ops *ops,
+static int process_finished_round(struct perf_tool *tool,
union perf_event *event __used,
struct perf_session *session)
{
- flush_sample_queue(session, ops);
+ flush_sample_queue(session, tool);
session->ordered_samples.next_flush = session->ordered_samples.max_timestamp;
return 0;
static int perf_session_deliver_event(struct perf_session *session,
union perf_event *event,
struct perf_sample *sample,
- struct perf_event_ops *ops,
+ struct perf_tool *tool,
u64 file_offset)
{
struct perf_evsel *evsel;
++session->hists.stats.nr_unknown_id;
return -1;
}
- return ops->sample(ops, event, sample, evsel, machine);
+ return tool->sample(tool, event, sample, evsel, machine);
case PERF_RECORD_MMAP:
- return ops->mmap(ops, event, sample, machine);
+ return tool->mmap(tool, event, sample, machine);
case PERF_RECORD_COMM:
- return ops->comm(ops, event, sample, machine);
+ return tool->comm(tool, event, sample, machine);
case PERF_RECORD_FORK:
- return ops->fork(ops, event, sample, machine);
+ return tool->fork(tool, event, sample, machine);
case PERF_RECORD_EXIT:
- return ops->exit(ops, event, sample, machine);
+ return tool->exit(tool, event, sample, machine);
case PERF_RECORD_LOST:
- if (ops->lost == perf_event__process_lost)
+ if (tool->lost == perf_event__process_lost)
session->hists.stats.total_lost += event->lost.lost;
- return ops->lost(ops, event, sample, machine);
+ return tool->lost(tool, event, sample, machine);
case PERF_RECORD_READ:
- return ops->read(ops, event, sample, evsel, machine);
+ return tool->read(tool, event, sample, evsel, machine);
case PERF_RECORD_THROTTLE:
- return ops->throttle(ops, event, sample, machine);
+ return tool->throttle(tool, event, sample, machine);
case PERF_RECORD_UNTHROTTLE:
- return ops->unthrottle(ops, event, sample, machine);
+ return tool->unthrottle(tool, event, sample, machine);
default:
++session->hists.stats.nr_unknown_events;
return -1;
}
static int perf_session__process_user_event(struct perf_session *session, union perf_event *event,
- struct perf_event_ops *ops, u64 file_offset)
+ struct perf_tool *tool, u64 file_offset)
{
int err;
/* These events are processed right away */
switch (event->header.type) {
case PERF_RECORD_HEADER_ATTR:
- err = ops->attr(event, &session->evlist);
+ err = tool->attr(event, &session->evlist);
if (err == 0)
perf_session__update_sample_type(session);
return err;
case PERF_RECORD_HEADER_EVENT_TYPE:
- return ops->event_type(ops, event);
+ return tool->event_type(tool, event);
case PERF_RECORD_HEADER_TRACING_DATA:
/* setup for reading amidst mmap */
lseek(session->fd, file_offset, SEEK_SET);
- return ops->tracing_data(event, session);
+ return tool->tracing_data(event, session);
case PERF_RECORD_HEADER_BUILD_ID:
- return ops->build_id(ops, event, session);
+ return tool->build_id(tool, event, session);
case PERF_RECORD_FINISHED_ROUND:
- return ops->finished_round(ops, event, session);
+ return tool->finished_round(tool, event, session);
default:
return -EINVAL;
}
static int perf_session__process_event(struct perf_session *session,
union perf_event *event,
- struct perf_event_ops *ops,
+ struct perf_tool *tool,
u64 file_offset)
{
struct perf_sample sample;
hists__inc_nr_events(&session->hists, event->header.type);
if (event->header.type >= PERF_RECORD_USER_TYPE_START)
- return perf_session__process_user_event(session, event, ops, file_offset);
+ return perf_session__process_user_event(session, event, tool, file_offset);
/*
* For all kernel events we get the sample data
if (perf_session__preprocess_sample(session, event, &sample))
return 0;
- if (ops->ordered_samples) {
+ if (tool->ordered_samples) {
ret = perf_session_queue_event(session, event, &sample,
file_offset);
if (ret != -ETIME)
return ret;
}
- return perf_session_deliver_event(session, event, &sample, ops,
+ return perf_session_deliver_event(session, event, &sample, tool,
file_offset);
}
}
static void perf_session__warn_about_errors(const struct perf_session *session,
- const struct perf_event_ops *ops)
+ const struct perf_tool *tool)
{
- if (ops->lost == perf_event__process_lost &&
+ if (tool->lost == perf_event__process_lost &&
session->hists.stats.nr_events[PERF_RECORD_LOST] != 0) {
ui__warning("Processed %d events and lost %d chunks!\n\n"
"Check IO/CPU overload!\n\n",
volatile int session_done;
static int __perf_session__process_pipe_events(struct perf_session *self,
- struct perf_event_ops *ops)
+ struct perf_tool *tool)
{
union perf_event event;
uint32_t size;
int err;
void *p;
- perf_event_ops__fill_defaults(ops);
+ perf_tool__fill_defaults(tool);
head = 0;
more:
}
if (size == 0 ||
- (skip = perf_session__process_event(self, &event, ops, head)) < 0) {
+ (skip = perf_session__process_event(self, &event, tool, head)) < 0) {
dump_printf("%#" PRIx64 " [%#x]: skipping unknown header type: %d\n",
head, event.header.size, event.header.type);
/*
done:
err = 0;
out_err:
- perf_session__warn_about_errors(self, ops);
+ perf_session__warn_about_errors(self, tool);
perf_session_free_sample_buffers(self);
return err;
}
int __perf_session__process_events(struct perf_session *session,
u64 data_offset, u64 data_size,
- u64 file_size, struct perf_event_ops *ops)
+ u64 file_size, struct perf_tool *tool)
{
u64 head, page_offset, file_offset, file_pos, progress_next;
int err, mmap_prot, mmap_flags, map_idx = 0;
union perf_event *event;
uint32_t size;
- perf_event_ops__fill_defaults(ops);
+ perf_tool__fill_defaults(tool);
page_size = sysconf(_SC_PAGESIZE);
size = event->header.size;
if (size == 0 ||
- perf_session__process_event(session, event, ops, file_pos) < 0) {
+ perf_session__process_event(session, event, tool, file_pos) < 0) {
dump_printf("%#" PRIx64 " [%#x]: skipping unknown header type: %d\n",
file_offset + head, event->header.size,
event->header.type);
err = 0;
/* do the final flush for ordered samples */
session->ordered_samples.next_flush = ULLONG_MAX;
- flush_sample_queue(session, ops);
+ flush_sample_queue(session, tool);
out_err:
- perf_session__warn_about_errors(session, ops);
+ perf_session__warn_about_errors(session, tool);
perf_session_free_sample_buffers(session);
return err;
}
int perf_session__process_events(struct perf_session *self,
- struct perf_event_ops *ops)
+ struct perf_tool *tool)
{
int err;
err = __perf_session__process_events(self,
self->header.data_offset,
self->header.data_size,
- self->size, ops);
+ self->size, tool);
else
- err = __perf_session__process_pipe_events(self, ops);
+ err = __perf_session__process_pipe_events(self, tool);
return err;
}
char filename[0];
};
-struct perf_evsel;
-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_tool;
struct perf_session *perf_session__new(const char *filename, int mode,
bool force, bool repipe,
- struct perf_event_ops *ops);
+ struct perf_tool *tool);
void perf_session__delete(struct perf_session *self);
void perf_event_header__bswap(struct perf_event_header *self);
int __perf_session__process_events(struct perf_session *self,
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,
- struct perf_event_ops *event_ops);
+ struct perf_tool *tool);
int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel,
struct thread *thread,
static inline
void perf_session__process_machines(struct perf_session *self,
- struct perf_event_ops *ops,
+ struct perf_tool *tool,
machine__process_t process)
{
- process(&self->host_machine, ops);
- return machines__process(&self->machines, process, ops);
+ process(&self->host_machine, tool);
+ return machines__process(&self->machines, process, tool);
}
struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
--- /dev/null
+#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
#define __PERF_TOP_H 1
+#include "tool.h"
#include "types.h"
-#include "session.h"
-#include "../perf.h"
#include <stddef.h>
+#include <stdbool.h>
struct perf_evlist;
struct perf_evsel;
+struct perf_session;
struct perf_top {
- struct perf_event_ops ops;
+ struct perf_tool tool;
struct perf_evlist *evlist;
/*
* Symbols will be added here in perf_event__process_sample and will