diff options
author | Jiri Olsa <jolsa@kernel.org> | 2017-10-11 11:01:28 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-11-13 07:39:58 -0500 |
commit | c34df25b40c20b478634b954a709749aebdc241a (patch) | |
tree | cb234ff09af7a371c44f586aa27076b9d093eac8 | |
parent | 37236d5e0b6a765319dec3e64d828cb44ebecac6 (diff) |
perf annotate: Add symbol__annotate function
Add symbol__annotate function to have generic annotation function to be
called for all annotation sources.
It calls the generic annotation init and then the specific annotation
data retrieval function.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20171011150158.11895-6-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-top.c | 2 | ||||
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 6 | ||||
-rw-r--r-- | tools/perf/ui/gtk/annotate.c | 4 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 58 | ||||
-rw-r--r-- | tools/perf/util/annotate.h | 6 |
5 files changed, 42 insertions, 34 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 477a8699f0b5..adfeeb488f1a 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -134,7 +134,7 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he) | |||
134 | return err; | 134 | return err; |
135 | } | 135 | } |
136 | 136 | ||
137 | err = symbol__disassemble(sym, map, NULL, 0, NULL, NULL); | 137 | err = symbol__annotate(sym, map, NULL, 0, NULL, NULL); |
138 | if (err == 0) { | 138 | if (err == 0) { |
139 | out_assign: | 139 | out_assign: |
140 | top->sym_filter_entry = he; | 140 | top->sym_filter_entry = he; |
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index d1aff2f7cb6c..d77994c1cba9 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -1120,9 +1120,9 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
1120 | (nr_pcnt - 1); | 1120 | (nr_pcnt - 1); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel), | 1123 | err = symbol__annotate(sym, map, perf_evsel__env_arch(evsel), |
1124 | sizeof_bdl, &browser.arch, | 1124 | sizeof_bdl, &browser.arch, |
1125 | perf_evsel__env_cpuid(evsel)); | 1125 | perf_evsel__env_cpuid(evsel)); |
1126 | if (err) { | 1126 | if (err) { |
1127 | char msg[BUFSIZ]; | 1127 | char msg[BUFSIZ]; |
1128 | symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); | 1128 | symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); |
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c index 162f15712d2d..b498f1a92bb1 100644 --- a/tools/perf/ui/gtk/annotate.c +++ b/tools/perf/ui/gtk/annotate.c | |||
@@ -169,8 +169,8 @@ static int symbol__gtk_annotate(struct symbol *sym, struct map *map, | |||
169 | if (map->dso->annotate_warned) | 169 | if (map->dso->annotate_warned) |
170 | return -1; | 170 | return -1; |
171 | 171 | ||
172 | err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel), | 172 | err = symbol__annotate(sym, map, perf_evsel__env_arch(evsel), |
173 | 0, NULL, NULL); | 173 | 0, NULL, NULL); |
174 | if (err) { | 174 | if (err) { |
175 | char msg[BUFSIZ]; | 175 | char msg[BUFSIZ]; |
176 | symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); | 176 | symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index e8b69001229d..f0093918882d 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -1425,13 +1425,11 @@ static const char *annotate__norm_arch(const char *arch_name) | |||
1425 | return normalize_arch((char *)arch_name); | 1425 | return normalize_arch((char *)arch_name); |
1426 | } | 1426 | } |
1427 | 1427 | ||
1428 | int symbol__disassemble(struct symbol *sym, struct map *map, | 1428 | static int symbol__disassemble(struct symbol *sym, struct map *map, |
1429 | const char *arch_name, size_t privsize, | 1429 | size_t privsize, struct arch *arch) |
1430 | struct arch **parch, char *cpuid) | ||
1431 | { | 1430 | { |
1432 | struct dso *dso = map->dso; | 1431 | struct dso *dso = map->dso; |
1433 | char command[PATH_MAX * 2]; | 1432 | char command[PATH_MAX * 2]; |
1434 | struct arch *arch = NULL; | ||
1435 | FILE *file; | 1433 | FILE *file; |
1436 | char symfs_filename[PATH_MAX]; | 1434 | char symfs_filename[PATH_MAX]; |
1437 | struct kcore_extract kce; | 1435 | struct kcore_extract kce; |
@@ -1445,25 +1443,6 @@ int symbol__disassemble(struct symbol *sym, struct map *map, | |||
1445 | if (err) | 1443 | if (err) |
1446 | return err; | 1444 | return err; |
1447 | 1445 | ||
1448 | arch_name = annotate__norm_arch(arch_name); | ||
1449 | if (!arch_name) | ||
1450 | return -1; | ||
1451 | |||
1452 | arch = arch__find(arch_name); | ||
1453 | if (arch == NULL) | ||
1454 | return -ENOTSUP; | ||
1455 | |||
1456 | if (parch) | ||
1457 | *parch = arch; | ||
1458 | |||
1459 | if (arch->init) { | ||
1460 | err = arch->init(arch, cpuid); | ||
1461 | if (err) { | ||
1462 | pr_err("%s: failed to initialize %s arch priv area\n", __func__, arch->name); | ||
1463 | return err; | ||
1464 | } | ||
1465 | } | ||
1466 | |||
1467 | pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__, | 1446 | pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__, |
1468 | symfs_filename, sym->name, map->unmap_ip(map, sym->start), | 1447 | symfs_filename, sym->name, map->unmap_ip(map, sym->start), |
1469 | map->unmap_ip(map, sym->end)); | 1448 | map->unmap_ip(map, sym->end)); |
@@ -1581,6 +1560,35 @@ out_close_stdout: | |||
1581 | goto out_remove_tmp; | 1560 | goto out_remove_tmp; |
1582 | } | 1561 | } |
1583 | 1562 | ||
1563 | int symbol__annotate(struct symbol *sym, struct map *map, | ||
1564 | const char *arch_name, size_t privsize, | ||
1565 | struct arch **parch, char *cpuid) | ||
1566 | { | ||
1567 | struct arch *arch; | ||
1568 | int err; | ||
1569 | |||
1570 | arch_name = annotate__norm_arch(arch_name); | ||
1571 | if (!arch_name) | ||
1572 | return -1; | ||
1573 | |||
1574 | arch = arch__find(arch_name); | ||
1575 | if (arch == NULL) | ||
1576 | return -ENOTSUP; | ||
1577 | |||
1578 | if (parch) | ||
1579 | *parch = arch; | ||
1580 | |||
1581 | if (arch->init) { | ||
1582 | err = arch->init(arch, cpuid); | ||
1583 | if (err) { | ||
1584 | pr_err("%s: failed to initialize %s arch priv area\n", __func__, arch->name); | ||
1585 | return err; | ||
1586 | } | ||
1587 | } | ||
1588 | |||
1589 | return symbol__disassemble(sym, map, privsize, arch); | ||
1590 | } | ||
1591 | |||
1584 | static void insert_source_line(struct rb_root *root, struct source_line *src_line) | 1592 | static void insert_source_line(struct rb_root *root, struct source_line *src_line) |
1585 | { | 1593 | { |
1586 | struct source_line *iter; | 1594 | struct source_line *iter; |
@@ -1954,8 +1962,8 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, | |||
1954 | struct rb_root source_line = RB_ROOT; | 1962 | struct rb_root source_line = RB_ROOT; |
1955 | u64 len; | 1963 | u64 len; |
1956 | 1964 | ||
1957 | if (symbol__disassemble(sym, map, perf_evsel__env_arch(evsel), | 1965 | if (symbol__annotate(sym, map, perf_evsel__env_arch(evsel), |
1958 | 0, NULL, NULL) < 0) | 1966 | 0, NULL, NULL) < 0) |
1959 | return -1; | 1967 | return -1; |
1960 | 1968 | ||
1961 | len = symbol__size(sym); | 1969 | len = symbol__size(sym); |
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index a822c0a4987e..e577f9d13a58 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
@@ -173,9 +173,9 @@ int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *samp | |||
173 | int symbol__alloc_hist(struct symbol *sym); | 173 | int symbol__alloc_hist(struct symbol *sym); |
174 | void symbol__annotate_zero_histograms(struct symbol *sym); | 174 | void symbol__annotate_zero_histograms(struct symbol *sym); |
175 | 175 | ||
176 | int symbol__disassemble(struct symbol *sym, struct map *map, | 176 | int symbol__annotate(struct symbol *sym, struct map *map, |
177 | const char *arch_name, size_t privsize, | 177 | const char *arch_name, size_t privsize, |
178 | struct arch **parch, char *cpuid); | 178 | struct arch **parch, char *cpuid); |
179 | 179 | ||
180 | enum symbol_disassemble_errno { | 180 | enum symbol_disassemble_errno { |
181 | SYMBOL_ANNOTATE_ERRNO__SUCCESS = 0, | 181 | SYMBOL_ANNOTATE_ERRNO__SUCCESS = 0, |