aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-01-19 07:36:14 -0500
committerIngo Molnar <mingo@elte.hu>2010-01-20 02:55:00 -0500
commitdc8d6ab2b61a2d92b5d7438565ccd20b29724cb2 (patch)
treec0453974206d3443a5caa421d40e6cfd7a47d510 /tools
parentf162f87ad6e98e8bfb2362955da46bed7b2514be (diff)
perf symbols: Use only --vmlinux if specified
Found while analysing a perf.data file collected on an ARM machine where an explicitely specified vmlinux was being disregarded. Reported-by: Jamie Iles <jamie.iles@picochip.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1263904574-30732-2-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/symbol.c67
1 files changed, 41 insertions, 26 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index a4e745934584..b6ab23dd5f9f 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1572,7 +1572,7 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
1572 return -1; 1572 return -1;
1573 1573
1574 dso__set_loaded(self, map->type); 1574 dso__set_loaded(self, map->type);
1575 err = dso__load_sym(self, map, session, self->long_name, fd, filter, 1, 0); 1575 err = dso__load_sym(self, map, session, vmlinux, fd, filter, 1, 0);
1576 close(fd); 1576 close(fd);
1577 1577
1578 return err; 1578 return err;
@@ -1584,6 +1584,26 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
1584 int err; 1584 int err;
1585 const char *kallsyms_filename = NULL; 1585 const char *kallsyms_filename = NULL;
1586 char *kallsyms_allocated_filename = NULL; 1586 char *kallsyms_allocated_filename = NULL;
1587 /*
1588 * Step 1: if the user specified a vmlinux filename, use it and only
1589 * it, reporting errors to the user if it cannot be used.
1590 *
1591 * For instance, try to analyse an ARM perf.data file _without_ a
1592 * build-id, or if the user specifies the wrong path to the right
1593 * vmlinux file, obviously we can't fallback to another vmlinux (a
1594 * x86_86 one, on the machine where analysis is being performed, say),
1595 * or worse, /proc/kallsyms.
1596 *
1597 * If the specified file _has_ a build-id and there is a build-id
1598 * section in the perf.data file, we will still do the expected
1599 * validation in dso__load_vmlinux and will bail out if they don't
1600 * match.
1601 */
1602 if (symbol_conf.vmlinux_name != NULL) {
1603 err = dso__load_vmlinux(self, map, session,
1604 symbol_conf.vmlinux_name, filter);
1605 goto out_try_fixup;
1606 }
1587 1607
1588 if (vmlinux_path != NULL) { 1608 if (vmlinux_path != NULL) {
1589 int i; 1609 int i;
@@ -1618,46 +1638,41 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
1618 goto do_kallsyms; 1638 goto do_kallsyms;
1619 } 1639 }
1620 } 1640 }
1621 1641 /*
1642 * Now look if we have it on the build-id cache in
1643 * $HOME/.debug/[kernel.kallsyms].
1644 */
1622 build_id__sprintf(self->build_id, sizeof(self->build_id), 1645 build_id__sprintf(self->build_id, sizeof(self->build_id),
1623 sbuild_id); 1646 sbuild_id);
1624 1647
1625 if (asprintf(&kallsyms_allocated_filename, 1648 if (asprintf(&kallsyms_allocated_filename,
1626 "%s/.debug/[kernel.kallsyms]/%s", 1649 "%s/.debug/[kernel.kallsyms]/%s",
1627 getenv("HOME"), sbuild_id) != -1) { 1650 getenv("HOME"), sbuild_id) == -1)
1628 if (access(kallsyms_filename, F_OK)) { 1651 return -1;
1629 kallsyms_filename = kallsyms_allocated_filename; 1652
1630 goto do_kallsyms; 1653 if (access(kallsyms_filename, F_OK)) {
1631 }
1632 free(kallsyms_allocated_filename); 1654 free(kallsyms_allocated_filename);
1633 kallsyms_allocated_filename = NULL; 1655 return -1;
1634 } 1656 }
1635 1657
1636 goto do_vmlinux; 1658 kallsyms_filename = kallsyms_allocated_filename;
1637 } 1659 } else {
1638 1660 /*
1639 if (self->long_name[0] == '[') { 1661 * Last resort, if we don't have a build-id and couldn't find
1662 * any vmlinux file, try the running kernel kallsyms table.
1663 */
1640 kallsyms_filename = "/proc/kallsyms"; 1664 kallsyms_filename = "/proc/kallsyms";
1641 goto do_kallsyms;
1642 } 1665 }
1643 1666
1644do_vmlinux:
1645 err = dso__load_vmlinux(self, map, session, self->long_name, filter);
1646 if (err <= 0) {
1647 if (self->has_build_id)
1648 return -1;
1649
1650 pr_info("The file %s cannot be used, "
1651 "trying to use /proc/kallsyms...", self->long_name);
1652do_kallsyms: 1667do_kallsyms:
1653 err = dso__load_kallsyms(self, kallsyms_filename, map, session, filter); 1668 err = dso__load_kallsyms(self, kallsyms_filename, map, session, filter);
1654 if (err > 0 && kallsyms_filename == NULL) 1669 free(kallsyms_allocated_filename);
1655 dso__set_long_name(self, strdup("[kernel.kallsyms]"));
1656 free(kallsyms_allocated_filename);
1657 }
1658 1670
1671out_try_fixup:
1659 if (err > 0) { 1672 if (err > 0) {
1660out_fixup: 1673out_fixup:
1674 if (kallsyms_filename == NULL)
1675 dso__set_long_name(self, strdup("[kernel.kallsyms]"));
1661 map__fixup_start(map); 1676 map__fixup_start(map);
1662 map__fixup_end(map); 1677 map__fixup_end(map);
1663 } 1678 }