diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-03-15 15:54:11 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-03-20 12:19:30 -0400 |
commit | ecda45bd6cfe0badda0e8215c5a008eaf7647716 (patch) | |
tree | bb05411b2b6a4d048f28015394a81ecdd2cb42c4 | |
parent | b8b0d819858e1140e98ce858a0c839f3d03cb0f5 (diff) |
perf annotate: Introduce symbol__annotate2 method
That does all the extended boilerplate the TUI browser did, leaving the
symbol__annotate() function to be used by the old --stdio output mode.
Now the upcoming --stdio2 output mode should just use this one to set
things up.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.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-e2x8wuf6gvdhzdryo229vj4i@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 28 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 39 | ||||
-rw-r--r-- | tools/perf/util/annotate.h | 4 |
3 files changed, 44 insertions, 27 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 06ad5ecaa67a..ab21739f27ae 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -910,7 +910,6 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
910 | struct hist_browser_timer *hbt) | 910 | struct hist_browser_timer *hbt) |
911 | { | 911 | { |
912 | struct annotation *notes = symbol__annotation(sym); | 912 | struct annotation *notes = symbol__annotation(sym); |
913 | size_t size; | ||
914 | struct map_symbol ms = { | 913 | struct map_symbol ms = { |
915 | .map = map, | 914 | .map = map, |
916 | .sym = sym, | 915 | .sym = sym, |
@@ -926,28 +925,14 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
926 | }, | 925 | }, |
927 | }; | 926 | }; |
928 | int ret = -1, err; | 927 | int ret = -1, err; |
929 | int nr_pcnt = 1; | ||
930 | 928 | ||
931 | if (sym == NULL) | 929 | if (sym == NULL) |
932 | return -1; | 930 | return -1; |
933 | 931 | ||
934 | size = symbol__size(sym); | ||
935 | |||
936 | if (map->dso->annotate_warned) | 932 | if (map->dso->annotate_warned) |
937 | return -1; | 933 | return -1; |
938 | 934 | ||
939 | notes->options = &annotate_browser__opts; | 935 | err = symbol__annotate2(sym, map, evsel, &annotate_browser__opts, &browser.arch); |
940 | |||
941 | notes->offsets = zalloc(size * sizeof(struct annotation_line *)); | ||
942 | if (notes->offsets == NULL) { | ||
943 | ui__error("Not enough memory!"); | ||
944 | return -1; | ||
945 | } | ||
946 | |||
947 | if (perf_evsel__is_group_event(evsel)) | ||
948 | nr_pcnt = evsel->nr_members; | ||
949 | |||
950 | err = symbol__annotate(sym, map, evsel, 0, &browser.arch); | ||
951 | if (err) { | 936 | if (err) { |
952 | char msg[BUFSIZ]; | 937 | char msg[BUFSIZ]; |
953 | symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); | 938 | symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); |
@@ -955,18 +940,9 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
955 | goto out_free_offsets; | 940 | goto out_free_offsets; |
956 | } | 941 | } |
957 | 942 | ||
958 | symbol__calc_percent(sym, evsel); | ||
959 | |||
960 | ui_helpline__push("Press ESC to exit"); | 943 | ui_helpline__push("Press ESC to exit"); |
961 | 944 | ||
962 | notes->start = map__rip_2objdump(map, sym->start); | ||
963 | |||
964 | annotation__set_offsets(notes, size); | ||
965 | browser.b.width = notes->max_line_len; | 945 | browser.b.width = notes->max_line_len; |
966 | annotation__mark_jump_targets(notes, sym); | ||
967 | annotation__compute_ipc(notes, size); | ||
968 | annotation__init_column_widths(notes, sym); | ||
969 | notes->nr_events = nr_pcnt; | ||
970 | browser.b.nr_entries = notes->nr_entries; | 946 | browser.b.nr_entries = notes->nr_entries; |
971 | browser.b.entries = ¬es->src->source, | 947 | browser.b.entries = ¬es->src->source, |
972 | browser.b.width += 18; /* Percentage */ | 948 | browser.b.width += 18; /* Percentage */ |
@@ -974,8 +950,6 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
974 | if (notes->options->hide_src_code) | 950 | if (notes->options->hide_src_code) |
975 | ui_browser__init_asm_mode(&browser.b); | 951 | ui_browser__init_asm_mode(&browser.b); |
976 | 952 | ||
977 | annotation__update_column_widths(notes); | ||
978 | |||
979 | ret = annotate_browser__run(&browser, evsel, hbt); | 953 | ret = annotate_browser__run(&browser, evsel, hbt); |
980 | 954 | ||
981 | annotated_source__purge(notes->src); | 955 | annotated_source__purge(notes->src); |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 9c05b534f428..7ad6400a0d4f 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -2183,3 +2183,42 @@ bool ui__has_annotation(void) | |||
2183 | { | 2183 | { |
2184 | return use_browser == 1 && perf_hpp_list.sym; | 2184 | return use_browser == 1 && perf_hpp_list.sym; |
2185 | } | 2185 | } |
2186 | |||
2187 | int symbol__annotate2(struct symbol *sym, struct map *map, struct perf_evsel *evsel, | ||
2188 | struct annotation_options *options, struct arch **parch) | ||
2189 | { | ||
2190 | struct annotation *notes = symbol__annotation(sym); | ||
2191 | size_t size = symbol__size(sym); | ||
2192 | int nr_pcnt = 1, err; | ||
2193 | |||
2194 | notes->offsets = zalloc(size * sizeof(struct annotation_line *)); | ||
2195 | if (notes->offsets == NULL) | ||
2196 | return -1; | ||
2197 | |||
2198 | if (perf_evsel__is_group_event(evsel)) | ||
2199 | nr_pcnt = evsel->nr_members; | ||
2200 | |||
2201 | err = symbol__annotate(sym, map, evsel, 0, parch); | ||
2202 | if (err) | ||
2203 | goto out_free_offsets; | ||
2204 | |||
2205 | notes->options = options; | ||
2206 | |||
2207 | symbol__calc_percent(sym, evsel); | ||
2208 | |||
2209 | notes->start = map__rip_2objdump(map, sym->start); | ||
2210 | |||
2211 | annotation__set_offsets(notes, size); | ||
2212 | annotation__mark_jump_targets(notes, sym); | ||
2213 | annotation__compute_ipc(notes, size); | ||
2214 | annotation__init_column_widths(notes, sym); | ||
2215 | notes->nr_events = nr_pcnt; | ||
2216 | |||
2217 | annotation__update_column_widths(notes); | ||
2218 | |||
2219 | return 0; | ||
2220 | |||
2221 | out_free_offsets: | ||
2222 | zfree(¬es->offsets); | ||
2223 | return -1; | ||
2224 | } | ||
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index c4528e03a031..f93c805473f9 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
@@ -233,6 +233,10 @@ void symbol__annotate_zero_histograms(struct symbol *sym); | |||
233 | int symbol__annotate(struct symbol *sym, struct map *map, | 233 | int symbol__annotate(struct symbol *sym, struct map *map, |
234 | struct perf_evsel *evsel, size_t privsize, | 234 | struct perf_evsel *evsel, size_t privsize, |
235 | struct arch **parch); | 235 | struct arch **parch); |
236 | int symbol__annotate2(struct symbol *sym, struct map *map, | ||
237 | struct perf_evsel *evsel, | ||
238 | struct annotation_options *options, | ||
239 | struct arch **parch); | ||
236 | 240 | ||
237 | enum symbol_disassemble_errno { | 241 | enum symbol_disassemble_errno { |
238 | SYMBOL_ANNOTATE_ERRNO__SUCCESS = 0, | 242 | SYMBOL_ANNOTATE_ERRNO__SUCCESS = 0, |