diff options
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r-- | tools/perf/builtin-report.c | 236 |
1 files changed, 130 insertions, 106 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 4d7c8340c32..25d34d483e4 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "util/evsel.h" | 25 | #include "util/evsel.h" |
26 | #include "util/header.h" | 26 | #include "util/header.h" |
27 | #include "util/session.h" | 27 | #include "util/session.h" |
28 | #include "util/tool.h" | ||
28 | 29 | ||
29 | #include "util/parse-options.h" | 30 | #include "util/parse-options.h" |
30 | #include "util/parse-events.h" | 31 | #include "util/parse-events.h" |
@@ -35,38 +36,35 @@ | |||
35 | 36 | ||
36 | #include <linux/bitmap.h> | 37 | #include <linux/bitmap.h> |
37 | 38 | ||
38 | static char const *input_name = "perf.data"; | 39 | struct perf_report { |
39 | 40 | struct perf_tool tool; | |
40 | static bool force, use_tui, use_stdio; | 41 | struct perf_session *session; |
41 | static bool hide_unresolved; | 42 | char const *input_name; |
42 | static bool dont_use_callchains; | 43 | bool force, use_tui, use_stdio; |
43 | static bool show_full_info; | 44 | bool hide_unresolved; |
44 | 45 | bool dont_use_callchains; | |
45 | static bool show_threads; | 46 | bool show_full_info; |
46 | static struct perf_read_values show_threads_values; | 47 | bool show_threads; |
47 | 48 | bool inverted_callchain; | |
48 | static const char default_pretty_printing_style[] = "normal"; | 49 | struct perf_read_values show_threads_values; |
49 | static const char *pretty_printing_style = default_pretty_printing_style; | 50 | const char *pretty_printing_style; |
50 | 51 | symbol_filter_t annotate_init; | |
51 | static char callchain_default_opt[] = "fractal,0.5,callee"; | 52 | const char *cpu_list; |
52 | static bool inverted_callchain; | 53 | DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); |
53 | static symbol_filter_t annotate_init; | 54 | }; |
54 | |||
55 | static const char *cpu_list; | ||
56 | static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); | ||
57 | 55 | ||
58 | static int perf_session__add_hist_entry(struct perf_session *session, | 56 | static int perf_evsel__add_hist_entry(struct perf_evsel *evsel, |
59 | struct addr_location *al, | 57 | struct addr_location *al, |
60 | struct perf_sample *sample, | 58 | struct perf_sample *sample, |
61 | struct perf_evsel *evsel) | 59 | struct machine *machine) |
62 | { | 60 | { |
63 | struct symbol *parent = NULL; | 61 | struct symbol *parent = NULL; |
64 | int err = 0; | 62 | int err = 0; |
65 | struct hist_entry *he; | 63 | struct hist_entry *he; |
66 | 64 | ||
67 | if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) { | 65 | if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) { |
68 | err = perf_session__resolve_callchain(session, al->thread, | 66 | err = machine__resolve_callchain(machine, evsel, al->thread, |
69 | sample->callchain, &parent); | 67 | sample->callchain, &parent); |
70 | if (err) | 68 | if (err) |
71 | return err; | 69 | return err; |
72 | } | 70 | } |
@@ -76,7 +74,8 @@ static int perf_session__add_hist_entry(struct perf_session *session, | |||
76 | return -ENOMEM; | 74 | return -ENOMEM; |
77 | 75 | ||
78 | if (symbol_conf.use_callchain) { | 76 | if (symbol_conf.use_callchain) { |
79 | err = callchain_append(he->callchain, &session->callchain_cursor, | 77 | err = callchain_append(he->callchain, |
78 | &evsel->hists.callchain_cursor, | ||
80 | sample->period); | 79 | sample->period); |
81 | if (err) | 80 | if (err) |
82 | return err; | 81 | return err; |
@@ -92,8 +91,7 @@ static int perf_session__add_hist_entry(struct perf_session *session, | |||
92 | assert(evsel != NULL); | 91 | assert(evsel != NULL); |
93 | 92 | ||
94 | err = -ENOMEM; | 93 | err = -ENOMEM; |
95 | if (notes->src == NULL && | 94 | if (notes->src == NULL && symbol__alloc_hist(he->ms.sym) < 0) |
96 | symbol__alloc_hist(he->ms.sym, session->evlist->nr_entries) < 0) | ||
97 | goto out; | 95 | goto out; |
98 | 96 | ||
99 | err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); | 97 | err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); |
@@ -106,30 +104,32 @@ out: | |||
106 | } | 104 | } |
107 | 105 | ||
108 | 106 | ||
109 | static int process_sample_event(union perf_event *event, | 107 | static int process_sample_event(struct perf_tool *tool, |
108 | union perf_event *event, | ||
110 | struct perf_sample *sample, | 109 | struct perf_sample *sample, |
111 | struct perf_evsel *evsel, | 110 | struct perf_evsel *evsel, |
112 | struct perf_session *session) | 111 | struct machine *machine) |
113 | { | 112 | { |
113 | struct perf_report *rep = container_of(tool, struct perf_report, tool); | ||
114 | struct addr_location al; | 114 | struct addr_location al; |
115 | 115 | ||
116 | if (perf_event__preprocess_sample(event, session, &al, sample, | 116 | if (perf_event__preprocess_sample(event, machine, &al, sample, |
117 | annotate_init) < 0) { | 117 | rep->annotate_init) < 0) { |
118 | fprintf(stderr, "problem processing %d event, skipping it.\n", | 118 | fprintf(stderr, "problem processing %d event, skipping it.\n", |
119 | event->header.type); | 119 | event->header.type); |
120 | return -1; | 120 | return -1; |
121 | } | 121 | } |
122 | 122 | ||
123 | if (al.filtered || (hide_unresolved && al.sym == NULL)) | 123 | if (al.filtered || (rep->hide_unresolved && al.sym == NULL)) |
124 | return 0; | 124 | return 0; |
125 | 125 | ||
126 | if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) | 126 | if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap)) |
127 | return 0; | 127 | return 0; |
128 | 128 | ||
129 | if (al.map != NULL) | 129 | if (al.map != NULL) |
130 | al.map->dso->hit = 1; | 130 | al.map->dso->hit = 1; |
131 | 131 | ||
132 | if (perf_session__add_hist_entry(session, &al, sample, evsel)) { | 132 | if (perf_evsel__add_hist_entry(evsel, &al, sample, machine)) { |
133 | pr_debug("problem incrementing symbol period, skipping event\n"); | 133 | pr_debug("problem incrementing symbol period, skipping event\n"); |
134 | return -1; | 134 | return -1; |
135 | } | 135 | } |
@@ -137,15 +137,17 @@ static int process_sample_event(union perf_event *event, | |||
137 | return 0; | 137 | return 0; |
138 | } | 138 | } |
139 | 139 | ||
140 | static int process_read_event(union perf_event *event, | 140 | static int process_read_event(struct perf_tool *tool, |
141 | union perf_event *event, | ||
141 | struct perf_sample *sample __used, | 142 | struct perf_sample *sample __used, |
142 | struct perf_session *session) | 143 | struct perf_evsel *evsel, |
144 | struct machine *machine __used) | ||
143 | { | 145 | { |
144 | struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, | 146 | struct perf_report *rep = container_of(tool, struct perf_report, tool); |
145 | event->read.id); | 147 | |
146 | if (show_threads) { | 148 | if (rep->show_threads) { |
147 | const char *name = evsel ? event_name(evsel) : "unknown"; | 149 | const char *name = evsel ? event_name(evsel) : "unknown"; |
148 | perf_read_values_add_value(&show_threads_values, | 150 | perf_read_values_add_value(&rep->show_threads_values, |
149 | event->read.pid, event->read.tid, | 151 | event->read.pid, event->read.tid, |
150 | event->read.id, | 152 | event->read.id, |
151 | name, | 153 | name, |
@@ -159,8 +161,10 @@ static int process_read_event(union perf_event *event, | |||
159 | return 0; | 161 | return 0; |
160 | } | 162 | } |
161 | 163 | ||
162 | static int perf_session__setup_sample_type(struct perf_session *self) | 164 | static int perf_report__setup_sample_type(struct perf_report *rep) |
163 | { | 165 | { |
166 | struct perf_session *self = rep->session; | ||
167 | |||
164 | if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) { | 168 | if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) { |
165 | if (sort__has_parent) { | 169 | if (sort__has_parent) { |
166 | ui__warning("Selected --sort parent, but no " | 170 | ui__warning("Selected --sort parent, but no " |
@@ -173,7 +177,8 @@ static int perf_session__setup_sample_type(struct perf_session *self) | |||
173 | "you call 'perf record' without -g?\n"); | 177 | "you call 'perf record' without -g?\n"); |
174 | return -1; | 178 | return -1; |
175 | } | 179 | } |
176 | } else if (!dont_use_callchains && callchain_param.mode != CHAIN_NONE && | 180 | } else if (!rep->dont_use_callchains && |
181 | callchain_param.mode != CHAIN_NONE && | ||
177 | !symbol_conf.use_callchain) { | 182 | !symbol_conf.use_callchain) { |
178 | symbol_conf.use_callchain = true; | 183 | symbol_conf.use_callchain = true; |
179 | if (callchain_register_param(&callchain_param) < 0) { | 184 | if (callchain_register_param(&callchain_param) < 0) { |
@@ -186,22 +191,6 @@ static int perf_session__setup_sample_type(struct perf_session *self) | |||
186 | return 0; | 191 | return 0; |
187 | } | 192 | } |
188 | 193 | ||
189 | static struct perf_event_ops event_ops = { | ||
190 | .sample = process_sample_event, | ||
191 | .mmap = perf_event__process_mmap, | ||
192 | .comm = perf_event__process_comm, | ||
193 | .exit = perf_event__process_task, | ||
194 | .fork = perf_event__process_task, | ||
195 | .lost = perf_event__process_lost, | ||
196 | .read = process_read_event, | ||
197 | .attr = perf_event__process_attr, | ||
198 | .event_type = perf_event__process_event_type, | ||
199 | .tracing_data = perf_event__process_tracing_data, | ||
200 | .build_id = perf_event__process_build_id, | ||
201 | .ordered_samples = true, | ||
202 | .ordering_requires_timestamps = true, | ||
203 | }; | ||
204 | |||
205 | extern volatile int session_done; | 194 | extern volatile int session_done; |
206 | 195 | ||
207 | static void sig_handler(int sig __used) | 196 | static void sig_handler(int sig __used) |
@@ -224,6 +213,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self, | |||
224 | } | 213 | } |
225 | 214 | ||
226 | static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, | 215 | static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, |
216 | struct perf_report *rep, | ||
227 | const char *help) | 217 | const char *help) |
228 | { | 218 | { |
229 | struct perf_evsel *pos; | 219 | struct perf_evsel *pos; |
@@ -241,18 +231,18 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, | |||
241 | parent_pattern == default_parent_pattern) { | 231 | parent_pattern == default_parent_pattern) { |
242 | fprintf(stdout, "#\n# (%s)\n#\n", help); | 232 | fprintf(stdout, "#\n# (%s)\n#\n", help); |
243 | 233 | ||
244 | if (show_threads) { | 234 | if (rep->show_threads) { |
245 | bool style = !strcmp(pretty_printing_style, "raw"); | 235 | bool style = !strcmp(rep->pretty_printing_style, "raw"); |
246 | perf_read_values_display(stdout, &show_threads_values, | 236 | perf_read_values_display(stdout, &rep->show_threads_values, |
247 | style); | 237 | style); |
248 | perf_read_values_destroy(&show_threads_values); | 238 | perf_read_values_destroy(&rep->show_threads_values); |
249 | } | 239 | } |
250 | } | 240 | } |
251 | 241 | ||
252 | return 0; | 242 | return 0; |
253 | } | 243 | } |
254 | 244 | ||
255 | static int __cmd_report(void) | 245 | static int __cmd_report(struct perf_report *rep) |
256 | { | 246 | { |
257 | int ret = -EINVAL; | 247 | int ret = -EINVAL; |
258 | u64 nr_samples; | 248 | u64 nr_samples; |
@@ -264,27 +254,31 @@ static int __cmd_report(void) | |||
264 | 254 | ||
265 | signal(SIGINT, sig_handler); | 255 | signal(SIGINT, sig_handler); |
266 | 256 | ||
267 | session = perf_session__new(input_name, O_RDONLY, force, false, &event_ops); | 257 | session = perf_session__new(rep->input_name, O_RDONLY, |
258 | rep->force, false, &rep->tool); | ||
268 | if (session == NULL) | 259 | if (session == NULL) |
269 | return -ENOMEM; | 260 | return -ENOMEM; |
270 | 261 | ||
271 | if (cpu_list) { | 262 | rep->session = session; |
272 | ret = perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap); | 263 | |
264 | if (rep->cpu_list) { | ||
265 | ret = perf_session__cpu_bitmap(session, rep->cpu_list, | ||
266 | rep->cpu_bitmap); | ||
273 | if (ret) | 267 | if (ret) |
274 | goto out_delete; | 268 | goto out_delete; |
275 | } | 269 | } |
276 | 270 | ||
277 | if (use_browser <= 0) | 271 | if (use_browser <= 0) |
278 | perf_session__fprintf_info(session, stdout, show_full_info); | 272 | perf_session__fprintf_info(session, stdout, rep->show_full_info); |
279 | 273 | ||
280 | if (show_threads) | 274 | if (rep->show_threads) |
281 | perf_read_values_init(&show_threads_values); | 275 | perf_read_values_init(&rep->show_threads_values); |
282 | 276 | ||
283 | ret = perf_session__setup_sample_type(session); | 277 | ret = perf_report__setup_sample_type(rep); |
284 | if (ret) | 278 | if (ret) |
285 | goto out_delete; | 279 | goto out_delete; |
286 | 280 | ||
287 | ret = perf_session__process_events(session, &event_ops); | 281 | ret = perf_session__process_events(session, &rep->tool); |
288 | if (ret) | 282 | if (ret) |
289 | goto out_delete; | 283 | goto out_delete; |
290 | 284 | ||
@@ -327,7 +321,7 @@ static int __cmd_report(void) | |||
327 | } | 321 | } |
328 | 322 | ||
329 | if (nr_samples == 0) { | 323 | if (nr_samples == 0) { |
330 | ui__warning("The %s file has no samples!\n", input_name); | 324 | ui__warning("The %s file has no samples!\n", session->filename); |
331 | goto out_delete; | 325 | goto out_delete; |
332 | } | 326 | } |
333 | 327 | ||
@@ -335,7 +329,7 @@ static int __cmd_report(void) | |||
335 | perf_evlist__tui_browse_hists(session->evlist, help, | 329 | perf_evlist__tui_browse_hists(session->evlist, help, |
336 | NULL, NULL, 0); | 330 | NULL, NULL, 0); |
337 | } else | 331 | } else |
338 | perf_evlist__tty_browse_hists(session->evlist, help); | 332 | perf_evlist__tty_browse_hists(session->evlist, rep, help); |
339 | 333 | ||
340 | out_delete: | 334 | out_delete: |
341 | /* | 335 | /* |
@@ -354,9 +348,9 @@ out_delete: | |||
354 | } | 348 | } |
355 | 349 | ||
356 | static int | 350 | static int |
357 | parse_callchain_opt(const struct option *opt __used, const char *arg, | 351 | parse_callchain_opt(const struct option *opt, const char *arg, int unset) |
358 | int unset) | ||
359 | { | 352 | { |
353 | struct perf_report *rep = (struct perf_report *)opt->value; | ||
360 | char *tok, *tok2; | 354 | char *tok, *tok2; |
361 | char *endptr; | 355 | char *endptr; |
362 | 356 | ||
@@ -364,7 +358,7 @@ parse_callchain_opt(const struct option *opt __used, const char *arg, | |||
364 | * --no-call-graph | 358 | * --no-call-graph |
365 | */ | 359 | */ |
366 | if (unset) { | 360 | if (unset) { |
367 | dont_use_callchains = true; | 361 | rep->dont_use_callchains = true; |
368 | return 0; | 362 | return 0; |
369 | } | 363 | } |
370 | 364 | ||
@@ -412,7 +406,7 @@ parse_callchain_opt(const struct option *opt __used, const char *arg, | |||
412 | goto setup; | 406 | goto setup; |
413 | 407 | ||
414 | if (tok2[0] != 'c') { | 408 | if (tok2[0] != 'c') { |
415 | callchain_param.print_limit = strtod(tok2, &endptr); | 409 | callchain_param.print_limit = strtoul(tok2, &endptr, 0); |
416 | tok2 = strtok(NULL, ","); | 410 | tok2 = strtok(NULL, ","); |
417 | if (!tok2) | 411 | if (!tok2) |
418 | goto setup; | 412 | goto setup; |
@@ -433,13 +427,34 @@ setup: | |||
433 | return 0; | 427 | return 0; |
434 | } | 428 | } |
435 | 429 | ||
436 | static const char * const report_usage[] = { | 430 | int cmd_report(int argc, const char **argv, const char *prefix __used) |
437 | "perf report [<options>] <command>", | 431 | { |
438 | NULL | 432 | struct stat st; |
439 | }; | 433 | char callchain_default_opt[] = "fractal,0.5,callee"; |
440 | 434 | const char * const report_usage[] = { | |
441 | static const struct option options[] = { | 435 | "perf report [<options>]", |
442 | OPT_STRING('i', "input", &input_name, "file", | 436 | NULL |
437 | }; | ||
438 | struct perf_report report = { | ||
439 | .tool = { | ||
440 | .sample = process_sample_event, | ||
441 | .mmap = perf_event__process_mmap, | ||
442 | .comm = perf_event__process_comm, | ||
443 | .exit = perf_event__process_task, | ||
444 | .fork = perf_event__process_task, | ||
445 | .lost = perf_event__process_lost, | ||
446 | .read = process_read_event, | ||
447 | .attr = perf_event__process_attr, | ||
448 | .event_type = perf_event__process_event_type, | ||
449 | .tracing_data = perf_event__process_tracing_data, | ||
450 | .build_id = perf_event__process_build_id, | ||
451 | .ordered_samples = true, | ||
452 | .ordering_requires_timestamps = true, | ||
453 | }, | ||
454 | .pretty_printing_style = "normal", | ||
455 | }; | ||
456 | const struct option options[] = { | ||
457 | OPT_STRING('i', "input", &report.input_name, "file", | ||
443 | "input file name"), | 458 | "input file name"), |
444 | OPT_INCR('v', "verbose", &verbose, | 459 | OPT_INCR('v', "verbose", &verbose, |
445 | "be more verbose (show symbol address, etc)"), | 460 | "be more verbose (show symbol address, etc)"), |
@@ -449,17 +464,18 @@ static const struct option options[] = { | |||
449 | "file", "vmlinux pathname"), | 464 | "file", "vmlinux pathname"), |
450 | OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, | 465 | OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, |
451 | "file", "kallsyms pathname"), | 466 | "file", "kallsyms pathname"), |
452 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | 467 | OPT_BOOLEAN('f', "force", &report.force, "don't complain, do it"), |
453 | OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, | 468 | OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, |
454 | "load module symbols - WARNING: use only with -k and LIVE kernel"), | 469 | "load module symbols - WARNING: use only with -k and LIVE kernel"), |
455 | OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples, | 470 | OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples, |
456 | "Show a column with the number of samples"), | 471 | "Show a column with the number of samples"), |
457 | OPT_BOOLEAN('T', "threads", &show_threads, | 472 | OPT_BOOLEAN('T', "threads", &report.show_threads, |
458 | "Show per-thread event counters"), | 473 | "Show per-thread event counters"), |
459 | OPT_STRING(0, "pretty", &pretty_printing_style, "key", | 474 | OPT_STRING(0, "pretty", &report.pretty_printing_style, "key", |
460 | "pretty printing style key: normal raw"), | 475 | "pretty printing style key: normal raw"), |
461 | OPT_BOOLEAN(0, "tui", &use_tui, "Use the TUI interface"), | 476 | OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"), |
462 | OPT_BOOLEAN(0, "stdio", &use_stdio, "Use the stdio interface"), | 477 | OPT_BOOLEAN(0, "stdio", &report.use_stdio, |
478 | "Use the stdio interface"), | ||
463 | OPT_STRING('s', "sort", &sort_order, "key[,key2...]", | 479 | OPT_STRING('s', "sort", &sort_order, "key[,key2...]", |
464 | "sort by key(s): pid, comm, dso, symbol, parent"), | 480 | "sort by key(s): pid, comm, dso, symbol, parent"), |
465 | OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization, | 481 | OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization, |
@@ -468,13 +484,14 @@ static const struct option options[] = { | |||
468 | "regex filter to identify parent, see: '--sort parent'"), | 484 | "regex filter to identify parent, see: '--sort parent'"), |
469 | OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other, | 485 | OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other, |
470 | "Only display entries with parent-match"), | 486 | "Only display entries with parent-match"), |
471 | OPT_CALLBACK_DEFAULT('g', "call-graph", NULL, "output_type,min_percent, call_order", | 487 | OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order", |
472 | "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold and callchain order. " | 488 | "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit and callchain order. " |
473 | "Default: fractal,0.5,callee", &parse_callchain_opt, callchain_default_opt), | 489 | "Default: fractal,0.5,callee", &parse_callchain_opt, callchain_default_opt), |
474 | OPT_BOOLEAN('G', "inverted", &inverted_callchain, "alias for inverted call graph"), | 490 | OPT_BOOLEAN('G', "inverted", &report.inverted_callchain, |
491 | "alias for inverted call graph"), | ||
475 | OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", | 492 | OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", |
476 | "only consider symbols in these dsos"), | 493 | "only consider symbols in these dsos"), |
477 | OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", | 494 | OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", |
478 | "only consider symbols in these comms"), | 495 | "only consider symbols in these comms"), |
479 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", | 496 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", |
480 | "only consider these symbols"), | 497 | "only consider these symbols"), |
@@ -484,12 +501,13 @@ static const struct option options[] = { | |||
484 | OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator", | 501 | OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator", |
485 | "separator for columns, no spaces will be added between " | 502 | "separator for columns, no spaces will be added between " |
486 | "columns '.' is reserved."), | 503 | "columns '.' is reserved."), |
487 | OPT_BOOLEAN('U', "hide-unresolved", &hide_unresolved, | 504 | OPT_BOOLEAN('U', "hide-unresolved", &report.hide_unresolved, |
488 | "Only display entries resolved to a symbol"), | 505 | "Only display entries resolved to a symbol"), |
489 | OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", | 506 | OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", |
490 | "Look for files with symbols relative to this directory"), | 507 | "Look for files with symbols relative to this directory"), |
491 | OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"), | 508 | OPT_STRING('C', "cpu", &report.cpu_list, "cpu", |
492 | OPT_BOOLEAN('I', "show-info", &show_full_info, | 509 | "list of cpus to profile"), |
510 | OPT_BOOLEAN('I', "show-info", &report.show_full_info, | ||
493 | "Display extended information about perf.data file"), | 511 | "Display extended information about perf.data file"), |
494 | OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src, | 512 | OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src, |
495 | "Interleave source code with assembly code (default)"), | 513 | "Interleave source code with assembly code (default)"), |
@@ -500,24 +518,30 @@ static const struct option options[] = { | |||
500 | OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, | 518 | OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, |
501 | "Show a column with the sum of periods"), | 519 | "Show a column with the sum of periods"), |
502 | OPT_END() | 520 | OPT_END() |
503 | }; | 521 | }; |
504 | 522 | ||
505 | int cmd_report(int argc, const char **argv, const char *prefix __used) | ||
506 | { | ||
507 | argc = parse_options(argc, argv, options, report_usage, 0); | 523 | argc = parse_options(argc, argv, options, report_usage, 0); |
508 | 524 | ||
509 | if (use_stdio) | 525 | if (report.use_stdio) |
510 | use_browser = 0; | 526 | use_browser = 0; |
511 | else if (use_tui) | 527 | else if (report.use_tui) |
512 | use_browser = 1; | 528 | use_browser = 1; |
513 | 529 | ||
514 | if (inverted_callchain) | 530 | if (report.inverted_callchain) |
515 | callchain_param.order = ORDER_CALLER; | 531 | callchain_param.order = ORDER_CALLER; |
516 | 532 | ||
517 | if (strcmp(input_name, "-") != 0) | 533 | if (!report.input_name || !strlen(report.input_name)) { |
534 | if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode)) | ||
535 | report.input_name = "-"; | ||
536 | else | ||
537 | report.input_name = "perf.data"; | ||
538 | } | ||
539 | |||
540 | if (strcmp(report.input_name, "-") != 0) | ||
518 | setup_browser(true); | 541 | setup_browser(true); |
519 | else | 542 | else |
520 | use_browser = 0; | 543 | use_browser = 0; |
544 | |||
521 | /* | 545 | /* |
522 | * Only in the newt browser we are doing integrated annotation, | 546 | * Only in the newt browser we are doing integrated annotation, |
523 | * so don't allocate extra space that won't be used in the stdio | 547 | * so don't allocate extra space that won't be used in the stdio |
@@ -525,7 +549,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used) | |||
525 | */ | 549 | */ |
526 | if (use_browser > 0) { | 550 | if (use_browser > 0) { |
527 | symbol_conf.priv_size = sizeof(struct annotation); | 551 | symbol_conf.priv_size = sizeof(struct annotation); |
528 | annotate_init = symbol__annotate_init; | 552 | report.annotate_init = symbol__annotate_init; |
529 | /* | 553 | /* |
530 | * For searching by name on the "Browse map details". | 554 | * For searching by name on the "Browse map details". |
531 | * providing it only in verbose mode not to bloat too | 555 | * providing it only in verbose mode not to bloat too |
@@ -572,5 +596,5 @@ int cmd_report(int argc, const char **argv, const char *prefix __used) | |||
572 | sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout); | 596 | sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout); |
573 | sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout); | 597 | sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout); |
574 | 598 | ||
575 | return __cmd_report(); | 599 | return __cmd_report(&report); |
576 | } | 600 | } |