aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-11-17 09:19:04 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-11-28 07:38:26 -0500
commitfa372aae335c6dfbe808d5a728fe10cd202dde45 (patch)
treea7df295553134ab719ac4ae1680b9e1d3d593b8c /tools/perf
parente3f42609628a20da92ecbc2d81053cc82c90a071 (diff)
perf report: Group options in a struct
Paving the way to remove these globals when we change the perf_event_ops to receive as a first parameter a pointer to a perf_event_ops that will then provide access to perf_report via container_of. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-2eh2vi2nb5z3tg1lvoxv09xu@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-report.c111
1 files changed, 59 insertions, 52 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index b7ab373b9acc..5d2e819dfc40 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -35,25 +35,25 @@
35 35
36#include <linux/bitmap.h> 36#include <linux/bitmap.h>
37 37
38static char const *input_name = "perf.data"; 38static struct perf_report {
39 39 char const *input_name;
40static bool force, use_tui, use_stdio; 40 bool force, use_tui, use_stdio;
41static bool hide_unresolved; 41 bool hide_unresolved;
42static bool dont_use_callchains; 42 bool dont_use_callchains;
43static bool show_full_info; 43 bool show_full_info;
44 44 bool show_threads;
45static bool show_threads; 45 bool inverted_callchain;
46static struct perf_read_values show_threads_values; 46 struct perf_read_values show_threads_values;
47 47 const char *pretty_printing_style;
48static const char default_pretty_printing_style[] = "normal"; 48 symbol_filter_t annotate_init;
49static const char *pretty_printing_style = default_pretty_printing_style; 49 const char *cpu_list;
50 50 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
51static char callchain_default_opt[] = "fractal,0.5,callee"; 51} report = {
52static bool inverted_callchain; 52 .input_name = "perf.data",
53static symbol_filter_t annotate_init; 53 .pretty_printing_style = "normal",
54 54}, *rep = &report;
55static const char *cpu_list; 55
56static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); 56static char callchain_default_opt[] = "fractal,0.5,callee";
57 57
58static int perf_session__add_hist_entry(struct perf_session *session, 58static int perf_session__add_hist_entry(struct perf_session *session,
59 struct addr_location *al, 59 struct addr_location *al,
@@ -114,16 +114,16 @@ static int process_sample_event(union perf_event *event,
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, session, &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)
@@ -143,9 +143,9 @@ static int process_read_event(union perf_event *event,
143{ 143{
144 struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, 144 struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist,
145 event->read.id); 145 event->read.id);
146 if (show_threads) { 146 if (rep->show_threads) {
147 const char *name = evsel ? event_name(evsel) : "unknown"; 147 const char *name = evsel ? event_name(evsel) : "unknown";
148 perf_read_values_add_value(&show_threads_values, 148 perf_read_values_add_value(&rep->show_threads_values,
149 event->read.pid, event->read.tid, 149 event->read.pid, event->read.tid,
150 event->read.id, 150 event->read.id,
151 name, 151 name,
@@ -173,7 +173,8 @@ static int perf_session__setup_sample_type(struct perf_session *self)
173 "you call 'perf record' without -g?\n"); 173 "you call 'perf record' without -g?\n");
174 return -1; 174 return -1;
175 } 175 }
176 } else if (!dont_use_callchains && callchain_param.mode != CHAIN_NONE && 176 } else if (!rep->dont_use_callchains &&
177 callchain_param.mode != CHAIN_NONE &&
177 !symbol_conf.use_callchain) { 178 !symbol_conf.use_callchain) {
178 symbol_conf.use_callchain = true; 179 symbol_conf.use_callchain = true;
179 if (callchain_register_param(&callchain_param) < 0) { 180 if (callchain_register_param(&callchain_param) < 0) {
@@ -241,11 +242,11 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
241 parent_pattern == default_parent_pattern) { 242 parent_pattern == default_parent_pattern) {
242 fprintf(stdout, "#\n# (%s)\n#\n", help); 243 fprintf(stdout, "#\n# (%s)\n#\n", help);
243 244
244 if (show_threads) { 245 if (rep->show_threads) {
245 bool style = !strcmp(pretty_printing_style, "raw"); 246 bool style = !strcmp(rep->pretty_printing_style, "raw");
246 perf_read_values_display(stdout, &show_threads_values, 247 perf_read_values_display(stdout, &rep->show_threads_values,
247 style); 248 style);
248 perf_read_values_destroy(&show_threads_values); 249 perf_read_values_destroy(&rep->show_threads_values);
249 } 250 }
250 } 251 }
251 252
@@ -264,21 +265,23 @@ static int __cmd_report(void)
264 265
265 signal(SIGINT, sig_handler); 266 signal(SIGINT, sig_handler);
266 267
267 session = perf_session__new(input_name, O_RDONLY, force, false, &event_ops); 268 session = perf_session__new(rep->input_name, O_RDONLY,
269 rep->force, false, &event_ops);
268 if (session == NULL) 270 if (session == NULL)
269 return -ENOMEM; 271 return -ENOMEM;
270 272
271 if (cpu_list) { 273 if (rep->cpu_list) {
272 ret = perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap); 274 ret = perf_session__cpu_bitmap(session, rep->cpu_list,
275 rep->cpu_bitmap);
273 if (ret) 276 if (ret)
274 goto out_delete; 277 goto out_delete;
275 } 278 }
276 279
277 if (use_browser <= 0) 280 if (use_browser <= 0)
278 perf_session__fprintf_info(session, stdout, show_full_info); 281 perf_session__fprintf_info(session, stdout, rep->show_full_info);
279 282
280 if (show_threads) 283 if (rep->show_threads)
281 perf_read_values_init(&show_threads_values); 284 perf_read_values_init(&rep->show_threads_values);
282 285
283 ret = perf_session__setup_sample_type(session); 286 ret = perf_session__setup_sample_type(session);
284 if (ret) 287 if (ret)
@@ -327,7 +330,8 @@ static int __cmd_report(void)
327 } 330 }
328 331
329 if (nr_samples == 0) { 332 if (nr_samples == 0) {
330 ui__warning("The %s file has no samples!\n", input_name); 333 ui__warning("The %s file has no samples!\n",
334 rep->input_name);
331 goto out_delete; 335 goto out_delete;
332 } 336 }
333 337
@@ -364,7 +368,7 @@ parse_callchain_opt(const struct option *opt __used, const char *arg,
364 * --no-call-graph 368 * --no-call-graph
365 */ 369 */
366 if (unset) { 370 if (unset) {
367 dont_use_callchains = true; 371 rep->dont_use_callchains = true;
368 return 0; 372 return 0;
369 } 373 }
370 374
@@ -439,7 +443,7 @@ static const char * const report_usage[] = {
439}; 443};
440 444
441static const struct option options[] = { 445static const struct option options[] = {
442 OPT_STRING('i', "input", &input_name, "file", 446 OPT_STRING('i', "input", &report.input_name, "file",
443 "input file name"), 447 "input file name"),
444 OPT_INCR('v', "verbose", &verbose, 448 OPT_INCR('v', "verbose", &verbose,
445 "be more verbose (show symbol address, etc)"), 449 "be more verbose (show symbol address, etc)"),
@@ -449,17 +453,18 @@ static const struct option options[] = {
449 "file", "vmlinux pathname"), 453 "file", "vmlinux pathname"),
450 OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, 454 OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
451 "file", "kallsyms pathname"), 455 "file", "kallsyms pathname"),
452 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), 456 OPT_BOOLEAN('f', "force", &report.force, "don't complain, do it"),
453 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, 457 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
454 "load module symbols - WARNING: use only with -k and LIVE kernel"), 458 "load module symbols - WARNING: use only with -k and LIVE kernel"),
455 OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples, 459 OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
456 "Show a column with the number of samples"), 460 "Show a column with the number of samples"),
457 OPT_BOOLEAN('T', "threads", &show_threads, 461 OPT_BOOLEAN('T', "threads", &report.show_threads,
458 "Show per-thread event counters"), 462 "Show per-thread event counters"),
459 OPT_STRING(0, "pretty", &pretty_printing_style, "key", 463 OPT_STRING(0, "pretty", &report.pretty_printing_style, "key",
460 "pretty printing style key: normal raw"), 464 "pretty printing style key: normal raw"),
461 OPT_BOOLEAN(0, "tui", &use_tui, "Use the TUI interface"), 465 OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"),
462 OPT_BOOLEAN(0, "stdio", &use_stdio, "Use the stdio interface"), 466 OPT_BOOLEAN(0, "stdio", &report.use_stdio,
467 "Use the stdio interface"),
463 OPT_STRING('s', "sort", &sort_order, "key[,key2...]", 468 OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
464 "sort by key(s): pid, comm, dso, symbol, parent"), 469 "sort by key(s): pid, comm, dso, symbol, parent"),
465 OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization, 470 OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
@@ -471,7 +476,8 @@ static const struct option options[] = {
471 OPT_CALLBACK_DEFAULT('g', "call-graph", NULL, "output_type,min_percent, call_order", 476 OPT_CALLBACK_DEFAULT('g', "call-graph", NULL, "output_type,min_percent, call_order",
472 "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold and callchain order. " 477 "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold and callchain order. "
473 "Default: fractal,0.5,callee", &parse_callchain_opt, callchain_default_opt), 478 "Default: fractal,0.5,callee", &parse_callchain_opt, callchain_default_opt),
474 OPT_BOOLEAN('G', "inverted", &inverted_callchain, "alias for inverted call graph"), 479 OPT_BOOLEAN('G', "inverted", &report.inverted_callchain,
480 "alias for inverted call graph"),
475 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", 481 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
476 "only consider symbols in these dsos"), 482 "only consider symbols in these dsos"),
477 OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", 483 OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
@@ -484,12 +490,13 @@ static const struct option options[] = {
484 OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator", 490 OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
485 "separator for columns, no spaces will be added between " 491 "separator for columns, no spaces will be added between "
486 "columns '.' is reserved."), 492 "columns '.' is reserved."),
487 OPT_BOOLEAN('U', "hide-unresolved", &hide_unresolved, 493 OPT_BOOLEAN('U', "hide-unresolved", &report.hide_unresolved,
488 "Only display entries resolved to a symbol"), 494 "Only display entries resolved to a symbol"),
489 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", 495 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
490 "Look for files with symbols relative to this directory"), 496 "Look for files with symbols relative to this directory"),
491 OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"), 497 OPT_STRING('c', "cpu", &report.cpu_list, "cpu",
492 OPT_BOOLEAN('I', "show-info", &show_full_info, 498 "list of cpus to profile"),
499 OPT_BOOLEAN('I', "show-info", &report.show_full_info,
493 "Display extended information about perf.data file"), 500 "Display extended information about perf.data file"),
494 OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src, 501 OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src,
495 "Interleave source code with assembly code (default)"), 502 "Interleave source code with assembly code (default)"),
@@ -506,15 +513,15 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
506{ 513{
507 argc = parse_options(argc, argv, options, report_usage, 0); 514 argc = parse_options(argc, argv, options, report_usage, 0);
508 515
509 if (use_stdio) 516 if (report.use_stdio)
510 use_browser = 0; 517 use_browser = 0;
511 else if (use_tui) 518 else if (report.use_tui)
512 use_browser = 1; 519 use_browser = 1;
513 520
514 if (inverted_callchain) 521 if (report.inverted_callchain)
515 callchain_param.order = ORDER_CALLER; 522 callchain_param.order = ORDER_CALLER;
516 523
517 if (strcmp(input_name, "-") != 0) 524 if (strcmp(report.input_name, "-") != 0)
518 setup_browser(true); 525 setup_browser(true);
519 else 526 else
520 use_browser = 0; 527 use_browser = 0;
@@ -525,7 +532,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
525 */ 532 */
526 if (use_browser > 0) { 533 if (use_browser > 0) {
527 symbol_conf.priv_size = sizeof(struct annotation); 534 symbol_conf.priv_size = sizeof(struct annotation);
528 annotate_init = symbol__annotate_init; 535 report.annotate_init = symbol__annotate_init;
529 /* 536 /*
530 * For searching by name on the "Browse map details". 537 * For searching by name on the "Browse map details".
531 * providing it only in verbose mode not to bloat too 538 * providing it only in verbose mode not to bloat too