diff options
Diffstat (limited to 'tools/perf/builtin-inject.c')
-rw-r--r-- | tools/perf/builtin-inject.c | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 84ad6abe4258..9b336fdb6f71 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, |
@@ -148,13 +136,14 @@ static int perf_event__repipe_fork(struct perf_tool *tool, | |||
148 | return err; | 136 | return err; |
149 | } | 137 | } |
150 | 138 | ||
151 | static int perf_event__repipe_tracing_data(union perf_event *event, | 139 | static int perf_event__repipe_tracing_data(struct perf_tool *tool, |
140 | union perf_event *event, | ||
152 | struct perf_session *session) | 141 | struct perf_session *session) |
153 | { | 142 | { |
154 | int err; | 143 | int err; |
155 | 144 | ||
156 | perf_event__repipe_synth(NULL, event, NULL); | 145 | perf_event__repipe_synth(tool, event); |
157 | err = perf_event__process_tracing_data(event, session); | 146 | err = perf_event__process_tracing_data(tool, event, session); |
158 | 147 | ||
159 | return err; | 148 | return err; |
160 | } | 149 | } |
@@ -209,7 +198,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool, | |||
209 | 198 | ||
210 | cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 199 | cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
211 | 200 | ||
212 | thread = machine__findnew_thread(machine, event->ip.pid); | 201 | thread = machine__findnew_thread(machine, sample->pid, sample->pid); |
213 | if (thread == NULL) { | 202 | if (thread == NULL) { |
214 | pr_err("problem processing %d event, skipping it.\n", | 203 | pr_err("problem processing %d event, skipping it.\n", |
215 | event->header.type); | 204 | event->header.type); |
@@ -217,7 +206,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool, | |||
217 | } | 206 | } |
218 | 207 | ||
219 | thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION, | 208 | thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION, |
220 | event->ip.ip, &al); | 209 | sample->ip, &al); |
221 | 210 | ||
222 | if (al.map != NULL) { | 211 | if (al.map != NULL) { |
223 | if (!al.map->dso->hit) { | 212 | if (!al.map->dso->hit) { |
@@ -312,7 +301,9 @@ found: | |||
312 | sample_sw.period = sample->period; | 301 | sample_sw.period = sample->period; |
313 | sample_sw.time = sample->time; | 302 | sample_sw.time = sample->time; |
314 | perf_event__synthesize_sample(event_sw, evsel->attr.sample_type, | 303 | perf_event__synthesize_sample(event_sw, evsel->attr.sample_type, |
315 | &sample_sw, false); | 304 | evsel->attr.sample_regs_user, |
305 | evsel->attr.read_format, &sample_sw, | ||
306 | false); | ||
316 | build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine); | 307 | build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine); |
317 | return perf_event__repipe(tool, event_sw, &sample_sw, machine); | 308 | return perf_event__repipe(tool, event_sw, &sample_sw, machine); |
318 | } | 309 | } |
@@ -407,8 +398,8 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) | |||
407 | .throttle = perf_event__repipe, | 398 | .throttle = perf_event__repipe, |
408 | .unthrottle = perf_event__repipe, | 399 | .unthrottle = perf_event__repipe, |
409 | .attr = perf_event__repipe_attr, | 400 | .attr = perf_event__repipe_attr, |
410 | .event_type = perf_event__repipe_event_type_synth, | 401 | .tracing_data = perf_event__repipe_op2_synth, |
411 | .tracing_data = perf_event__repipe_tracing_data_synth, | 402 | .finished_round = perf_event__repipe_op2_synth, |
412 | .build_id = perf_event__repipe_op2_synth, | 403 | .build_id = perf_event__repipe_op2_synth, |
413 | }, | 404 | }, |
414 | .input_name = "-", | 405 | .input_name = "-", |