aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-inject.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-11-28 05:30:20 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-11-28 07:39:28 -0500
commit45694aa7702bc44d538a3bcb51bb2bb96cf190c0 (patch)
tree81bc1f449f55984556d89b63c461dcf181dc97e5 /tools/perf/builtin-inject.c
parent743eb868657bdb1b26c7b24077ca21c67c82c777 (diff)
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.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-inject.c')
-rw-r--r--tools/perf/builtin-inject.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index a5bcf81776fc..09c106193e65 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -9,6 +9,7 @@
9 9
10#include "perf.h" 10#include "perf.h"
11#include "util/session.h" 11#include "util/session.h"
12#include "util/tool.h"
12#include "util/debug.h" 13#include "util/debug.h"
13 14
14#include "util/parse-options.h" 15#include "util/parse-options.h"
@@ -16,7 +17,7 @@
16static char const *input_name = "-"; 17static char const *input_name = "-";
17static bool inject_build_ids; 18static bool inject_build_ids;
18 19
19static int perf_event__repipe_synth(struct perf_event_ops *ops __used, 20static int perf_event__repipe_synth(struct perf_tool *tool __used,
20 union perf_event *event, 21 union perf_event *event,
21 struct machine *machine __used) 22 struct machine *machine __used)
22{ 23{
@@ -37,17 +38,17 @@ static int perf_event__repipe_synth(struct perf_event_ops *ops __used,
37 return 0; 38 return 0;
38} 39}
39 40
40static int perf_event__repipe_op2_synth(struct perf_event_ops *ops, 41static int perf_event__repipe_op2_synth(struct perf_tool *tool,
41 union perf_event *event, 42 union perf_event *event,
42 struct perf_session *session __used) 43 struct perf_session *session __used)
43{ 44{
44 return perf_event__repipe_synth(ops, event, NULL); 45 return perf_event__repipe_synth(tool, event, NULL);
45} 46}
46 47
47static int perf_event__repipe_event_type_synth(struct perf_event_ops *ops, 48static int perf_event__repipe_event_type_synth(struct perf_tool *tool,
48 union perf_event *event) 49 union perf_event *event)
49{ 50{
50 return perf_event__repipe_synth(ops, event, NULL); 51 return perf_event__repipe_synth(tool, event, NULL);
51} 52}
52 53
53static int perf_event__repipe_tracing_data_synth(union perf_event *event, 54static 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 return perf_event__repipe_synth(NULL, event, NULL); 63 return perf_event__repipe_synth(NULL, event, NULL);
63} 64}
64 65
65static int perf_event__repipe(struct perf_event_ops *ops, 66static int perf_event__repipe(struct perf_tool *tool,
66 union perf_event *event, 67 union perf_event *event,
67 struct perf_sample *sample __used, 68 struct perf_sample *sample __used,
68 struct machine *machine) 69 struct machine *machine)
69{ 70{
70 return perf_event__repipe_synth(ops, event, machine); 71 return perf_event__repipe_synth(tool, event, machine);
71} 72}
72 73
73static int perf_event__repipe_sample(struct perf_event_ops *ops, 74static int perf_event__repipe_sample(struct perf_tool *tool,
74 union perf_event *event, 75 union perf_event *event,
75 struct perf_sample *sample __used, 76 struct perf_sample *sample __used,
76 struct perf_evsel *evsel __used, 77 struct perf_evsel *evsel __used,
77 struct machine *machine) 78 struct machine *machine)
78{ 79{
79 return perf_event__repipe_synth(ops, event, machine); 80 return perf_event__repipe_synth(tool, event, machine);
80} 81}
81 82
82static int perf_event__repipe_mmap(struct perf_event_ops *ops, 83static int perf_event__repipe_mmap(struct perf_tool *tool,
83 union perf_event *event, 84 union perf_event *event,
84 struct perf_sample *sample, 85 struct perf_sample *sample,
85 struct machine *machine) 86 struct machine *machine)
86{ 87{
87 int err; 88 int err;
88 89
89 err = perf_event__process_mmap(ops, event, sample, machine); 90 err = perf_event__process_mmap(tool, event, sample, machine);
90 perf_event__repipe(ops, event, sample, machine); 91 perf_event__repipe(tool, event, sample, machine);
91 92
92 return err; 93 return err;
93} 94}
94 95
95static int perf_event__repipe_task(struct perf_event_ops *ops, 96static int perf_event__repipe_task(struct perf_tool *tool,
96 union perf_event *event, 97 union perf_event *event,
97 struct perf_sample *sample, 98 struct perf_sample *sample,
98 struct machine *machine) 99 struct machine *machine)
99{ 100{
100 int err; 101 int err;
101 102
102 err = perf_event__process_task(ops, event, sample, machine); 103 err = perf_event__process_task(tool, event, sample, machine);
103 perf_event__repipe(ops, event, sample, machine); 104 perf_event__repipe(tool, event, sample, machine);
104 105
105 return err; 106 return err;
106} 107}
@@ -130,7 +131,7 @@ static int dso__read_build_id(struct dso *self)
130 return -1; 131 return -1;
131} 132}
132 133
133static int dso__inject_build_id(struct dso *self, struct perf_event_ops *ops, 134static int dso__inject_build_id(struct dso *self, struct perf_tool *tool,
134 struct machine *machine) 135 struct machine *machine)
135{ 136{
136 u16 misc = PERF_RECORD_MISC_USER; 137 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 if (self->kernel) 145 if (self->kernel)
145 misc = PERF_RECORD_MISC_KERNEL; 146 misc = PERF_RECORD_MISC_KERNEL;
146 147
147 err = perf_event__synthesize_build_id(ops, self, misc, perf_event__repipe, 148 err = perf_event__synthesize_build_id(tool, self, misc, perf_event__repipe,
148 machine); 149 machine);
149 if (err) { 150 if (err) {
150 pr_err("Can't synthesize build_id event for %s\n", self->long_name); 151 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 return 0; 155 return 0;
155} 156}
156 157
157static int perf_event__inject_buildid(struct perf_event_ops *ops, 158static int perf_event__inject_buildid(struct perf_tool *tool,
158 union perf_event *event, 159 union perf_event *event,
159 struct perf_sample *sample, 160 struct perf_sample *sample,
160 struct perf_evsel *evsel __used, 161 struct perf_evsel *evsel __used,
@@ -180,7 +181,7 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
180 if (!al.map->dso->hit) { 181 if (!al.map->dso->hit) {
181 al.map->dso->hit = 1; 182 al.map->dso->hit = 1;
182 if (map__load(al.map, NULL) >= 0) { 183 if (map__load(al.map, NULL) >= 0) {
183 dso__inject_build_id(al.map->dso, ops, machine); 184 dso__inject_build_id(al.map->dso, tool, machine);
184 /* 185 /*
185 * If this fails, too bad, let the other side 186 * If this fails, too bad, let the other side
186 * account this as unresolved. 187 * account this as unresolved.
@@ -193,11 +194,11 @@ static int perf_event__inject_buildid(struct perf_event_ops *ops,
193 } 194 }
194 195
195repipe: 196repipe:
196 perf_event__repipe(ops, event, sample, machine); 197 perf_event__repipe(tool, event, sample, machine);
197 return 0; 198 return 0;
198} 199}
199 200
200struct perf_event_ops inject_ops = { 201struct perf_tool perf_inject = {
201 .sample = perf_event__repipe_sample, 202 .sample = perf_event__repipe_sample,
202 .mmap = perf_event__repipe, 203 .mmap = perf_event__repipe,
203 .comm = perf_event__repipe, 204 .comm = perf_event__repipe,
@@ -228,17 +229,17 @@ static int __cmd_inject(void)
228 signal(SIGINT, sig_handler); 229 signal(SIGINT, sig_handler);
229 230
230 if (inject_build_ids) { 231 if (inject_build_ids) {
231 inject_ops.sample = perf_event__inject_buildid; 232 perf_inject.sample = perf_event__inject_buildid;
232 inject_ops.mmap = perf_event__repipe_mmap; 233 perf_inject.mmap = perf_event__repipe_mmap;
233 inject_ops.fork = perf_event__repipe_task; 234 perf_inject.fork = perf_event__repipe_task;
234 inject_ops.tracing_data = perf_event__repipe_tracing_data; 235 perf_inject.tracing_data = perf_event__repipe_tracing_data;
235 } 236 }
236 237
237 session = perf_session__new(input_name, O_RDONLY, false, true, &inject_ops); 238 session = perf_session__new(input_name, O_RDONLY, false, true, &perf_inject);
238 if (session == NULL) 239 if (session == NULL)
239 return -ENOMEM; 240 return -ENOMEM;
240 241
241 ret = perf_session__process_events(session, &inject_ops); 242 ret = perf_session__process_events(session, &perf_inject);
242 243
243 perf_session__delete(session); 244 perf_session__delete(session);
244 245