Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 1 | /* |
| 2 | * builtin-inject.c |
| 3 | * |
| 4 | * Builtin inject command: Examine the live mode (stdin) event stream |
| 5 | * and repipe it to stdout while optionally injecting additional |
| 6 | * events into it. |
| 7 | */ |
| 8 | #include "builtin.h" |
| 9 | |
| 10 | #include "perf.h" |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 11 | #include "util/color.h" |
| 12 | #include "util/evlist.h" |
| 13 | #include "util/evsel.h" |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 14 | #include "util/session.h" |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 15 | #include "util/tool.h" |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 16 | #include "util/debug.h" |
Andrew Vagin | 54a3cf5 | 2012-08-07 16:56:05 +0400 | [diff] [blame] | 17 | #include "util/build-id.h" |
Jiri Olsa | f5fc1412 | 2013-10-15 16:27:32 +0200 | [diff] [blame] | 18 | #include "util/data.h" |
Adrian Hunter | 0f0aa5e | 2015-04-09 18:54:00 +0300 | [diff] [blame] | 19 | #include "util/auxtrace.h" |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 20 | |
| 21 | #include "util/parse-options.h" |
| 22 | |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 23 | #include <linux/list.h> |
| 24 | |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 25 | struct perf_inject { |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 26 | struct perf_tool tool; |
Namhyung Kim | 1cb8bdc | 2014-08-12 15:40:37 +0900 | [diff] [blame] | 27 | struct perf_session *session; |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 28 | bool build_ids; |
| 29 | bool sched_stat; |
Adrian Hunter | cd10b28 | 2015-04-30 17:37:26 +0300 | [diff] [blame^] | 30 | bool have_auxtrace; |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 31 | const char *input_name; |
| 32 | struct perf_data_file output; |
| 33 | u64 bytes_written; |
| 34 | struct list_head samples; |
Adrian Hunter | 0f0aa5e | 2015-04-09 18:54:00 +0300 | [diff] [blame] | 35 | struct itrace_synth_opts itrace_synth_opts; |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | struct event_entry { |
| 39 | struct list_head node; |
| 40 | u32 tid; |
| 41 | union perf_event event[0]; |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 42 | }; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 43 | |
Adrian Hunter | cd17a9b | 2015-04-21 12:21:54 +0300 | [diff] [blame] | 44 | static int output_bytes(struct perf_inject *inject, void *buf, size_t sz) |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 45 | { |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 46 | ssize_t size; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 47 | |
Adrian Hunter | cd17a9b | 2015-04-21 12:21:54 +0300 | [diff] [blame] | 48 | size = perf_data_file__write(&inject->output, buf, sz); |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 49 | if (size < 0) |
| 50 | return -errno; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 51 | |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 52 | inject->bytes_written += size; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 53 | return 0; |
| 54 | } |
| 55 | |
Adrian Hunter | cd17a9b | 2015-04-21 12:21:54 +0300 | [diff] [blame] | 56 | static int copy_bytes(struct perf_inject *inject, int fd, off_t size) |
| 57 | { |
| 58 | char buf[4096]; |
| 59 | ssize_t ssz; |
| 60 | int ret; |
| 61 | |
| 62 | while (size > 0) { |
| 63 | ssz = read(fd, buf, min(size, (off_t)sizeof(buf))); |
| 64 | if (ssz < 0) |
| 65 | return -errno; |
| 66 | ret = output_bytes(inject, buf, ssz); |
| 67 | if (ret) |
| 68 | return ret; |
| 69 | size -= ssz; |
| 70 | } |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | static int perf_event__repipe_synth(struct perf_tool *tool, |
| 76 | union perf_event *event) |
| 77 | { |
| 78 | struct perf_inject *inject = container_of(tool, struct perf_inject, |
| 79 | tool); |
| 80 | |
| 81 | return output_bytes(inject, event, event->header.size); |
| 82 | } |
| 83 | |
Arnaldo Carvalho de Melo | d704ebd | 2015-03-03 12:37:54 -0300 | [diff] [blame] | 84 | static int perf_event__repipe_oe_synth(struct perf_tool *tool, |
| 85 | union perf_event *event, |
| 86 | struct ordered_events *oe __maybe_unused) |
| 87 | { |
| 88 | return perf_event__repipe_synth(tool, event); |
| 89 | } |
| 90 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 91 | static int perf_event__repipe_op2_synth(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 92 | union perf_event *event, |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 93 | struct perf_session *session |
| 94 | __maybe_unused) |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 95 | { |
Adrian Hunter | 63c2c9f | 2013-07-04 16:20:20 +0300 | [diff] [blame] | 96 | return perf_event__repipe_synth(tool, event); |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 97 | } |
| 98 | |
Adrian Hunter | 47c3d10 | 2013-07-04 16:20:21 +0300 | [diff] [blame] | 99 | static int perf_event__repipe_attr(struct perf_tool *tool, |
| 100 | union perf_event *event, |
| 101 | struct perf_evlist **pevlist) |
Arnaldo Carvalho de Melo | 10d0f08 | 2011-11-11 22:45:41 -0200 | [diff] [blame] | 102 | { |
Adrian Hunter | 89c97d9 | 2013-10-22 10:34:09 +0300 | [diff] [blame] | 103 | struct perf_inject *inject = container_of(tool, struct perf_inject, |
| 104 | tool); |
Stephane Eranian | 1a1ed1b | 2012-05-15 13:28:11 +0200 | [diff] [blame] | 105 | int ret; |
Adrian Hunter | 47c3d10 | 2013-07-04 16:20:21 +0300 | [diff] [blame] | 106 | |
| 107 | ret = perf_event__process_attr(tool, event, pevlist); |
Stephane Eranian | 1a1ed1b | 2012-05-15 13:28:11 +0200 | [diff] [blame] | 108 | if (ret) |
| 109 | return ret; |
| 110 | |
Jiri Olsa | a261e4a | 2014-06-05 18:51:44 +0200 | [diff] [blame] | 111 | if (!inject->output.is_pipe) |
Adrian Hunter | 89c97d9 | 2013-10-22 10:34:09 +0300 | [diff] [blame] | 112 | return 0; |
| 113 | |
Adrian Hunter | 47c3d10 | 2013-07-04 16:20:21 +0300 | [diff] [blame] | 114 | return perf_event__repipe_synth(tool, event); |
Arnaldo Carvalho de Melo | 10d0f08 | 2011-11-11 22:45:41 -0200 | [diff] [blame] | 115 | } |
| 116 | |
Adrian Hunter | cd17a9b | 2015-04-21 12:21:54 +0300 | [diff] [blame] | 117 | static s64 perf_event__repipe_auxtrace(struct perf_tool *tool, |
| 118 | union perf_event *event, |
| 119 | struct perf_session *session |
| 120 | __maybe_unused) |
| 121 | { |
| 122 | struct perf_inject *inject = container_of(tool, struct perf_inject, |
| 123 | tool); |
| 124 | int ret; |
| 125 | |
Adrian Hunter | cd10b28 | 2015-04-30 17:37:26 +0300 | [diff] [blame^] | 126 | inject->have_auxtrace = true; |
| 127 | |
Adrian Hunter | 99fa298 | 2015-04-30 17:37:25 +0300 | [diff] [blame] | 128 | if (!inject->output.is_pipe) { |
| 129 | off_t offset; |
| 130 | |
| 131 | offset = lseek(inject->output.fd, 0, SEEK_CUR); |
| 132 | if (offset == -1) |
| 133 | return -errno; |
| 134 | ret = auxtrace_index__auxtrace_event(&session->auxtrace_index, |
| 135 | event, offset); |
| 136 | if (ret < 0) |
| 137 | return ret; |
| 138 | } |
| 139 | |
Adrian Hunter | cd17a9b | 2015-04-21 12:21:54 +0300 | [diff] [blame] | 140 | if (perf_data_file__is_pipe(session->file) || !session->one_mmap) { |
| 141 | ret = output_bytes(inject, event, event->header.size); |
| 142 | if (ret < 0) |
| 143 | return ret; |
| 144 | ret = copy_bytes(inject, perf_data_file__fd(session->file), |
| 145 | event->auxtrace.size); |
| 146 | } else { |
| 147 | ret = output_bytes(inject, event, |
| 148 | event->header.size + event->auxtrace.size); |
| 149 | } |
| 150 | if (ret < 0) |
| 151 | return ret; |
| 152 | |
| 153 | return event->auxtrace.size; |
| 154 | } |
| 155 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 156 | static int perf_event__repipe(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 157 | union perf_event *event, |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 158 | struct perf_sample *sample __maybe_unused, |
Adrian Hunter | 63c2c9f | 2013-07-04 16:20:20 +0300 | [diff] [blame] | 159 | struct machine *machine __maybe_unused) |
Arnaldo Carvalho de Melo | 640c03c | 2010-12-02 14:10:21 -0200 | [diff] [blame] | 160 | { |
Adrian Hunter | 63c2c9f | 2013-07-04 16:20:20 +0300 | [diff] [blame] | 161 | return perf_event__repipe_synth(tool, event); |
Arnaldo Carvalho de Melo | 640c03c | 2010-12-02 14:10:21 -0200 | [diff] [blame] | 162 | } |
| 163 | |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 164 | typedef int (*inject_handler)(struct perf_tool *tool, |
| 165 | union perf_event *event, |
| 166 | struct perf_sample *sample, |
| 167 | struct perf_evsel *evsel, |
| 168 | struct machine *machine); |
| 169 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 170 | static int perf_event__repipe_sample(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 171 | union perf_event *event, |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 172 | struct perf_sample *sample, |
| 173 | struct perf_evsel *evsel, |
| 174 | struct machine *machine) |
Arnaldo Carvalho de Melo | 9e69c21 | 2011-03-15 15:44:01 -0300 | [diff] [blame] | 175 | { |
Arnaldo Carvalho de Melo | 744a971 | 2013-11-06 10:17:38 -0300 | [diff] [blame] | 176 | if (evsel->handler) { |
| 177 | inject_handler f = evsel->handler; |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 178 | return f(tool, event, sample, evsel, machine); |
| 179 | } |
| 180 | |
Andrew Vagin | 54a3cf5 | 2012-08-07 16:56:05 +0400 | [diff] [blame] | 181 | build_id__mark_dso_hit(tool, event, sample, evsel, machine); |
| 182 | |
Adrian Hunter | 63c2c9f | 2013-07-04 16:20:20 +0300 | [diff] [blame] | 183 | return perf_event__repipe_synth(tool, event); |
Arnaldo Carvalho de Melo | 9e69c21 | 2011-03-15 15:44:01 -0300 | [diff] [blame] | 184 | } |
| 185 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 186 | static int perf_event__repipe_mmap(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 187 | union perf_event *event, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 188 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 189 | struct machine *machine) |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 190 | { |
| 191 | int err; |
| 192 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 193 | err = perf_event__process_mmap(tool, event, sample, machine); |
| 194 | perf_event__repipe(tool, event, sample, machine); |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 195 | |
| 196 | return err; |
| 197 | } |
| 198 | |
Stephane Eranian | 5c5e854 | 2013-08-21 12:10:25 +0200 | [diff] [blame] | 199 | static int perf_event__repipe_mmap2(struct perf_tool *tool, |
| 200 | union perf_event *event, |
| 201 | struct perf_sample *sample, |
| 202 | struct machine *machine) |
| 203 | { |
| 204 | int err; |
| 205 | |
| 206 | err = perf_event__process_mmap2(tool, event, sample, machine); |
| 207 | perf_event__repipe(tool, event, sample, machine); |
| 208 | |
| 209 | return err; |
| 210 | } |
| 211 | |
Arnaldo Carvalho de Melo | f62d3f0 | 2012-10-06 15:44:59 -0300 | [diff] [blame] | 212 | static int perf_event__repipe_fork(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 213 | union perf_event *event, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 214 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 215 | struct machine *machine) |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 216 | { |
| 217 | int err; |
| 218 | |
Arnaldo Carvalho de Melo | f62d3f0 | 2012-10-06 15:44:59 -0300 | [diff] [blame] | 219 | err = perf_event__process_fork(tool, event, sample, machine); |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 220 | perf_event__repipe(tool, event, sample, machine); |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 221 | |
| 222 | return err; |
| 223 | } |
| 224 | |
Adrian Hunter | 0f0aa5e | 2015-04-09 18:54:00 +0300 | [diff] [blame] | 225 | static int perf_event__repipe_comm(struct perf_tool *tool, |
| 226 | union perf_event *event, |
| 227 | struct perf_sample *sample, |
| 228 | struct machine *machine) |
| 229 | { |
| 230 | int err; |
| 231 | |
| 232 | err = perf_event__process_comm(tool, event, sample, machine); |
| 233 | perf_event__repipe(tool, event, sample, machine); |
| 234 | |
| 235 | return err; |
| 236 | } |
| 237 | |
| 238 | static int perf_event__repipe_exit(struct perf_tool *tool, |
| 239 | union perf_event *event, |
| 240 | struct perf_sample *sample, |
| 241 | struct machine *machine) |
| 242 | { |
| 243 | int err; |
| 244 | |
| 245 | err = perf_event__process_exit(tool, event, sample, machine); |
| 246 | perf_event__repipe(tool, event, sample, machine); |
| 247 | |
| 248 | return err; |
| 249 | } |
| 250 | |
Adrian Hunter | 47c3d10 | 2013-07-04 16:20:21 +0300 | [diff] [blame] | 251 | static int perf_event__repipe_tracing_data(struct perf_tool *tool, |
| 252 | union perf_event *event, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 253 | struct perf_session *session) |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 254 | { |
| 255 | int err; |
| 256 | |
Adrian Hunter | 47c3d10 | 2013-07-04 16:20:21 +0300 | [diff] [blame] | 257 | perf_event__repipe_synth(tool, event); |
| 258 | err = perf_event__process_tracing_data(tool, event, session); |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 259 | |
| 260 | return err; |
| 261 | } |
| 262 | |
Adrian Hunter | 0f0aa5e | 2015-04-09 18:54:00 +0300 | [diff] [blame] | 263 | static int perf_event__repipe_id_index(struct perf_tool *tool, |
| 264 | union perf_event *event, |
| 265 | struct perf_session *session) |
| 266 | { |
| 267 | int err; |
| 268 | |
| 269 | perf_event__repipe_synth(tool, event); |
| 270 | err = perf_event__process_id_index(tool, event, session); |
| 271 | |
| 272 | return err; |
| 273 | } |
| 274 | |
Arnaldo Carvalho de Melo | c824c43 | 2013-10-22 19:01:31 -0300 | [diff] [blame] | 275 | static int dso__read_build_id(struct dso *dso) |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 276 | { |
Arnaldo Carvalho de Melo | c824c43 | 2013-10-22 19:01:31 -0300 | [diff] [blame] | 277 | if (dso->has_build_id) |
Arnaldo Carvalho de Melo | 090f720 | 2010-05-02 19:46:36 -0300 | [diff] [blame] | 278 | return 0; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 279 | |
Arnaldo Carvalho de Melo | c824c43 | 2013-10-22 19:01:31 -0300 | [diff] [blame] | 280 | if (filename__read_build_id(dso->long_name, dso->build_id, |
| 281 | sizeof(dso->build_id)) > 0) { |
| 282 | dso->has_build_id = true; |
Arnaldo Carvalho de Melo | 090f720 | 2010-05-02 19:46:36 -0300 | [diff] [blame] | 283 | return 0; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 284 | } |
| 285 | |
Arnaldo Carvalho de Melo | 090f720 | 2010-05-02 19:46:36 -0300 | [diff] [blame] | 286 | return -1; |
| 287 | } |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 288 | |
Arnaldo Carvalho de Melo | c824c43 | 2013-10-22 19:01:31 -0300 | [diff] [blame] | 289 | static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 290 | struct machine *machine) |
Arnaldo Carvalho de Melo | 090f720 | 2010-05-02 19:46:36 -0300 | [diff] [blame] | 291 | { |
| 292 | u16 misc = PERF_RECORD_MISC_USER; |
Arnaldo Carvalho de Melo | 090f720 | 2010-05-02 19:46:36 -0300 | [diff] [blame] | 293 | int err; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 294 | |
Arnaldo Carvalho de Melo | c824c43 | 2013-10-22 19:01:31 -0300 | [diff] [blame] | 295 | if (dso__read_build_id(dso) < 0) { |
| 296 | pr_debug("no build_id found for %s\n", dso->long_name); |
Arnaldo Carvalho de Melo | 090f720 | 2010-05-02 19:46:36 -0300 | [diff] [blame] | 297 | return -1; |
| 298 | } |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 299 | |
Arnaldo Carvalho de Melo | c824c43 | 2013-10-22 19:01:31 -0300 | [diff] [blame] | 300 | if (dso->kernel) |
Arnaldo Carvalho de Melo | 090f720 | 2010-05-02 19:46:36 -0300 | [diff] [blame] | 301 | misc = PERF_RECORD_MISC_KERNEL; |
| 302 | |
Arnaldo Carvalho de Melo | c824c43 | 2013-10-22 19:01:31 -0300 | [diff] [blame] | 303 | err = perf_event__synthesize_build_id(tool, dso, misc, perf_event__repipe, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 304 | machine); |
Arnaldo Carvalho de Melo | 090f720 | 2010-05-02 19:46:36 -0300 | [diff] [blame] | 305 | if (err) { |
Arnaldo Carvalho de Melo | c824c43 | 2013-10-22 19:01:31 -0300 | [diff] [blame] | 306 | pr_err("Can't synthesize build_id event for %s\n", dso->long_name); |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 307 | return -1; |
| 308 | } |
| 309 | |
| 310 | return 0; |
| 311 | } |
| 312 | |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 313 | static int perf_event__inject_buildid(struct perf_tool *tool, |
Arnaldo Carvalho de Melo | d20deb6 | 2011-11-25 08:19:45 -0200 | [diff] [blame] | 314 | union perf_event *event, |
Arnaldo Carvalho de Melo | 8115d60 | 2011-01-29 14:01:45 -0200 | [diff] [blame] | 315 | struct perf_sample *sample, |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 316 | struct perf_evsel *evsel __maybe_unused, |
Arnaldo Carvalho de Melo | 743eb86 | 2011-11-28 07:56:39 -0200 | [diff] [blame] | 317 | struct machine *machine) |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 318 | { |
| 319 | struct addr_location al; |
| 320 | struct thread *thread; |
| 321 | u8 cpumode; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 322 | |
| 323 | cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
| 324 | |
Namhyung Kim | 13ce34d | 2014-05-12 09:56:42 +0900 | [diff] [blame] | 325 | thread = machine__findnew_thread(machine, sample->pid, sample->tid); |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 326 | if (thread == NULL) { |
| 327 | pr_err("problem processing %d event, skipping it.\n", |
| 328 | event->header.type); |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 329 | goto repipe; |
| 330 | } |
| 331 | |
Arnaldo Carvalho de Melo | bb871a9 | 2014-10-23 12:50:25 -0300 | [diff] [blame] | 332 | thread__find_addr_map(thread, cpumode, MAP__FUNCTION, sample->ip, &al); |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 333 | |
| 334 | if (al.map != NULL) { |
| 335 | if (!al.map->dso->hit) { |
| 336 | al.map->dso->hit = 1; |
Arnaldo Carvalho de Melo | 090f720 | 2010-05-02 19:46:36 -0300 | [diff] [blame] | 337 | if (map__load(al.map, NULL) >= 0) { |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 338 | dso__inject_build_id(al.map->dso, tool, machine); |
Arnaldo Carvalho de Melo | 090f720 | 2010-05-02 19:46:36 -0300 | [diff] [blame] | 339 | /* |
| 340 | * If this fails, too bad, let the other side |
| 341 | * account this as unresolved. |
| 342 | */ |
Namhyung Kim | 393be2e | 2012-08-06 13:41:21 +0900 | [diff] [blame] | 343 | } else { |
Ingo Molnar | 89fe808 | 2013-09-30 12:07:11 +0200 | [diff] [blame] | 344 | #ifdef HAVE_LIBELF_SUPPORT |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 345 | pr_warning("no symbols found in %s, maybe " |
| 346 | "install a debug package?\n", |
| 347 | al.map->dso->long_name); |
Namhyung Kim | 393be2e | 2012-08-06 13:41:21 +0900 | [diff] [blame] | 348 | #endif |
| 349 | } |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 350 | } |
| 351 | } |
| 352 | |
| 353 | repipe: |
Arnaldo Carvalho de Melo | 45694aa | 2011-11-28 08:30:20 -0200 | [diff] [blame] | 354 | perf_event__repipe(tool, event, sample, machine); |
Arnaldo Carvalho de Melo | 090f720 | 2010-05-02 19:46:36 -0300 | [diff] [blame] | 355 | return 0; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 356 | } |
| 357 | |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 358 | static int perf_inject__sched_process_exit(struct perf_tool *tool, |
| 359 | union perf_event *event __maybe_unused, |
| 360 | struct perf_sample *sample, |
| 361 | struct perf_evsel *evsel __maybe_unused, |
| 362 | struct machine *machine __maybe_unused) |
| 363 | { |
| 364 | struct perf_inject *inject = container_of(tool, struct perf_inject, tool); |
| 365 | struct event_entry *ent; |
| 366 | |
| 367 | list_for_each_entry(ent, &inject->samples, node) { |
| 368 | if (sample->tid == ent->tid) { |
| 369 | list_del_init(&ent->node); |
| 370 | free(ent); |
| 371 | break; |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | static int perf_inject__sched_switch(struct perf_tool *tool, |
| 379 | union perf_event *event, |
| 380 | struct perf_sample *sample, |
| 381 | struct perf_evsel *evsel, |
| 382 | struct machine *machine) |
| 383 | { |
| 384 | struct perf_inject *inject = container_of(tool, struct perf_inject, tool); |
| 385 | struct event_entry *ent; |
| 386 | |
| 387 | perf_inject__sched_process_exit(tool, event, sample, evsel, machine); |
| 388 | |
| 389 | ent = malloc(event->header.size + sizeof(struct event_entry)); |
| 390 | if (ent == NULL) { |
| 391 | color_fprintf(stderr, PERF_COLOR_RED, |
| 392 | "Not enough memory to process sched switch event!"); |
| 393 | return -1; |
| 394 | } |
| 395 | |
| 396 | ent->tid = sample->tid; |
| 397 | memcpy(&ent->event, event, event->header.size); |
| 398 | list_add(&ent->node, &inject->samples); |
| 399 | return 0; |
| 400 | } |
| 401 | |
| 402 | static int perf_inject__sched_stat(struct perf_tool *tool, |
| 403 | union perf_event *event __maybe_unused, |
| 404 | struct perf_sample *sample, |
| 405 | struct perf_evsel *evsel, |
| 406 | struct machine *machine) |
| 407 | { |
| 408 | struct event_entry *ent; |
| 409 | union perf_event *event_sw; |
| 410 | struct perf_sample sample_sw; |
| 411 | struct perf_inject *inject = container_of(tool, struct perf_inject, tool); |
| 412 | u32 pid = perf_evsel__intval(evsel, sample, "pid"); |
| 413 | |
| 414 | list_for_each_entry(ent, &inject->samples, node) { |
| 415 | if (pid == ent->tid) |
| 416 | goto found; |
| 417 | } |
| 418 | |
| 419 | return 0; |
| 420 | found: |
| 421 | event_sw = &ent->event[0]; |
| 422 | perf_evsel__parse_sample(evsel, event_sw, &sample_sw); |
| 423 | |
| 424 | sample_sw.period = sample->period; |
| 425 | sample_sw.time = sample->time; |
| 426 | perf_event__synthesize_sample(event_sw, evsel->attr.sample_type, |
Adrian Hunter | d03f217 | 2013-08-27 11:23:11 +0300 | [diff] [blame] | 427 | evsel->attr.read_format, &sample_sw, |
| 428 | false); |
Andrew Vagin | 54a3cf5 | 2012-08-07 16:56:05 +0400 | [diff] [blame] | 429 | build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine); |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 430 | return perf_event__repipe(tool, event_sw, &sample_sw, machine); |
| 431 | } |
| 432 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 433 | static void sig_handler(int sig __maybe_unused) |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 434 | { |
| 435 | session_done = 1; |
| 436 | } |
| 437 | |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 438 | static int perf_evsel__check_stype(struct perf_evsel *evsel, |
| 439 | u64 sample_type, const char *sample_msg) |
| 440 | { |
| 441 | struct perf_event_attr *attr = &evsel->attr; |
| 442 | const char *name = perf_evsel__name(evsel); |
| 443 | |
| 444 | if (!(attr->sample_type & sample_type)) { |
| 445 | pr_err("Samples for %s event do not have %s attribute set.", |
| 446 | name, sample_msg); |
| 447 | return -EINVAL; |
| 448 | } |
| 449 | |
| 450 | return 0; |
| 451 | } |
| 452 | |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 453 | static int __cmd_inject(struct perf_inject *inject) |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 454 | { |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 455 | int ret = -EINVAL; |
Namhyung Kim | 1cb8bdc | 2014-08-12 15:40:37 +0900 | [diff] [blame] | 456 | struct perf_session *session = inject->session; |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 457 | struct perf_data_file *file_out = &inject->output; |
Namhyung Kim | 42aa276 | 2015-01-29 17:06:48 +0900 | [diff] [blame] | 458 | int fd = perf_data_file__fd(file_out); |
Adrian Hunter | 0f0aa5e | 2015-04-09 18:54:00 +0300 | [diff] [blame] | 459 | u64 output_data_offset; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 460 | |
| 461 | signal(SIGINT, sig_handler); |
| 462 | |
Adrian Hunter | 0f0aa5e | 2015-04-09 18:54:00 +0300 | [diff] [blame] | 463 | if (inject->build_ids || inject->sched_stat || |
| 464 | inject->itrace_synth_opts.set) { |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 465 | inject->tool.mmap = perf_event__repipe_mmap; |
Stephane Eranian | 5c5e854 | 2013-08-21 12:10:25 +0200 | [diff] [blame] | 466 | inject->tool.mmap2 = perf_event__repipe_mmap2; |
Arnaldo Carvalho de Melo | f62d3f0 | 2012-10-06 15:44:59 -0300 | [diff] [blame] | 467 | inject->tool.fork = perf_event__repipe_fork; |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 468 | inject->tool.tracing_data = perf_event__repipe_tracing_data; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 469 | } |
| 470 | |
Adrian Hunter | 0f0aa5e | 2015-04-09 18:54:00 +0300 | [diff] [blame] | 471 | output_data_offset = session->header.data_offset; |
| 472 | |
Andrew Vagin | 54a3cf5 | 2012-08-07 16:56:05 +0400 | [diff] [blame] | 473 | if (inject->build_ids) { |
| 474 | inject->tool.sample = perf_event__inject_buildid; |
| 475 | } else if (inject->sched_stat) { |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 476 | struct perf_evsel *evsel; |
| 477 | |
Arnaldo Carvalho de Melo | 0050f7a | 2014-01-10 10:37:27 -0300 | [diff] [blame] | 478 | evlist__for_each(session->evlist, evsel) { |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 479 | const char *name = perf_evsel__name(evsel); |
| 480 | |
| 481 | if (!strcmp(name, "sched:sched_switch")) { |
| 482 | if (perf_evsel__check_stype(evsel, PERF_SAMPLE_TID, "TID")) |
| 483 | return -EINVAL; |
| 484 | |
Arnaldo Carvalho de Melo | 744a971 | 2013-11-06 10:17:38 -0300 | [diff] [blame] | 485 | evsel->handler = perf_inject__sched_switch; |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 486 | } else if (!strcmp(name, "sched:sched_process_exit")) |
Arnaldo Carvalho de Melo | 744a971 | 2013-11-06 10:17:38 -0300 | [diff] [blame] | 487 | evsel->handler = perf_inject__sched_process_exit; |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 488 | else if (!strncmp(name, "sched:sched_stat_", 17)) |
Arnaldo Carvalho de Melo | 744a971 | 2013-11-06 10:17:38 -0300 | [diff] [blame] | 489 | evsel->handler = perf_inject__sched_stat; |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 490 | } |
Adrian Hunter | 0f0aa5e | 2015-04-09 18:54:00 +0300 | [diff] [blame] | 491 | } else if (inject->itrace_synth_opts.set) { |
| 492 | session->itrace_synth_opts = &inject->itrace_synth_opts; |
| 493 | inject->itrace_synth_opts.inject = true; |
| 494 | inject->tool.comm = perf_event__repipe_comm; |
| 495 | inject->tool.exit = perf_event__repipe_exit; |
| 496 | inject->tool.id_index = perf_event__repipe_id_index; |
| 497 | inject->tool.auxtrace_info = perf_event__process_auxtrace_info; |
| 498 | inject->tool.auxtrace = perf_event__process_auxtrace; |
| 499 | inject->tool.ordered_events = true; |
| 500 | inject->tool.ordering_requires_timestamps = true; |
| 501 | /* Allow space in the header for new attributes */ |
| 502 | output_data_offset = 4096; |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 503 | } |
| 504 | |
Adrian Hunter | 99fa298 | 2015-04-30 17:37:25 +0300 | [diff] [blame] | 505 | if (!inject->itrace_synth_opts.set) |
| 506 | auxtrace_index__free(&session->auxtrace_index); |
| 507 | |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 508 | if (!file_out->is_pipe) |
Adrian Hunter | 0f0aa5e | 2015-04-09 18:54:00 +0300 | [diff] [blame] | 509 | lseek(fd, output_data_offset, SEEK_SET); |
Andrew Vagin | e558a5b | 2012-08-07 16:56:02 +0400 | [diff] [blame] | 510 | |
Arnaldo Carvalho de Melo | b7b61cb | 2015-03-03 11:58:45 -0300 | [diff] [blame] | 511 | ret = perf_session__process_events(session); |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 512 | |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 513 | if (!file_out->is_pipe) { |
Adrian Hunter | cd10b28 | 2015-04-30 17:37:26 +0300 | [diff] [blame^] | 514 | if (inject->build_ids) { |
Adrian Hunter | e38b43c | 2014-07-14 13:02:34 +0300 | [diff] [blame] | 515 | perf_header__set_feat(&session->header, |
| 516 | HEADER_BUILD_ID); |
Adrian Hunter | cd10b28 | 2015-04-30 17:37:26 +0300 | [diff] [blame^] | 517 | if (inject->have_auxtrace) |
| 518 | dsos__hit_all(session); |
| 519 | } |
Adrian Hunter | 0f0aa5e | 2015-04-09 18:54:00 +0300 | [diff] [blame] | 520 | /* |
| 521 | * The AUX areas have been removed and replaced with |
| 522 | * synthesized hardware events, so clear the feature flag. |
| 523 | */ |
| 524 | if (inject->itrace_synth_opts.set) |
| 525 | perf_header__clear_feat(&session->header, |
| 526 | HEADER_AUXTRACE); |
| 527 | session->header.data_offset = output_data_offset; |
Andrew Vagin | e558a5b | 2012-08-07 16:56:02 +0400 | [diff] [blame] | 528 | session->header.data_size = inject->bytes_written; |
Namhyung Kim | 42aa276 | 2015-01-29 17:06:48 +0900 | [diff] [blame] | 529 | perf_session__write_header(session, session->evlist, fd, true); |
Andrew Vagin | e558a5b | 2012-08-07 16:56:02 +0400 | [diff] [blame] | 530 | } |
| 531 | |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 532 | return ret; |
| 533 | } |
| 534 | |
Irina Tirdea | 1d037ca | 2012-09-11 01:15:03 +0300 | [diff] [blame] | 535 | int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 536 | { |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 537 | struct perf_inject inject = { |
| 538 | .tool = { |
| 539 | .sample = perf_event__repipe_sample, |
| 540 | .mmap = perf_event__repipe, |
Stephane Eranian | 5c5e854 | 2013-08-21 12:10:25 +0200 | [diff] [blame] | 541 | .mmap2 = perf_event__repipe, |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 542 | .comm = perf_event__repipe, |
| 543 | .fork = perf_event__repipe, |
| 544 | .exit = perf_event__repipe, |
| 545 | .lost = perf_event__repipe, |
| 546 | .read = perf_event__repipe_sample, |
| 547 | .throttle = perf_event__repipe, |
| 548 | .unthrottle = perf_event__repipe, |
| 549 | .attr = perf_event__repipe_attr, |
Adrian Hunter | 47c3d10 | 2013-07-04 16:20:21 +0300 | [diff] [blame] | 550 | .tracing_data = perf_event__repipe_op2_synth, |
Adrian Hunter | cd17a9b | 2015-04-21 12:21:54 +0300 | [diff] [blame] | 551 | .auxtrace_info = perf_event__repipe_op2_synth, |
| 552 | .auxtrace = perf_event__repipe_auxtrace, |
| 553 | .auxtrace_error = perf_event__repipe_op2_synth, |
Arnaldo Carvalho de Melo | d704ebd | 2015-03-03 12:37:54 -0300 | [diff] [blame] | 554 | .finished_round = perf_event__repipe_oe_synth, |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 555 | .build_id = perf_event__repipe_op2_synth, |
Adrian Hunter | 3c659ee | 2014-10-27 15:49:22 +0200 | [diff] [blame] | 556 | .id_index = perf_event__repipe_op2_synth, |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 557 | }, |
Andrew Vagin | e558a5b | 2012-08-07 16:56:02 +0400 | [diff] [blame] | 558 | .input_name = "-", |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 559 | .samples = LIST_HEAD_INIT(inject.samples), |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 560 | .output = { |
| 561 | .path = "-", |
| 562 | .mode = PERF_DATA_MODE_WRITE, |
| 563 | }, |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 564 | }; |
Namhyung Kim | 1cb8bdc | 2014-08-12 15:40:37 +0900 | [diff] [blame] | 565 | struct perf_data_file file = { |
| 566 | .mode = PERF_DATA_MODE_READ, |
| 567 | }; |
| 568 | int ret; |
| 569 | |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 570 | const struct option options[] = { |
| 571 | OPT_BOOLEAN('b', "build-ids", &inject.build_ids, |
| 572 | "Inject build-ids into the output stream"), |
Andrew Vagin | e558a5b | 2012-08-07 16:56:02 +0400 | [diff] [blame] | 573 | OPT_STRING('i', "input", &inject.input_name, "file", |
| 574 | "input file name"), |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 575 | OPT_STRING('o', "output", &inject.output.path, "file", |
Andrew Vagin | e558a5b | 2012-08-07 16:56:02 +0400 | [diff] [blame] | 576 | "output file name"), |
Andrew Vagin | 26a031e | 2012-08-07 16:56:04 +0400 | [diff] [blame] | 577 | OPT_BOOLEAN('s', "sched-stat", &inject.sched_stat, |
| 578 | "Merge sched-stat and sched-switch for getting events " |
| 579 | "where and how long tasks slept"), |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 580 | OPT_INCR('v', "verbose", &verbose, |
| 581 | "be more verbose (show build ids, etc)"), |
Adrian Hunter | a7a2b8b | 2014-07-22 16:17:38 +0300 | [diff] [blame] | 582 | OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, "file", |
| 583 | "kallsyms pathname"), |
Yunlong Song | ccaa474 | 2015-04-02 21:47:11 +0800 | [diff] [blame] | 584 | OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"), |
Adrian Hunter | 0f0aa5e | 2015-04-09 18:54:00 +0300 | [diff] [blame] | 585 | OPT_CALLBACK_OPTARG(0, "itrace", &inject.itrace_synth_opts, |
| 586 | NULL, "opts", "Instruction Tracing options", |
| 587 | itrace_parse_synth_opts), |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 588 | OPT_END() |
| 589 | }; |
Arnaldo Carvalho de Melo | 002439e | 2012-10-01 15:20:58 -0300 | [diff] [blame] | 590 | const char * const inject_usage[] = { |
| 591 | "perf inject [<options>]", |
| 592 | NULL |
| 593 | }; |
Arnaldo Carvalho de Melo | 5ded57a | 2012-09-30 19:54:10 -0300 | [diff] [blame] | 594 | |
Arnaldo Carvalho de Melo | 002439e | 2012-10-01 15:20:58 -0300 | [diff] [blame] | 595 | argc = parse_options(argc, argv, options, inject_usage, 0); |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 596 | |
| 597 | /* |
| 598 | * Any (unrecognized) arguments left? |
| 599 | */ |
| 600 | if (argc) |
Arnaldo Carvalho de Melo | 002439e | 2012-10-01 15:20:58 -0300 | [diff] [blame] | 601 | usage_with_options(inject_usage, options); |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 602 | |
Jiri Olsa | 3406912 | 2013-10-29 19:04:57 +0100 | [diff] [blame] | 603 | if (perf_data_file__open(&inject.output)) { |
| 604 | perror("failed to create output file"); |
| 605 | return -1; |
Andrew Vagin | e558a5b | 2012-08-07 16:56:02 +0400 | [diff] [blame] | 606 | } |
| 607 | |
Arnaldo Carvalho de Melo | b7b61cb | 2015-03-03 11:58:45 -0300 | [diff] [blame] | 608 | inject.tool.ordered_events = inject.sched_stat; |
| 609 | |
Namhyung Kim | 1cb8bdc | 2014-08-12 15:40:37 +0900 | [diff] [blame] | 610 | file.path = inject.input_name; |
| 611 | inject.session = perf_session__new(&file, true, &inject.tool); |
| 612 | if (inject.session == NULL) |
Taeung Song | 52e02834 | 2014-09-24 10:33:37 +0900 | [diff] [blame] | 613 | return -1; |
Namhyung Kim | 1cb8bdc | 2014-08-12 15:40:37 +0900 | [diff] [blame] | 614 | |
Namhyung Kim | 0a7e6d1 | 2014-08-12 15:40:45 +0900 | [diff] [blame] | 615 | if (symbol__init(&inject.session->header.env) < 0) |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 616 | return -1; |
| 617 | |
Namhyung Kim | 1cb8bdc | 2014-08-12 15:40:37 +0900 | [diff] [blame] | 618 | ret = __cmd_inject(&inject); |
| 619 | |
| 620 | perf_session__delete(inject.session); |
| 621 | |
| 622 | return ret; |
Tom Zanussi | 454c407 | 2010-05-01 01:41:20 -0500 | [diff] [blame] | 623 | } |