aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2017-10-11 11:01:28 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-11-13 07:39:58 -0500
commitc34df25b40c20b478634b954a709749aebdc241a (patch)
treecb234ff09af7a371c44f586aa27076b9d093eac8 /tools/perf/util/annotate.c
parent37236d5e0b6a765319dec3e64d828cb44ebecac6 (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>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c58
1 files changed, 33 insertions, 25 deletions
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
1428int symbol__disassemble(struct symbol *sym, struct map *map, 1428static 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
1563int 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
1584static void insert_source_line(struct rb_root *root, struct source_line *src_line) 1592static 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);