diff options
Diffstat (limited to 'tools/perf/builtin-inject.c')
-rw-r--r-- | tools/perf/builtin-inject.c | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 84ad6abe4258..afe377b2884f 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c | |||
@@ -38,8 +38,7 @@ struct event_entry { | |||
38 | }; | 38 | }; |
39 | 39 | ||
40 | static int perf_event__repipe_synth(struct perf_tool *tool, | 40 | static int perf_event__repipe_synth(struct perf_tool *tool, |
41 | union perf_event *event, | 41 | union perf_event *event) |
42 | struct machine *machine __maybe_unused) | ||
43 | { | 42 | { |
44 | struct perf_inject *inject = container_of(tool, struct perf_inject, tool); | 43 | struct perf_inject *inject = container_of(tool, struct perf_inject, tool); |
45 | uint32_t size; | 44 | uint32_t size; |
@@ -65,39 +64,28 @@ static int perf_event__repipe_op2_synth(struct perf_tool *tool, | |||
65 | struct perf_session *session | 64 | struct perf_session *session |
66 | __maybe_unused) | 65 | __maybe_unused) |
67 | { | 66 | { |
68 | return perf_event__repipe_synth(tool, event, NULL); | 67 | return perf_event__repipe_synth(tool, event); |
69 | } | 68 | } |
70 | 69 | ||
71 | static int perf_event__repipe_event_type_synth(struct perf_tool *tool, | 70 | static int perf_event__repipe_attr(struct perf_tool *tool, |
72 | union perf_event *event) | 71 | union perf_event *event, |
73 | { | 72 | struct perf_evlist **pevlist) |
74 | return perf_event__repipe_synth(tool, event, NULL); | ||
75 | } | ||
76 | |||
77 | static int perf_event__repipe_tracing_data_synth(union perf_event *event, | ||
78 | struct perf_session *session | ||
79 | __maybe_unused) | ||
80 | { | ||
81 | return perf_event__repipe_synth(NULL, event, NULL); | ||
82 | } | ||
83 | |||
84 | static int perf_event__repipe_attr(union perf_event *event, | ||
85 | struct perf_evlist **pevlist __maybe_unused) | ||
86 | { | 73 | { |
87 | int ret; | 74 | int ret; |
88 | ret = perf_event__process_attr(event, pevlist); | 75 | |
76 | ret = perf_event__process_attr(tool, event, pevlist); | ||
89 | if (ret) | 77 | if (ret) |
90 | return ret; | 78 | return ret; |
91 | 79 | ||
92 | return perf_event__repipe_synth(NULL, event, NULL); | 80 | return perf_event__repipe_synth(tool, event); |
93 | } | 81 | } |
94 | 82 | ||
95 | static int perf_event__repipe(struct perf_tool *tool, | 83 | static int perf_event__repipe(struct perf_tool *tool, |
96 | union perf_event *event, | 84 | union perf_event *event, |
97 | struct perf_sample *sample __maybe_unused, | 85 | struct perf_sample *sample __maybe_unused, |
98 | struct machine *machine) | 86 | struct machine *machine __maybe_unused) |
99 | { | 87 | { |
100 | return perf_event__repipe_synth(tool, event, machine); | 88 | return perf_event__repipe_synth(tool, event); |
101 | } | 89 | } |
102 | 90 | ||
103 | typedef int (*inject_handler)(struct perf_tool *tool, | 91 | typedef int (*inject_handler)(struct perf_tool *tool, |
@@ -119,7 +107,7 @@ static int perf_event__repipe_sample(struct perf_tool *tool, | |||
119 | 107 | ||
120 | build_id__mark_dso_hit(tool, event, sample, evsel, machine); | 108 | build_id__mark_dso_hit(tool, event, sample, evsel, machine); |
121 | 109 | ||
122 | return perf_event__repipe_synth(tool, event, machine); | 110 | return perf_event__repipe_synth(tool, event); |
123 | } | 111 | } |
124 | 112 | ||
125 | static int perf_event__repipe_mmap(struct perf_tool *tool, | 113 | static int perf_event__repipe_mmap(struct perf_tool *tool, |
@@ -135,6 +123,19 @@ static int perf_event__repipe_mmap(struct perf_tool *tool, | |||
135 | return err; | 123 | return err; |
136 | } | 124 | } |
137 | 125 | ||
126 | static int perf_event__repipe_mmap2(struct perf_tool *tool, | ||
127 | union perf_event *event, | ||
128 | struct perf_sample *sample, | ||
129 | struct machine *machine) | ||
130 | { | ||
131 | int err; | ||
132 | |||
133 | err = perf_event__process_mmap2(tool, event, sample, machine); | ||
134 | perf_event__repipe(tool, event, sample, machine); | ||
135 | |||
136 | return err; | ||
137 | } | ||
138 | |||
138 | static int perf_event__repipe_fork(struct perf_tool *tool, | 139 | static int perf_event__repipe_fork(struct perf_tool *tool, |
139 | union perf_event *event, | 140 | union perf_event *event, |
140 | struct perf_sample *sample, | 141 | struct perf_sample *sample, |
@@ -148,13 +149,14 @@ static int perf_event__repipe_fork(struct perf_tool *tool, | |||
148 | return err; | 149 | return err; |
149 | } | 150 | } |
150 | 151 | ||
151 | static int perf_event__repipe_tracing_data(union perf_event *event, | 152 | static int perf_event__repipe_tracing_data(struct perf_tool *tool, |
153 | union perf_event *event, | ||
152 | struct perf_session *session) | 154 | struct perf_session *session) |
153 | { | 155 | { |
154 | int err; | 156 | int err; |
155 | 157 | ||
156 | perf_event__repipe_synth(NULL, event, NULL); | 158 | perf_event__repipe_synth(tool, event); |
157 | err = perf_event__process_tracing_data(event, session); | 159 | err = perf_event__process_tracing_data(tool, event, session); |
158 | 160 | ||
159 | return err; | 161 | return err; |
160 | } | 162 | } |
@@ -209,7 +211,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool, | |||
209 | 211 | ||
210 | cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 212 | cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
211 | 213 | ||
212 | thread = machine__findnew_thread(machine, event->ip.pid); | 214 | thread = machine__findnew_thread(machine, sample->pid, sample->pid); |
213 | if (thread == NULL) { | 215 | if (thread == NULL) { |
214 | pr_err("problem processing %d event, skipping it.\n", | 216 | pr_err("problem processing %d event, skipping it.\n", |
215 | event->header.type); | 217 | event->header.type); |
@@ -217,7 +219,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool, | |||
217 | } | 219 | } |
218 | 220 | ||
219 | thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION, | 221 | thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION, |
220 | event->ip.ip, &al); | 222 | sample->ip, &al); |
221 | 223 | ||
222 | if (al.map != NULL) { | 224 | if (al.map != NULL) { |
223 | if (!al.map->dso->hit) { | 225 | if (!al.map->dso->hit) { |
@@ -312,13 +314,13 @@ found: | |||
312 | sample_sw.period = sample->period; | 314 | sample_sw.period = sample->period; |
313 | sample_sw.time = sample->time; | 315 | sample_sw.time = sample->time; |
314 | perf_event__synthesize_sample(event_sw, evsel->attr.sample_type, | 316 | perf_event__synthesize_sample(event_sw, evsel->attr.sample_type, |
315 | &sample_sw, false); | 317 | evsel->attr.sample_regs_user, |
318 | evsel->attr.read_format, &sample_sw, | ||
319 | false); | ||
316 | build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine); | 320 | build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine); |
317 | return perf_event__repipe(tool, event_sw, &sample_sw, machine); | 321 | return perf_event__repipe(tool, event_sw, &sample_sw, machine); |
318 | } | 322 | } |
319 | 323 | ||
320 | extern volatile int session_done; | ||
321 | |||
322 | static void sig_handler(int sig __maybe_unused) | 324 | static void sig_handler(int sig __maybe_unused) |
323 | { | 325 | { |
324 | session_done = 1; | 326 | session_done = 1; |
@@ -348,6 +350,7 @@ static int __cmd_inject(struct perf_inject *inject) | |||
348 | 350 | ||
349 | if (inject->build_ids || inject->sched_stat) { | 351 | if (inject->build_ids || inject->sched_stat) { |
350 | inject->tool.mmap = perf_event__repipe_mmap; | 352 | inject->tool.mmap = perf_event__repipe_mmap; |
353 | inject->tool.mmap2 = perf_event__repipe_mmap2; | ||
351 | inject->tool.fork = perf_event__repipe_fork; | 354 | inject->tool.fork = perf_event__repipe_fork; |
352 | inject->tool.tracing_data = perf_event__repipe_tracing_data; | 355 | inject->tool.tracing_data = perf_event__repipe_tracing_data; |
353 | } | 356 | } |
@@ -399,6 +402,7 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) | |||
399 | .tool = { | 402 | .tool = { |
400 | .sample = perf_event__repipe_sample, | 403 | .sample = perf_event__repipe_sample, |
401 | .mmap = perf_event__repipe, | 404 | .mmap = perf_event__repipe, |
405 | .mmap2 = perf_event__repipe, | ||
402 | .comm = perf_event__repipe, | 406 | .comm = perf_event__repipe, |
403 | .fork = perf_event__repipe, | 407 | .fork = perf_event__repipe, |
404 | .exit = perf_event__repipe, | 408 | .exit = perf_event__repipe, |
@@ -407,8 +411,8 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) | |||
407 | .throttle = perf_event__repipe, | 411 | .throttle = perf_event__repipe, |
408 | .unthrottle = perf_event__repipe, | 412 | .unthrottle = perf_event__repipe, |
409 | .attr = perf_event__repipe_attr, | 413 | .attr = perf_event__repipe_attr, |
410 | .event_type = perf_event__repipe_event_type_synth, | 414 | .tracing_data = perf_event__repipe_op2_synth, |
411 | .tracing_data = perf_event__repipe_tracing_data_synth, | 415 | .finished_round = perf_event__repipe_op2_synth, |
412 | .build_id = perf_event__repipe_op2_synth, | 416 | .build_id = perf_event__repipe_op2_synth, |
413 | }, | 417 | }, |
414 | .input_name = "-", | 418 | .input_name = "-", |