diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-19 12:53:53 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-19 14:19:01 -0500 |
commit | 28b21393fa0472501b5a2a85a0b008b4e3dc154c (patch) | |
tree | 5604a60277c05a4619c20ad952e1e3cc1ff2d356 /tools/perf/builtin-report.c | |
parent | 4c7aafc950178cd78f8cbda916ee8208afe039b5 (diff) |
perf report: Rename 'perf_report' to 'report'
Reduce typing, functions use class__method convention, so unlikely to
clash with other libraries.
This actually was discussed in the "Link:" referenced message below.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20131112113427.GA4053@ghostprotocols.net
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r-- | tools/perf/builtin-report.c | 73 |
1 files changed, 31 insertions, 42 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 8424053b399a..da156a44cb15 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <dlfcn.h> | 39 | #include <dlfcn.h> |
40 | #include <linux/bitmap.h> | 40 | #include <linux/bitmap.h> |
41 | 41 | ||
42 | struct perf_report { | 42 | struct report { |
43 | struct perf_tool tool; | 43 | struct perf_tool tool; |
44 | struct perf_session *session; | 44 | struct perf_session *session; |
45 | bool force, use_tui, use_gtk, use_stdio; | 45 | bool force, use_tui, use_gtk, use_stdio; |
@@ -60,14 +60,14 @@ struct perf_report { | |||
60 | DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); | 60 | DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static int perf_report_config(const char *var, const char *value, void *cb) | 63 | static int report__config(const char *var, const char *value, void *cb) |
64 | { | 64 | { |
65 | if (!strcmp(var, "report.group")) { | 65 | if (!strcmp(var, "report.group")) { |
66 | symbol_conf.event_group = perf_config_bool(var, value); | 66 | symbol_conf.event_group = perf_config_bool(var, value); |
67 | return 0; | 67 | return 0; |
68 | } | 68 | } |
69 | if (!strcmp(var, "report.percent-limit")) { | 69 | if (!strcmp(var, "report.percent-limit")) { |
70 | struct perf_report *rep = cb; | 70 | struct report *rep = cb; |
71 | rep->min_percent = strtof(value, NULL); | 71 | rep->min_percent = strtof(value, NULL); |
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
@@ -75,7 +75,7 @@ static int perf_report_config(const char *var, const char *value, void *cb) | |||
75 | return perf_default_config(var, value, cb); | 75 | return perf_default_config(var, value, cb); |
76 | } | 76 | } |
77 | 77 | ||
78 | static int report__resolve_callchain(struct perf_report *rep, struct symbol **parent, | 78 | static int report__resolve_callchain(struct report *rep, struct symbol **parent, |
79 | struct perf_evsel *evsel, struct addr_location *al, | 79 | struct perf_evsel *evsel, struct addr_location *al, |
80 | struct perf_sample *sample, struct machine *machine) | 80 | struct perf_sample *sample, struct machine *machine) |
81 | { | 81 | { |
@@ -93,14 +93,11 @@ static int hist_entry__append_callchain(struct hist_entry *he, struct perf_sampl | |||
93 | return callchain_append(he->callchain, &callchain_cursor, sample->period); | 93 | return callchain_append(he->callchain, &callchain_cursor, sample->period); |
94 | } | 94 | } |
95 | 95 | ||
96 | static int perf_report__add_mem_hist_entry(struct perf_tool *tool, | 96 | static int report__add_mem_hist_entry(struct perf_tool *tool, struct addr_location *al, |
97 | struct addr_location *al, | 97 | struct perf_sample *sample, struct perf_evsel *evsel, |
98 | struct perf_sample *sample, | 98 | struct machine *machine, union perf_event *event) |
99 | struct perf_evsel *evsel, | ||
100 | struct machine *machine, | ||
101 | union perf_event *event) | ||
102 | { | 99 | { |
103 | struct perf_report *rep = container_of(tool, struct perf_report, tool); | 100 | struct report *rep = container_of(tool, struct report, tool); |
104 | struct symbol *parent = NULL; | 101 | struct symbol *parent = NULL; |
105 | u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 102 | u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
106 | struct hist_entry *he; | 103 | struct hist_entry *he; |
@@ -150,13 +147,11 @@ out: | |||
150 | return err; | 147 | return err; |
151 | } | 148 | } |
152 | 149 | ||
153 | static int perf_report__add_branch_hist_entry(struct perf_tool *tool, | 150 | static int report__add_branch_hist_entry(struct perf_tool *tool, struct addr_location *al, |
154 | struct addr_location *al, | 151 | struct perf_sample *sample, struct perf_evsel *evsel, |
155 | struct perf_sample *sample, | 152 | struct machine *machine) |
156 | struct perf_evsel *evsel, | ||
157 | struct machine *machine) | ||
158 | { | 153 | { |
159 | struct perf_report *rep = container_of(tool, struct perf_report, tool); | 154 | struct report *rep = container_of(tool, struct report, tool); |
160 | struct symbol *parent = NULL; | 155 | struct symbol *parent = NULL; |
161 | unsigned i; | 156 | unsigned i; |
162 | struct hist_entry *he; | 157 | struct hist_entry *he; |
@@ -208,13 +203,11 @@ out: | |||
208 | return err; | 203 | return err; |
209 | } | 204 | } |
210 | 205 | ||
211 | static int perf_evsel__add_hist_entry(struct perf_tool *tool, | 206 | static int report__add_hist_entry(struct perf_tool *tool, struct perf_evsel *evsel, |
212 | struct perf_evsel *evsel, | 207 | struct addr_location *al, struct perf_sample *sample, |
213 | struct addr_location *al, | 208 | struct machine *machine) |
214 | struct perf_sample *sample, | ||
215 | struct machine *machine) | ||
216 | { | 209 | { |
217 | struct perf_report *rep = container_of(tool, struct perf_report, tool); | 210 | struct report *rep = container_of(tool, struct report, tool); |
218 | struct symbol *parent = NULL; | 211 | struct symbol *parent = NULL; |
219 | struct hist_entry *he; | 212 | struct hist_entry *he; |
220 | int err = report__resolve_callchain(rep, &parent, evsel, al, sample, machine); | 213 | int err = report__resolve_callchain(rep, &parent, evsel, al, sample, machine); |
@@ -246,7 +239,7 @@ static int process_sample_event(struct perf_tool *tool, | |||
246 | struct perf_evsel *evsel, | 239 | struct perf_evsel *evsel, |
247 | struct machine *machine) | 240 | struct machine *machine) |
248 | { | 241 | { |
249 | struct perf_report *rep = container_of(tool, struct perf_report, tool); | 242 | struct report *rep = container_of(tool, struct report, tool); |
250 | struct addr_location al; | 243 | struct addr_location al; |
251 | int ret; | 244 | int ret; |
252 | 245 | ||
@@ -263,21 +256,18 @@ static int process_sample_event(struct perf_tool *tool, | |||
263 | return 0; | 256 | return 0; |
264 | 257 | ||
265 | if (sort__mode == SORT_MODE__BRANCH) { | 258 | if (sort__mode == SORT_MODE__BRANCH) { |
266 | ret = perf_report__add_branch_hist_entry(tool, &al, sample, | 259 | ret = report__add_branch_hist_entry(tool, &al, sample, evsel, machine); |
267 | evsel, machine); | ||
268 | if (ret < 0) | 260 | if (ret < 0) |
269 | pr_debug("problem adding lbr entry, skipping event\n"); | 261 | pr_debug("problem adding lbr entry, skipping event\n"); |
270 | } else if (rep->mem_mode == 1) { | 262 | } else if (rep->mem_mode == 1) { |
271 | ret = perf_report__add_mem_hist_entry(tool, &al, sample, | 263 | ret = report__add_mem_hist_entry(tool, &al, sample, evsel, machine, event); |
272 | evsel, machine, event); | ||
273 | if (ret < 0) | 264 | if (ret < 0) |
274 | pr_debug("problem adding mem entry, skipping event\n"); | 265 | pr_debug("problem adding mem entry, skipping event\n"); |
275 | } else { | 266 | } else { |
276 | if (al.map != NULL) | 267 | if (al.map != NULL) |
277 | al.map->dso->hit = 1; | 268 | al.map->dso->hit = 1; |
278 | 269 | ||
279 | ret = perf_evsel__add_hist_entry(tool, evsel, &al, sample, | 270 | ret = report__add_hist_entry(tool, evsel, &al, sample, machine); |
280 | machine); | ||
281 | if (ret < 0) | 271 | if (ret < 0) |
282 | pr_debug("problem incrementing symbol period, skipping event\n"); | 272 | pr_debug("problem incrementing symbol period, skipping event\n"); |
283 | } | 273 | } |
@@ -290,7 +280,7 @@ static int process_read_event(struct perf_tool *tool, | |||
290 | struct perf_evsel *evsel, | 280 | struct perf_evsel *evsel, |
291 | struct machine *machine __maybe_unused) | 281 | struct machine *machine __maybe_unused) |
292 | { | 282 | { |
293 | struct perf_report *rep = container_of(tool, struct perf_report, tool); | 283 | struct report *rep = container_of(tool, struct report, tool); |
294 | 284 | ||
295 | if (rep->show_threads) { | 285 | if (rep->show_threads) { |
296 | const char *name = evsel ? perf_evsel__name(evsel) : "unknown"; | 286 | const char *name = evsel ? perf_evsel__name(evsel) : "unknown"; |
@@ -309,7 +299,7 @@ static int process_read_event(struct perf_tool *tool, | |||
309 | } | 299 | } |
310 | 300 | ||
311 | /* For pipe mode, sample_type is not currently set */ | 301 | /* For pipe mode, sample_type is not currently set */ |
312 | static int perf_report__setup_sample_type(struct perf_report *rep) | 302 | static int report__setup_sample_type(struct report *rep) |
313 | { | 303 | { |
314 | struct perf_session *session = rep->session; | 304 | struct perf_session *session = rep->session; |
315 | u64 sample_type = perf_evlist__combined_sample_type(session->evlist); | 305 | u64 sample_type = perf_evlist__combined_sample_type(session->evlist); |
@@ -354,8 +344,7 @@ static void sig_handler(int sig __maybe_unused) | |||
354 | session_done = 1; | 344 | session_done = 1; |
355 | } | 345 | } |
356 | 346 | ||
357 | static size_t hists__fprintf_nr_sample_events(struct perf_report *rep, | 347 | static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report *rep, |
358 | struct hists *hists, | ||
359 | const char *evname, FILE *fp) | 348 | const char *evname, FILE *fp) |
360 | { | 349 | { |
361 | size_t ret; | 350 | size_t ret; |
@@ -392,7 +381,7 @@ static size_t hists__fprintf_nr_sample_events(struct perf_report *rep, | |||
392 | } | 381 | } |
393 | 382 | ||
394 | static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, | 383 | static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, |
395 | struct perf_report *rep, | 384 | struct report *rep, |
396 | const char *help) | 385 | const char *help) |
397 | { | 386 | { |
398 | struct perf_evsel *pos; | 387 | struct perf_evsel *pos; |
@@ -405,7 +394,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, | |||
405 | !perf_evsel__is_group_leader(pos)) | 394 | !perf_evsel__is_group_leader(pos)) |
406 | continue; | 395 | continue; |
407 | 396 | ||
408 | hists__fprintf_nr_sample_events(rep, hists, evname, stdout); | 397 | hists__fprintf_nr_sample_events(hists, rep, evname, stdout); |
409 | hists__fprintf(hists, true, 0, 0, rep->min_percent, stdout); | 398 | hists__fprintf(hists, true, 0, 0, rep->min_percent, stdout); |
410 | fprintf(stdout, "\n\n"); | 399 | fprintf(stdout, "\n\n"); |
411 | } | 400 | } |
@@ -425,7 +414,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, | |||
425 | return 0; | 414 | return 0; |
426 | } | 415 | } |
427 | 416 | ||
428 | static int __cmd_report(struct perf_report *rep) | 417 | static int __cmd_report(struct report *rep) |
429 | { | 418 | { |
430 | int ret = -EINVAL; | 419 | int ret = -EINVAL; |
431 | u64 nr_samples; | 420 | u64 nr_samples; |
@@ -449,7 +438,7 @@ static int __cmd_report(struct perf_report *rep) | |||
449 | if (rep->show_threads) | 438 | if (rep->show_threads) |
450 | perf_read_values_init(&rep->show_threads_values); | 439 | perf_read_values_init(&rep->show_threads_values); |
451 | 440 | ||
452 | ret = perf_report__setup_sample_type(rep); | 441 | ret = report__setup_sample_type(rep); |
453 | if (ret) | 442 | if (ret) |
454 | return ret; | 443 | return ret; |
455 | 444 | ||
@@ -568,7 +557,7 @@ static int __cmd_report(struct perf_report *rep) | |||
568 | static int | 557 | static int |
569 | parse_callchain_opt(const struct option *opt, const char *arg, int unset) | 558 | parse_callchain_opt(const struct option *opt, const char *arg, int unset) |
570 | { | 559 | { |
571 | struct perf_report *rep = (struct perf_report *)opt->value; | 560 | struct report *rep = (struct report *)opt->value; |
572 | char *tok, *tok2; | 561 | char *tok, *tok2; |
573 | char *endptr; | 562 | char *endptr; |
574 | 563 | ||
@@ -688,7 +677,7 @@ static int | |||
688 | parse_percent_limit(const struct option *opt, const char *str, | 677 | parse_percent_limit(const struct option *opt, const char *str, |
689 | int unset __maybe_unused) | 678 | int unset __maybe_unused) |
690 | { | 679 | { |
691 | struct perf_report *rep = opt->value; | 680 | struct report *rep = opt->value; |
692 | 681 | ||
693 | rep->min_percent = strtof(str, NULL); | 682 | rep->min_percent = strtof(str, NULL); |
694 | return 0; | 683 | return 0; |
@@ -706,7 +695,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) | |||
706 | "perf report [<options>]", | 695 | "perf report [<options>]", |
707 | NULL | 696 | NULL |
708 | }; | 697 | }; |
709 | struct perf_report report = { | 698 | struct report report = { |
710 | .tool = { | 699 | .tool = { |
711 | .sample = process_sample_event, | 700 | .sample = process_sample_event, |
712 | .mmap = perf_event__process_mmap, | 701 | .mmap = perf_event__process_mmap, |
@@ -822,7 +811,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) | |||
822 | .mode = PERF_DATA_MODE_READ, | 811 | .mode = PERF_DATA_MODE_READ, |
823 | }; | 812 | }; |
824 | 813 | ||
825 | perf_config(perf_report_config, &report); | 814 | perf_config(report__config, &report); |
826 | 815 | ||
827 | argc = parse_options(argc, argv, options, report_usage, 0); | 816 | argc = parse_options(argc, argv, options, report_usage, 0); |
828 | 817 | ||