diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-05-25 16:28:37 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-06-04 09:28:52 -0400 |
commit | 982d410bc6b405a75086236d3c1da1f18c40d6dd (patch) | |
tree | 79c972cc96866830d8bd0aa8778aeb24740094cb | |
parent | 9132d3d92d8953ee79690408a9a24d938be22cd8 (diff) |
perf annotate stdio: Use annotation_options consistently
Accross all the routines, this way we can have eventually have a
consistent set of defaults for all UIs.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-6qgtixurjgdk5u0n3rw78ges@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-annotate.c | 15 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 14 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 31 | ||||
-rw-r--r-- | tools/perf/util/annotate.h | 15 | ||||
-rw-r--r-- | tools/perf/util/top.h | 3 |
5 files changed, 41 insertions, 37 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 2b21bbcd70ea..7238010f28d4 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -40,9 +40,8 @@ | |||
40 | struct perf_annotate { | 40 | struct perf_annotate { |
41 | struct perf_tool tool; | 41 | struct perf_tool tool; |
42 | struct perf_session *session; | 42 | struct perf_session *session; |
43 | struct annotation_options opts; | ||
43 | bool use_tui, use_stdio, use_stdio2, use_gtk; | 44 | bool use_tui, use_stdio, use_stdio2, use_gtk; |
44 | bool full_paths; | ||
45 | bool print_line; | ||
46 | bool skip_missing; | 45 | bool skip_missing; |
47 | bool has_br_stack; | 46 | bool has_br_stack; |
48 | bool group_set; | 47 | bool group_set; |
@@ -289,10 +288,9 @@ static int hist_entry__tty_annotate(struct hist_entry *he, | |||
289 | struct perf_annotate *ann) | 288 | struct perf_annotate *ann) |
290 | { | 289 | { |
291 | if (!ann->use_stdio2) | 290 | if (!ann->use_stdio2) |
292 | return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel, | 291 | return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel, &ann->opts); |
293 | ann->print_line, ann->full_paths, 0, 0); | 292 | |
294 | return symbol__tty_annotate2(he->ms.sym, he->ms.map, evsel, | 293 | return symbol__tty_annotate2(he->ms.sym, he->ms.map, evsel, &ann->opts); |
295 | ann->print_line, ann->full_paths); | ||
296 | } | 294 | } |
297 | 295 | ||
298 | static void hists__find_annotations(struct hists *hists, | 296 | static void hists__find_annotations(struct hists *hists, |
@@ -476,6 +474,7 @@ int cmd_annotate(int argc, const char **argv) | |||
476 | .ordered_events = true, | 474 | .ordered_events = true, |
477 | .ordering_requires_timestamps = true, | 475 | .ordering_requires_timestamps = true, |
478 | }, | 476 | }, |
477 | .opts = annotation__default_options, | ||
479 | }; | 478 | }; |
480 | struct perf_data data = { | 479 | struct perf_data data = { |
481 | .mode = PERF_DATA_MODE_READ, | 480 | .mode = PERF_DATA_MODE_READ, |
@@ -503,9 +502,9 @@ int cmd_annotate(int argc, const char **argv) | |||
503 | "file", "vmlinux pathname"), | 502 | "file", "vmlinux pathname"), |
504 | OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, | 503 | OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, |
505 | "load module symbols - WARNING: use only with -k and LIVE kernel"), | 504 | "load module symbols - WARNING: use only with -k and LIVE kernel"), |
506 | OPT_BOOLEAN('l', "print-line", &annotate.print_line, | 505 | OPT_BOOLEAN('l', "print-line", &annotate.opts.print_lines, |
507 | "print matching source lines (may be slow)"), | 506 | "print matching source lines (may be slow)"), |
508 | OPT_BOOLEAN('P', "full-paths", &annotate.full_paths, | 507 | OPT_BOOLEAN('P', "full-paths", &annotate.opts.full_path, |
509 | "Don't shorten the displayed pathnames"), | 508 | "Don't shorten the displayed pathnames"), |
510 | OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing, | 509 | OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing, |
511 | "Skip symbols that cannot be annotated"), | 510 | "Skip symbols that cannot be annotated"), |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 4284840022a3..5e58cd4de90b 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -243,10 +243,9 @@ static void perf_top__show_details(struct perf_top *top) | |||
243 | goto out_unlock; | 243 | goto out_unlock; |
244 | 244 | ||
245 | printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), symbol->name); | 245 | printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), symbol->name); |
246 | printf(" Events Pcnt (>=%d%%)\n", top->sym_pcnt_filter); | 246 | printf(" Events Pcnt (>=%d%%)\n", top->annotation_opts.min_pcnt); |
247 | 247 | ||
248 | more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, | 248 | more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, &top->annotation_opts); |
249 | 0, top->sym_pcnt_filter, top->print_entries, 4); | ||
250 | 249 | ||
251 | if (top->evlist->enabled) { | 250 | if (top->evlist->enabled) { |
252 | if (top->zero) | 251 | if (top->zero) |
@@ -406,7 +405,7 @@ static void perf_top__print_mapped_keys(struct perf_top *top) | |||
406 | 405 | ||
407 | fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", top->count_filter); | 406 | fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", top->count_filter); |
408 | 407 | ||
409 | fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", top->sym_pcnt_filter); | 408 | fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", top->annotation_opts.min_pcnt); |
410 | fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL"); | 409 | fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL"); |
411 | fprintf(stdout, "\t[S] stop annotation.\n"); | 410 | fprintf(stdout, "\t[S] stop annotation.\n"); |
412 | 411 | ||
@@ -509,7 +508,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c) | |||
509 | prompt_integer(&top->count_filter, "Enter display event count filter"); | 508 | prompt_integer(&top->count_filter, "Enter display event count filter"); |
510 | break; | 509 | break; |
511 | case 'F': | 510 | case 'F': |
512 | prompt_percent(&top->sym_pcnt_filter, | 511 | prompt_percent(&top->annotation_opts.min_pcnt, |
513 | "Enter details display event filter (percent)"); | 512 | "Enter details display event filter (percent)"); |
514 | break; | 513 | break; |
515 | case 'K': | 514 | case 'K': |
@@ -1259,7 +1258,7 @@ int cmd_top(int argc, const char **argv) | |||
1259 | .overwrite = 1, | 1258 | .overwrite = 1, |
1260 | }, | 1259 | }, |
1261 | .max_stack = sysctl__max_stack(), | 1260 | .max_stack = sysctl__max_stack(), |
1262 | .sym_pcnt_filter = 5, | 1261 | .annotation_opts = annotation__default_options, |
1263 | .nr_threads_synthesize = UINT_MAX, | 1262 | .nr_threads_synthesize = UINT_MAX, |
1264 | }; | 1263 | }; |
1265 | struct record_opts *opts = &top.record_opts; | 1264 | struct record_opts *opts = &top.record_opts; |
@@ -1385,6 +1384,9 @@ int cmd_top(int argc, const char **argv) | |||
1385 | if (status < 0) | 1384 | if (status < 0) |
1386 | return status; | 1385 | return status; |
1387 | 1386 | ||
1387 | top.annotation_opts.min_pcnt = 5; | ||
1388 | top.annotation_opts.context = 4; | ||
1389 | |||
1388 | top.evlist = perf_evlist__new(); | 1390 | top.evlist = perf_evlist__new(); |
1389 | if (top.evlist == NULL) | 1391 | if (top.evlist == NULL) |
1390 | return -ENOMEM; | 1392 | return -ENOMEM; |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index bcd5d3e17b85..abcc7e24c365 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -1985,8 +1985,8 @@ static int annotated_source__addr_fmt_width(struct list_head *lines, u64 start) | |||
1985 | } | 1985 | } |
1986 | 1986 | ||
1987 | int symbol__annotate_printf(struct symbol *sym, struct map *map, | 1987 | int symbol__annotate_printf(struct symbol *sym, struct map *map, |
1988 | struct perf_evsel *evsel, bool full_paths, | 1988 | struct perf_evsel *evsel, |
1989 | int min_pcnt, int max_lines, int context) | 1989 | struct annotation_options *opts) |
1990 | { | 1990 | { |
1991 | struct dso *dso = map->dso; | 1991 | struct dso *dso = map->dso; |
1992 | char *filename; | 1992 | char *filename; |
@@ -1998,6 +1998,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, | |||
1998 | u64 start = map__rip_2objdump(map, sym->start); | 1998 | u64 start = map__rip_2objdump(map, sym->start); |
1999 | int printed = 2, queue_len = 0, addr_fmt_width; | 1999 | int printed = 2, queue_len = 0, addr_fmt_width; |
2000 | int more = 0; | 2000 | int more = 0; |
2001 | bool context = opts->context; | ||
2001 | u64 len; | 2002 | u64 len; |
2002 | int width = symbol_conf.show_total_period ? 12 : 8; | 2003 | int width = symbol_conf.show_total_period ? 12 : 8; |
2003 | int graph_dotted_len; | 2004 | int graph_dotted_len; |
@@ -2007,7 +2008,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, | |||
2007 | if (!filename) | 2008 | if (!filename) |
2008 | return -ENOMEM; | 2009 | return -ENOMEM; |
2009 | 2010 | ||
2010 | if (full_paths) | 2011 | if (opts->full_path) |
2011 | d_filename = filename; | 2012 | d_filename = filename; |
2012 | else | 2013 | else |
2013 | d_filename = basename(filename); | 2014 | d_filename = basename(filename); |
@@ -2042,7 +2043,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, | |||
2042 | } | 2043 | } |
2043 | 2044 | ||
2044 | err = annotation_line__print(pos, sym, start, evsel, len, | 2045 | err = annotation_line__print(pos, sym, start, evsel, len, |
2045 | min_pcnt, printed, max_lines, | 2046 | opts->min_pcnt, printed, opts->max_lines, |
2046 | queue, addr_fmt_width); | 2047 | queue, addr_fmt_width); |
2047 | 2048 | ||
2048 | switch (err) { | 2049 | switch (err) { |
@@ -2375,20 +2376,19 @@ static void symbol__calc_lines(struct symbol *sym, struct map *map, | |||
2375 | } | 2376 | } |
2376 | 2377 | ||
2377 | int symbol__tty_annotate2(struct symbol *sym, struct map *map, | 2378 | int symbol__tty_annotate2(struct symbol *sym, struct map *map, |
2378 | struct perf_evsel *evsel, bool print_lines, | 2379 | struct perf_evsel *evsel, |
2379 | bool full_paths) | 2380 | struct annotation_options *opts) |
2380 | { | 2381 | { |
2381 | struct dso *dso = map->dso; | 2382 | struct dso *dso = map->dso; |
2382 | struct rb_root source_line = RB_ROOT; | 2383 | struct rb_root source_line = RB_ROOT; |
2383 | struct annotation_options opts = annotation__default_options; | ||
2384 | struct annotation *notes = symbol__annotation(sym); | 2384 | struct annotation *notes = symbol__annotation(sym); |
2385 | char buf[1024]; | 2385 | char buf[1024]; |
2386 | 2386 | ||
2387 | if (symbol__annotate2(sym, map, evsel, &opts, NULL) < 0) | 2387 | if (symbol__annotate2(sym, map, evsel, opts, NULL) < 0) |
2388 | return -1; | 2388 | return -1; |
2389 | 2389 | ||
2390 | if (print_lines) { | 2390 | if (opts->print_lines) { |
2391 | srcline_full_filename = full_paths; | 2391 | srcline_full_filename = opts->full_path; |
2392 | symbol__calc_lines(sym, map, &source_line); | 2392 | symbol__calc_lines(sym, map, &source_line); |
2393 | print_summary(&source_line, dso->long_name); | 2393 | print_summary(&source_line, dso->long_name); |
2394 | } | 2394 | } |
@@ -2403,8 +2403,8 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map, | |||
2403 | } | 2403 | } |
2404 | 2404 | ||
2405 | int symbol__tty_annotate(struct symbol *sym, struct map *map, | 2405 | int symbol__tty_annotate(struct symbol *sym, struct map *map, |
2406 | struct perf_evsel *evsel, bool print_lines, | 2406 | struct perf_evsel *evsel, |
2407 | bool full_paths, int min_pcnt, int max_lines) | 2407 | struct annotation_options *opts) |
2408 | { | 2408 | { |
2409 | struct dso *dso = map->dso; | 2409 | struct dso *dso = map->dso; |
2410 | struct rb_root source_line = RB_ROOT; | 2410 | struct rb_root source_line = RB_ROOT; |
@@ -2414,14 +2414,13 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, | |||
2414 | 2414 | ||
2415 | symbol__calc_percent(sym, evsel); | 2415 | symbol__calc_percent(sym, evsel); |
2416 | 2416 | ||
2417 | if (print_lines) { | 2417 | if (opts->print_lines) { |
2418 | srcline_full_filename = full_paths; | 2418 | srcline_full_filename = opts->full_path; |
2419 | symbol__calc_lines(sym, map, &source_line); | 2419 | symbol__calc_lines(sym, map, &source_line); |
2420 | print_summary(&source_line, dso->long_name); | 2420 | print_summary(&source_line, dso->long_name); |
2421 | } | 2421 | } |
2422 | 2422 | ||
2423 | symbol__annotate_printf(sym, map, evsel, full_paths, | 2423 | symbol__annotate_printf(sym, map, evsel, opts); |
2424 | min_pcnt, max_lines, 0); | ||
2425 | 2424 | ||
2426 | annotated_source__purge(symbol__annotation(sym)->src); | 2425 | annotated_source__purge(symbol__annotation(sym)->src); |
2427 | 2426 | ||
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 3dc4ca1d6c08..20f3326cc640 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
@@ -67,12 +67,17 @@ struct annotation_options { | |||
67 | bool hide_src_code, | 67 | bool hide_src_code, |
68 | use_offset, | 68 | use_offset, |
69 | jump_arrows, | 69 | jump_arrows, |
70 | print_lines, | ||
71 | full_path, | ||
70 | show_linenr, | 72 | show_linenr, |
71 | show_nr_jumps, | 73 | show_nr_jumps, |
72 | show_nr_samples, | 74 | show_nr_samples, |
73 | show_total_period, | 75 | show_total_period, |
74 | show_minmax_cycle; | 76 | show_minmax_cycle; |
75 | u8 offset_level; | 77 | u8 offset_level; |
78 | int min_pcnt; | ||
79 | int max_lines; | ||
80 | int context; | ||
76 | }; | 81 | }; |
77 | 82 | ||
78 | enum { | 83 | enum { |
@@ -328,8 +333,8 @@ int symbol__strerror_disassemble(struct symbol *sym, struct map *map, | |||
328 | int errnum, char *buf, size_t buflen); | 333 | int errnum, char *buf, size_t buflen); |
329 | 334 | ||
330 | int symbol__annotate_printf(struct symbol *sym, struct map *map, | 335 | int symbol__annotate_printf(struct symbol *sym, struct map *map, |
331 | struct perf_evsel *evsel, bool full_paths, | 336 | struct perf_evsel *evsel, |
332 | int min_pcnt, int max_lines, int context); | 337 | struct annotation_options *options); |
333 | int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp); | 338 | int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp); |
334 | void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); | 339 | void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); |
335 | void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); | 340 | void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); |
@@ -340,12 +345,10 @@ int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel) | |||
340 | bool ui__has_annotation(void); | 345 | bool ui__has_annotation(void); |
341 | 346 | ||
342 | int symbol__tty_annotate(struct symbol *sym, struct map *map, | 347 | int symbol__tty_annotate(struct symbol *sym, struct map *map, |
343 | struct perf_evsel *evsel, bool print_lines, | 348 | struct perf_evsel *evsel, struct annotation_options *opts); |
344 | bool full_paths, int min_pcnt, int max_lines); | ||
345 | 349 | ||
346 | int symbol__tty_annotate2(struct symbol *sym, struct map *map, | 350 | int symbol__tty_annotate2(struct symbol *sym, struct map *map, |
347 | struct perf_evsel *evsel, bool print_lines, | 351 | struct perf_evsel *evsel, struct annotation_options *opts); |
348 | bool full_paths); | ||
349 | 352 | ||
350 | #ifdef HAVE_SLANG_SUPPORT | 353 | #ifdef HAVE_SLANG_SUPPORT |
351 | int symbol__tui_annotate(struct symbol *sym, struct map *map, | 354 | int symbol__tui_annotate(struct symbol *sym, struct map *map, |
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index 9892323cdd7c..9add1f72ce95 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h | |||
@@ -3,6 +3,7 @@ | |||
3 | #define __PERF_TOP_H 1 | 3 | #define __PERF_TOP_H 1 |
4 | 4 | ||
5 | #include "tool.h" | 5 | #include "tool.h" |
6 | #include "annotate.h" | ||
6 | #include <linux/types.h> | 7 | #include <linux/types.h> |
7 | #include <stddef.h> | 8 | #include <stddef.h> |
8 | #include <stdbool.h> | 9 | #include <stdbool.h> |
@@ -16,6 +17,7 @@ struct perf_top { | |||
16 | struct perf_tool tool; | 17 | struct perf_tool tool; |
17 | struct perf_evlist *evlist; | 18 | struct perf_evlist *evlist; |
18 | struct record_opts record_opts; | 19 | struct record_opts record_opts; |
20 | struct annotation_options annotation_opts; | ||
19 | /* | 21 | /* |
20 | * Symbols will be added here in perf_event__process_sample and will | 22 | * Symbols will be added here in perf_event__process_sample and will |
21 | * get out after decayed. | 23 | * get out after decayed. |
@@ -35,7 +37,6 @@ struct perf_top { | |||
35 | struct perf_session *session; | 37 | struct perf_session *session; |
36 | struct winsize winsize; | 38 | struct winsize winsize; |
37 | int realtime_prio; | 39 | int realtime_prio; |
38 | int sym_pcnt_filter; | ||
39 | const char *sym_filter; | 40 | const char *sym_filter; |
40 | float min_percent; | 41 | float min_percent; |
41 | unsigned int nr_threads_synthesize; | 42 | unsigned int nr_threads_synthesize; |