perf tools: Rename perf_event_ops to perf_tool
Commit-ID: 45694aa7702bc44d538a3bcb51bb2bb96cf190c0 Gitweb: http://git.kernel.org/tip/45694aa7702bc44d538a3bcb51bb2bb96cf190c0 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Mon, 28 Nov 2011 08:30:20 -0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 28 Nov 2011 10:39:28 -0200
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 <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/Makefile | 1 + tools/perf/builtin-annotate.c | 13 ++-- tools/perf/builtin-diff.c | 11 ++- tools/perf/builtin-inject.c | 55 +++++++------- tools/perf/builtin-kmem.c | 9 +- tools/perf/builtin-lock.c | 5 +- tools/perf/builtin-record.c | 35 +++++---- tools/perf/builtin-report.c | 17 ++-- tools/perf/builtin-sched.c | 9 +- tools/perf/builtin-script.c | 9 +- tools/perf/builtin-timechart.c | 15 ++-- tools/perf/builtin-top.c | 6 +- tools/perf/util/build-id.c | 7 +- tools/perf/util/build-id.h | 2 +- tools/perf/util/event.c | 54 +++++++------- tools/perf/util/event.h | 22 +++--- tools/perf/util/header.c | 28 ++++---- tools/perf/util/header.h | 16 ++-- tools/perf/util/session.c | 163 ++++++++++++++++++++-------------------- tools/perf/util/session.h | 49 ++---------- tools/perf/util/tool.h | 45 +++++++++++ tools/perf/util/top.h | 7 +- 22 files changed, 301 insertions(+), 277 deletions(-)
tools/perf/Makefile +1 -0
@@ -278,6 +278,7 @@ LIB_H += util/strbuf.h 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
tools/perf/builtin-annotate.c +7 -6
@@ -27,11 +27,12 @@#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;
@@ -79,13 +80,13 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,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,
@@ -174,7 +175,7 @@ static int __cmd_annotate(struct perf_annotate *ann)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 ;
@@ -185,7 +186,7 @@ static int __cmd_annotate(struct perf_annotate *ann) goto out_delete; } - ret =perf_session__process_events (session, &ann->ops); + ret =perf_session__process_events (session, &ann->tool);if (ret) goto out_delete;
@@ -241,7 +242,7 @@ static const char * const annotate_usage[] = {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,
tools/perf/builtin-diff.c +6 -5
@@ -11,6 +11,7 @@#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"
@@ -31,7 +32,7 @@ static int hists__add_entry(struct hists *self,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,
@@ -57,7 +58,7 @@ static int diff__process_sample_event(struct perf_event_ops *ops __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,
@@ -147,13 +148,13 @@ static int __cmd_diff(void)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; }
tools/perf/builtin-inject.c +28 -27
159 lines not on this page · raw message
tools/perf/builtin-kmem.c +5 -4
@@ -7,6 +7,7 @@#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"
@@ -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, struct perf_sample *sample, struct perf_evsel *evsel __used,
@@ -325,7 +326,7 @@ static int process_sample_event(struct perf_event_ops *ops __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,
@@ -484,7 +485,7 @@ static int __cmd_kmem(void) {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 ;
@@ -495,7 +496,7 @@ static int __cmd_kmem(void) 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 ();
tools/perf/builtin-lock.c +3 -2
@@ -12,6 +12,7 @@#include "util/debug.h" #include "util/session.h" +#include "util/tool.h" #include <sys/types.h> #include <sys/prctl.h>
@@ -845,7 +846,7 @@ static void dump_info(void)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,
@@ -864,7 +865,7 @@ static int process_sample_event(struct perf_event_ops *ops __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,
tools/perf/builtin-record.c +18 -17
@@ -22,6 +22,7 @@#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"
@@ -36,7 +37,7 @@ enum write_mode_t { };struct perf_record { -struct perf_event_ops ops; +struct perf_tool tool;struct perf_record_opts opts;u64 bytes_written;const char *output_name;
@@ -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,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 ; }
@@ -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) {int err; -struct perf_event_ops *ops = data; +struct perf_tool *tool = data;if (machine__is_host (machine))return ;
@@ -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 *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"
@@ -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 * 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"
@@ -378,7 +379,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)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;
@@ -501,14 +502,14 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) }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" );
@@ -524,7 +525,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)* 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" );
@@ -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" );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"
@@ -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");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) {
tools/perf/builtin-report.c +9 -8
@@ -25,6 +25,7 @@#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"
@@ -36,7 +37,7 @@#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;
@@ -103,13 +104,13 @@ out: } -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,
@@ -136,13 +137,13 @@ static int process_sample_event(struct perf_event_ops *ops,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" ;
@@ -254,7 +255,7 @@ static int __cmd_report(struct perf_report *rep)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 ;
@@ -277,7 +278,7 @@ static int __cmd_report(struct perf_report *rep)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;
@@ -435,7 +436,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)NULL };struct perf_report report = { - .ops = { + .tool = { .sample = process_sample_event, .mmap = perf_event__process_mmap, .comm = perf_event__process_comm,
tools/perf/builtin-sched.c +5 -4
@@ -8,6 +8,7 @@#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"
@@ -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); } -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,
@@ -1631,7 +1632,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,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,
@@ -1643,12 +1644,12 @@ static void read_events(bool destroy, struct perf_session **psession) {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);
tools/perf/builtin-script.c +5 -4
@@ -7,6 +7,7 @@#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"
@@ -434,7 +435,7 @@ static int cleanup_scripting(void)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,
@@ -468,7 +469,7 @@ static int process_sample_event(struct perf_event_ops *ops __used,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,
@@ -495,7 +496,7 @@ static int __cmd_script(struct perf_session *session)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);
@@ -1262,7 +1263,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)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 ;
tools/perf/builtin-timechart.c +8 -7
@@ -32,6 +32,7 @@#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
@@ -274,7 +275,7 @@ static int cpus_cstate_state[MAX_CPUS];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 )
@@ -283,7 +284,7 @@ static int process_comm_event(struct perf_event_ops *ops __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 )
@@ -292,7 +293,7 @@ static int process_fork_event(struct perf_event_ops *ops __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 )
@@ -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, struct perf_sample *sample, struct perf_evsel *evsel,
@@ -979,7 +980,7 @@ static void write_svg_file(const char *filename)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,
@@ -990,7 +991,7 @@ static struct perf_event_ops event_ops = {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 )
@@ -999,7 +1000,7 @@ static int __cmd_timechart(void)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;
tools/perf/builtin-top.c +3 -3
@@ -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); 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; }
@@ -968,11 +968,11 @@ static int __cmd_top(void) 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;
tools/perf/util/build-id.c +4 -3
@@ -14,8 +14,9 @@#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,
@@ -40,7 +41,7 @@ static int build_id__mark_dso_hit(struct perf_event_ops *ops __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)
@@ -59,7 +60,7 @@ static int perf_event__exit_del_thread(struct perf_event_ops *ops __used,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,
tools/perf/util/build-id.h +1 -1
@@ -3,7 +3,7 @@#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);
tools/perf/util/event.c +27 -27
192 lines not on this page · raw message
tools/perf/util/event.h +11 -11
@@ -141,47 +141,47 @@ union perf_event {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);
tools/perf/util/header.c +14 -14
@@ -2070,7 +2070,7 @@ out_delete_evlist: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) {
@@ -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.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) {
@@ -2109,7 +2109,7 @@ int perf_event__synthesize_attrs(struct perf_event_ops *ops,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" );
@@ -2157,7 +2157,7 @@ int perf_event__process_attr(union perf_event *event,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)
@@ -2178,12 +2178,12 @@ int perf_event__synthesize_event_type(struct perf_event_ops *ops, 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) {
@@ -2193,7 +2193,7 @@ int perf_event__synthesize_event_types(struct perf_event_ops *ops,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) {
@@ -2205,7 +2205,7 @@ int perf_event__synthesize_event_types(struct perf_event_ops *ops,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,
@@ -2215,7 +2215,7 @@ int perf_event__process_event_type(struct perf_event_ops *ops __unused,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) {
@@ -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.size = aligned_size; -process (ops, &ev,NULL ,NULL ); +process (tool, &ev,NULL ,NULL );/* * The put function will copy all the tracing data
@@ -2290,7 +2290,7 @@ int perf_event__process_tracing_data(union perf_event *event,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)
@@ -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;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) {
tools/perf/util/header.h +8 -8
@@ -97,35 +97,35 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, const char *name, bool is_kallsyms);int build_id_cache__remove_s (const char *sbuild_id,const char *debugdir); -int perf_event__synthesize_attr (struct perf_event_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);
tools/perf/util/session.c +82 -81
381 lines not on this page · raw message
tools/perf/util/session.h +7 -42
73 lines not on this page · raw message
tools/perf/util/tool.h new file +45 -0
45 lines not on this page · raw message
tools/perf/util/top.h +4 -3
@@ -1,16 +1,17 @@ #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