29 size =
event->header.size;
32 int ret =
write(STDOUT_FILENO, buf, size);
43 static int perf_event__repipe_op2_synth(
struct perf_tool *tool,
48 return perf_event__repipe_synth(tool, event,
NULL);
51 static int perf_event__repipe_event_type_synth(
struct perf_tool *tool,
54 return perf_event__repipe_synth(tool, event,
NULL);
57 static int perf_event__repipe_tracing_data_synth(
union perf_event *
event,
61 return perf_event__repipe_synth(
NULL, event,
NULL);
72 return perf_event__repipe_synth(
NULL, event,
NULL);
75 static int perf_event__repipe(
struct perf_tool *tool,
80 return perf_event__repipe_synth(tool, event, machine);
83 static int perf_event__repipe_sample(
struct perf_tool *tool,
89 return perf_event__repipe_synth(tool, event, machine);
92 static int perf_event__repipe_mmap(
struct perf_tool *tool,
100 perf_event__repipe(tool, event, sample, machine);
105 static int perf_event__repipe_task(
struct perf_tool *tool,
113 perf_event__repipe(tool, event, sample, machine);
118 static int perf_event__repipe_tracing_data(
union perf_event *event,
123 perf_event__repipe_synth(
NULL, event,
NULL);
129 static int dso__read_build_id(
struct dso *
self)
131 if (self->has_build_id)
135 sizeof(self->build_id)) > 0) {
136 self->has_build_id =
true;
143 static int dso__inject_build_id(
struct dso *
self,
struct perf_tool *tool,
149 if (dso__read_build_id(
self) < 0) {
150 pr_debug(
"no build_id found for %s\n", self->long_name);
160 pr_err(
"Can't synthesize build_id event for %s\n", self->long_name);
167 static int perf_event__inject_buildid(
struct perf_tool *tool,
171 struct machine *machine)
180 if (thread ==
NULL) {
181 pr_err(
"problem processing %d event, skipping it.\n",
189 if (al.map !=
NULL) {
190 if (!al.map->dso->hit) {
191 al.map->dso->hit = 1;
193 dso__inject_build_id(al.map->dso, tool, machine);
199 #ifdef LIBELF_SUPPORT
201 "install a debug package?\n",
202 al.map->dso->long_name);
209 perf_event__repipe(tool, event, sample, machine);
220 static int __cmd_inject(
struct perf_inject *inject)
228 inject->
tool.sample = perf_event__inject_buildid;
229 inject->
tool.mmap = perf_event__repipe_mmap;
230 inject->
tool.fork = perf_event__repipe_task;
231 inject->
tool.tracing_data = perf_event__repipe_tracing_data;
249 .sample = perf_event__repipe_sample,
250 .mmap = perf_event__repipe,
251 .comm = perf_event__repipe,
252 .fork = perf_event__repipe,
253 .exit = perf_event__repipe,
254 .lost = perf_event__repipe,
255 .read = perf_event__repipe_sample,
256 .throttle = perf_event__repipe,
257 .unthrottle = perf_event__repipe,
258 .attr = perf_event__repipe_attr,
259 .event_type = perf_event__repipe_event_type_synth,
260 .tracing_data = perf_event__repipe_tracing_data_synth,
261 .build_id = perf_event__repipe_op2_synth,
264 const struct option options[] = {
266 "Inject build-ids into the output stream"),
268 "be more verbose (show build ids, etc)"),
271 const char *
const inject_usage[] = {
272 "perf inject [<options>]",
287 return __cmd_inject(&inject);