Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 1 | #include "builtin.h" |
| 2 | #include "perf.h" |
| 3 | |
Josh Poimboeuf | 4b6ab94 | 2015-12-15 09:39:39 -0600 | [diff] [blame] | 4 | #include <subcmd/parse-options.h> |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 5 | #include "util/trace-event.h" |
| 6 | #include "util/tool.h" |
| 7 | #include "util/session.h" |
Jiri Olsa | f5fc1412 | 2013-10-15 16:27:32 +0200 | [diff] [blame] | 8 | #include "util/data.h" |
Jiri Olsa | acbe613 | 2016-02-15 09:34:34 +0100 | [diff] [blame] | 9 | #include "util/mem-events.h" |
Jiri Olsa | ce1e22b | 2016-02-15 09:34:35 +0100 | [diff] [blame^] | 10 | #include "util/debug.h" |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 11 | |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 12 | #define MEM_OPERATION_LOAD 0x1 |
| 13 | #define MEM_OPERATION_STORE 0x2 |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 14 | |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 15 | struct perf_mem { |
| 16 | struct perf_tool tool; |
| 17 | char const *input_name; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 18 | bool hide_unresolved; |
| 19 | bool dump_raw; |
Yunlong Song | 62a1a63 | 2015-04-02 21:47:15 +0800 | [diff] [blame] | 20 | bool force; |
Arnaldo Carvalho de Melo | 6602412 | 2014-12-17 13:53:27 -0300 | [diff] [blame] | 21 | int operation; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 22 | const char *cpu_list; |
| 23 | DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); |
| 24 | }; |
| 25 | |
Jiri Olsa | ce1e22b | 2016-02-15 09:34:35 +0100 | [diff] [blame^] | 26 | static int parse_record_events(const struct option *opt, |
| 27 | const char *str, int unset __maybe_unused) |
| 28 | { |
| 29 | struct perf_mem *mem = *(struct perf_mem **)opt->value; |
| 30 | int j; |
| 31 | |
| 32 | if (strcmp(str, "list")) { |
| 33 | if (!perf_mem_events__parse(str)) { |
| 34 | mem->operation = 0; |
| 35 | return 0; |
| 36 | } |
| 37 | exit(-1); |
| 38 | } |
| 39 | |
| 40 | for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) { |
| 41 | struct perf_mem_event *e = &perf_mem_events[j]; |
| 42 | |
| 43 | fprintf(stderr, "%-20s%s", |
| 44 | e->tag, verbose ? "" : "\n"); |
| 45 | if (verbose) |
| 46 | fprintf(stderr, " [%s]\n", e->name); |
| 47 | } |
| 48 | exit(0); |
| 49 | } |
| 50 | |
| 51 | static const char * const __usage[] = { |
| 52 | "perf mem record [<options>] [<command>]", |
| 53 | "perf mem record [<options>] -- <command> [<options>]", |
| 54 | NULL |
| 55 | }; |
| 56 | |
| 57 | static const char * const *record_mem_usage = __usage; |
| 58 | |
Arnaldo Carvalho de Melo | 6602412 | 2014-12-17 13:53:27 -0300 | [diff] [blame] | 59 | static int __cmd_record(int argc, const char **argv, struct perf_mem *mem) |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 60 | { |
| 61 | int rec_argc, i = 0, j; |
| 62 | const char **rec_argv; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 63 | int ret; |
Jiri Olsa | ce1e22b | 2016-02-15 09:34:35 +0100 | [diff] [blame^] | 64 | struct option options[] = { |
| 65 | OPT_CALLBACK('e', "event", &mem, "event", |
| 66 | "event selector. use 'perf mem record -e list' to list available events", |
| 67 | parse_record_events), |
| 68 | OPT_INCR('v', "verbose", &verbose, |
| 69 | "be more verbose (show counter open errors, etc)"), |
| 70 | OPT_END() |
| 71 | }; |
| 72 | |
| 73 | argc = parse_options(argc, argv, options, record_mem_usage, |
| 74 | PARSE_OPT_STOP_AT_NON_OPTION); |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 75 | |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 76 | rec_argc = argc + 7; /* max number of arguments */ |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 77 | rec_argv = calloc(rec_argc + 1, sizeof(char *)); |
| 78 | if (!rec_argv) |
| 79 | return -1; |
| 80 | |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 81 | rec_argv[i++] = "record"; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 82 | |
Jiri Olsa | ce1e22b | 2016-02-15 09:34:35 +0100 | [diff] [blame^] | 83 | if (mem->operation & MEM_OPERATION_LOAD) |
Jiri Olsa | acbe613 | 2016-02-15 09:34:34 +0100 | [diff] [blame] | 84 | perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true; |
Jiri Olsa | ce1e22b | 2016-02-15 09:34:35 +0100 | [diff] [blame^] | 85 | |
| 86 | if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record) |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 87 | rec_argv[i++] = "-W"; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 88 | |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 89 | rec_argv[i++] = "-d"; |
| 90 | |
Jiri Olsa | acbe613 | 2016-02-15 09:34:34 +0100 | [diff] [blame] | 91 | for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) { |
| 92 | if (!perf_mem_events[j].record) |
| 93 | continue; |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 94 | |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 95 | rec_argv[i++] = "-e"; |
Jiri Olsa | acbe613 | 2016-02-15 09:34:34 +0100 | [diff] [blame] | 96 | rec_argv[i++] = perf_mem_events[j].name; |
| 97 | }; |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 98 | |
Jiri Olsa | ce1e22b | 2016-02-15 09:34:35 +0100 | [diff] [blame^] | 99 | for (j = 0; j < argc; j++, i++) |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 100 | rec_argv[i] = argv[j]; |
| 101 | |
Jiri Olsa | ce1e22b | 2016-02-15 09:34:35 +0100 | [diff] [blame^] | 102 | if (verbose > 0) { |
| 103 | pr_debug("calling: record "); |
| 104 | |
| 105 | while (rec_argv[j]) { |
| 106 | pr_debug("%s ", rec_argv[j]); |
| 107 | j++; |
| 108 | } |
| 109 | pr_debug("\n"); |
| 110 | } |
| 111 | |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 112 | ret = cmd_record(i, rec_argv, NULL); |
| 113 | free(rec_argv); |
| 114 | return ret; |
| 115 | } |
| 116 | |
| 117 | static int |
| 118 | dump_raw_samples(struct perf_tool *tool, |
| 119 | union perf_event *event, |
| 120 | struct perf_sample *sample, |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 121 | struct machine *machine) |
| 122 | { |
| 123 | struct perf_mem *mem = container_of(tool, struct perf_mem, tool); |
| 124 | struct addr_location al; |
| 125 | const char *fmt; |
| 126 | |
Adrian Hunter | e44baa3 | 2013-08-08 14:32:25 +0300 | [diff] [blame] | 127 | if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) { |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 128 | fprintf(stderr, "problem processing %d event, skipping it.\n", |
| 129 | event->header.type); |
| 130 | return -1; |
| 131 | } |
| 132 | |
| 133 | if (al.filtered || (mem->hide_unresolved && al.sym == NULL)) |
Arnaldo Carvalho de Melo | b91fc39 | 2015-04-06 20:43:22 -0300 | [diff] [blame] | 134 | goto out_put; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 135 | |
| 136 | if (al.map != NULL) |
| 137 | al.map->dso->hit = 1; |
| 138 | |
| 139 | if (symbol_conf.field_sep) { |
| 140 | fmt = "%d%s%d%s0x%"PRIx64"%s0x%"PRIx64"%s%"PRIu64 |
| 141 | "%s0x%"PRIx64"%s%s:%s\n"; |
| 142 | } else { |
| 143 | fmt = "%5d%s%5d%s0x%016"PRIx64"%s0x016%"PRIx64 |
| 144 | "%s%5"PRIu64"%s0x%06"PRIx64"%s%s:%s\n"; |
| 145 | symbol_conf.field_sep = " "; |
| 146 | } |
| 147 | |
| 148 | printf(fmt, |
| 149 | sample->pid, |
| 150 | symbol_conf.field_sep, |
| 151 | sample->tid, |
| 152 | symbol_conf.field_sep, |
Adrian Hunter | ef89325 | 2013-08-27 11:23:06 +0300 | [diff] [blame] | 153 | sample->ip, |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 154 | symbol_conf.field_sep, |
| 155 | sample->addr, |
| 156 | symbol_conf.field_sep, |
| 157 | sample->weight, |
| 158 | symbol_conf.field_sep, |
| 159 | sample->data_src, |
| 160 | symbol_conf.field_sep, |
| 161 | al.map ? (al.map->dso ? al.map->dso->long_name : "???") : "???", |
| 162 | al.sym ? al.sym->name : "???"); |
Arnaldo Carvalho de Melo | b91fc39 | 2015-04-06 20:43:22 -0300 | [diff] [blame] | 163 | out_put: |
| 164 | addr_location__put(&al); |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 165 | return 0; |
| 166 | } |
| 167 | |
| 168 | static int process_sample_event(struct perf_tool *tool, |
| 169 | union perf_event *event, |
| 170 | struct perf_sample *sample, |
Arnaldo Carvalho de Melo | 8b640cc | 2013-12-19 17:00:45 -0300 | [diff] [blame] | 171 | struct perf_evsel *evsel __maybe_unused, |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 172 | struct machine *machine) |
| 173 | { |
Arnaldo Carvalho de Melo | 8b640cc | 2013-12-19 17:00:45 -0300 | [diff] [blame] | 174 | return dump_raw_samples(tool, event, sample, machine); |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | static int report_raw_events(struct perf_mem *mem) |
| 178 | { |
Jiri Olsa | f5fc1412 | 2013-10-15 16:27:32 +0200 | [diff] [blame] | 179 | struct perf_data_file file = { |
| 180 | .path = input_name, |
| 181 | .mode = PERF_DATA_MODE_READ, |
Yunlong Song | 62a1a63 | 2015-04-02 21:47:15 +0800 | [diff] [blame] | 182 | .force = mem->force, |
Jiri Olsa | f5fc1412 | 2013-10-15 16:27:32 +0200 | [diff] [blame] | 183 | }; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 184 | int ret; |
Jiri Olsa | f5fc1412 | 2013-10-15 16:27:32 +0200 | [diff] [blame] | 185 | struct perf_session *session = perf_session__new(&file, false, |
| 186 | &mem->tool); |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 187 | |
| 188 | if (session == NULL) |
Taeung Song | 52e02834 | 2014-09-24 10:33:37 +0900 | [diff] [blame] | 189 | return -1; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 190 | |
| 191 | if (mem->cpu_list) { |
| 192 | ret = perf_session__cpu_bitmap(session, mem->cpu_list, |
| 193 | mem->cpu_bitmap); |
Taeung Song | 1df9fade | 2015-07-01 21:08:19 +0900 | [diff] [blame] | 194 | if (ret < 0) |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 195 | goto out_delete; |
| 196 | } |
| 197 | |
Taeung Song | 1df9fade | 2015-07-01 21:08:19 +0900 | [diff] [blame] | 198 | ret = symbol__init(&session->header.env); |
| 199 | if (ret < 0) |
| 200 | goto out_delete; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 201 | |
| 202 | printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n"); |
| 203 | |
Taeung Song | 1df9fade | 2015-07-01 21:08:19 +0900 | [diff] [blame] | 204 | ret = perf_session__process_events(session); |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 205 | |
| 206 | out_delete: |
| 207 | perf_session__delete(session); |
Taeung Song | 1df9fade | 2015-07-01 21:08:19 +0900 | [diff] [blame] | 208 | return ret; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | static int report_events(int argc, const char **argv, struct perf_mem *mem) |
| 212 | { |
| 213 | const char **rep_argv; |
| 214 | int ret, i = 0, j, rep_argc; |
| 215 | |
| 216 | if (mem->dump_raw) |
| 217 | return report_raw_events(mem); |
| 218 | |
| 219 | rep_argc = argc + 3; |
| 220 | rep_argv = calloc(rep_argc + 1, sizeof(char *)); |
| 221 | if (!rep_argv) |
| 222 | return -1; |
| 223 | |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 224 | rep_argv[i++] = "report"; |
| 225 | rep_argv[i++] = "--mem-mode"; |
| 226 | rep_argv[i++] = "-n"; /* display number of samples */ |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 227 | |
| 228 | /* |
| 229 | * there is no weight (cost) associated with stores, so don't print |
| 230 | * the column |
| 231 | */ |
Arnaldo Carvalho de Melo | 6602412 | 2014-12-17 13:53:27 -0300 | [diff] [blame] | 232 | if (!(mem->operation & MEM_OPERATION_LOAD)) |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 233 | rep_argv[i++] = "--sort=mem,sym,dso,symbol_daddr," |
| 234 | "dso_daddr,tlb,locked"; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 235 | |
| 236 | for (j = 1; j < argc; j++, i++) |
| 237 | rep_argv[i] = argv[j]; |
| 238 | |
| 239 | ret = cmd_report(i, rep_argv, NULL); |
| 240 | free(rep_argv); |
| 241 | return ret; |
| 242 | } |
| 243 | |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 244 | struct mem_mode { |
| 245 | const char *name; |
| 246 | int mode; |
| 247 | }; |
| 248 | |
| 249 | #define MEM_OPT(n, m) \ |
| 250 | { .name = n, .mode = (m) } |
| 251 | |
| 252 | #define MEM_END { .name = NULL } |
| 253 | |
| 254 | static const struct mem_mode mem_modes[]={ |
| 255 | MEM_OPT("load", MEM_OPERATION_LOAD), |
| 256 | MEM_OPT("store", MEM_OPERATION_STORE), |
| 257 | MEM_END |
| 258 | }; |
| 259 | |
| 260 | static int |
| 261 | parse_mem_ops(const struct option *opt, const char *str, int unset) |
| 262 | { |
| 263 | int *mode = (int *)opt->value; |
| 264 | const struct mem_mode *m; |
| 265 | char *s, *os = NULL, *p; |
| 266 | int ret = -1; |
| 267 | |
| 268 | if (unset) |
| 269 | return 0; |
| 270 | |
| 271 | /* str may be NULL in case no arg is passed to -t */ |
| 272 | if (str) { |
| 273 | /* because str is read-only */ |
| 274 | s = os = strdup(str); |
| 275 | if (!s) |
| 276 | return -1; |
| 277 | |
| 278 | /* reset mode */ |
| 279 | *mode = 0; |
| 280 | |
| 281 | for (;;) { |
| 282 | p = strchr(s, ','); |
| 283 | if (p) |
| 284 | *p = '\0'; |
| 285 | |
| 286 | for (m = mem_modes; m->name; m++) { |
| 287 | if (!strcasecmp(s, m->name)) |
| 288 | break; |
| 289 | } |
| 290 | if (!m->name) { |
| 291 | fprintf(stderr, "unknown sampling op %s," |
| 292 | " check man page\n", s); |
| 293 | goto error; |
| 294 | } |
| 295 | |
| 296 | *mode |= m->mode; |
| 297 | |
| 298 | if (!p) |
| 299 | break; |
| 300 | |
| 301 | s = p + 1; |
| 302 | } |
| 303 | } |
| 304 | ret = 0; |
| 305 | |
| 306 | if (*mode == 0) |
| 307 | *mode = MEM_OPERATION_LOAD; |
| 308 | error: |
| 309 | free(os); |
| 310 | return ret; |
| 311 | } |
| 312 | |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 313 | int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused) |
| 314 | { |
| 315 | struct stat st; |
| 316 | struct perf_mem mem = { |
| 317 | .tool = { |
| 318 | .sample = process_sample_event, |
| 319 | .mmap = perf_event__process_mmap, |
Stephane Eranian | 5c5e854 | 2013-08-21 12:10:25 +0200 | [diff] [blame] | 320 | .mmap2 = perf_event__process_mmap2, |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 321 | .comm = perf_event__process_comm, |
| 322 | .lost = perf_event__process_lost, |
| 323 | .fork = perf_event__process_fork, |
| 324 | .build_id = perf_event__process_build_id, |
Jiri Olsa | 0a8cb85 | 2014-07-06 14:18:21 +0200 | [diff] [blame] | 325 | .ordered_events = true, |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 326 | }, |
| 327 | .input_name = "perf.data", |
Arnaldo Carvalho de Melo | 6602412 | 2014-12-17 13:53:27 -0300 | [diff] [blame] | 328 | /* |
| 329 | * default to both load an store sampling |
| 330 | */ |
| 331 | .operation = MEM_OPERATION_LOAD | MEM_OPERATION_STORE, |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 332 | }; |
| 333 | const struct option mem_options[] = { |
Arnaldo Carvalho de Melo | 6602412 | 2014-12-17 13:53:27 -0300 | [diff] [blame] | 334 | OPT_CALLBACK('t', "type", &mem.operation, |
Stephane Eranian | 67121f8 | 2014-12-17 16:23:55 +0100 | [diff] [blame] | 335 | "type", "memory operations(load,store) Default load,store", |
| 336 | parse_mem_ops), |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 337 | OPT_BOOLEAN('D', "dump-raw-samples", &mem.dump_raw, |
| 338 | "dump raw samples in ASCII"), |
| 339 | OPT_BOOLEAN('U', "hide-unresolved", &mem.hide_unresolved, |
| 340 | "Only display entries resolved to a symbol"), |
| 341 | OPT_STRING('i', "input", &input_name, "file", |
| 342 | "input file name"), |
| 343 | OPT_STRING('C', "cpu", &mem.cpu_list, "cpu", |
| 344 | "list of cpus to profile"), |
Wang Nan | 8b8ca6e | 2015-03-20 02:57:52 +0000 | [diff] [blame] | 345 | OPT_STRING_NOEMPTY('x', "field-separator", &symbol_conf.field_sep, |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 346 | "separator", |
| 347 | "separator for columns, no spaces will be added" |
| 348 | " between columns '.' is reserved."), |
Yunlong Song | 62a1a63 | 2015-04-02 21:47:15 +0800 | [diff] [blame] | 349 | OPT_BOOLEAN('f', "force", &mem.force, "don't complain, do it"), |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 350 | OPT_END() |
| 351 | }; |
Ramkumar Ramachandra | 8d2a2a1 | 2014-03-14 23:17:52 -0400 | [diff] [blame] | 352 | const char *const mem_subcommands[] = { "record", "report", NULL }; |
| 353 | const char *mem_usage[] = { |
| 354 | NULL, |
| 355 | NULL |
| 356 | }; |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 357 | |
Ramkumar Ramachandra | 8d2a2a1 | 2014-03-14 23:17:52 -0400 | [diff] [blame] | 358 | argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands, |
| 359 | mem_usage, PARSE_OPT_STOP_AT_NON_OPTION); |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 360 | |
Arnaldo Carvalho de Melo | 6602412 | 2014-12-17 13:53:27 -0300 | [diff] [blame] | 361 | if (!argc || !(strncmp(argv[0], "rec", 3) || mem.operation)) |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 362 | usage_with_options(mem_usage, mem_options); |
| 363 | |
| 364 | if (!mem.input_name || !strlen(mem.input_name)) { |
| 365 | if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode)) |
| 366 | mem.input_name = "-"; |
| 367 | else |
| 368 | mem.input_name = "perf.data"; |
| 369 | } |
| 370 | |
| 371 | if (!strncmp(argv[0], "rec", 3)) |
Arnaldo Carvalho de Melo | 6602412 | 2014-12-17 13:53:27 -0300 | [diff] [blame] | 372 | return __cmd_record(argc, argv, &mem); |
Stephane Eranian | 028f12e | 2013-01-24 16:10:38 +0100 | [diff] [blame] | 373 | else if (!strncmp(argv[0], "rep", 3)) |
| 374 | return report_events(argc, argv, &mem); |
| 375 | else |
| 376 | usage_with_options(mem_usage, mem_options); |
| 377 | |
| 378 | return 0; |
| 379 | } |