aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r--tools/perf/util/symbol.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 009a9d064f11..ac098a3c2a31 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -15,6 +15,7 @@
15#include "machine.h" 15#include "machine.h"
16#include "symbol.h" 16#include "symbol.h"
17#include "strlist.h" 17#include "strlist.h"
18#include "header.h"
18 19
19#include <elf.h> 20#include <elf.h>
20#include <limits.h> 21#include <limits.h>
@@ -1749,10 +1750,11 @@ static void vmlinux_path__exit(void)
1749 zfree(&vmlinux_path); 1750 zfree(&vmlinux_path);
1750} 1751}
1751 1752
1752static int vmlinux_path__init(void) 1753static int vmlinux_path__init(struct perf_session_env *env)
1753{ 1754{
1754 struct utsname uts; 1755 struct utsname uts;
1755 char bf[PATH_MAX]; 1756 char bf[PATH_MAX];
1757 char *kernel_version;
1756 1758
1757 vmlinux_path = malloc(sizeof(char *) * 5); 1759 vmlinux_path = malloc(sizeof(char *) * 5);
1758 if (vmlinux_path == NULL) 1760 if (vmlinux_path == NULL)
@@ -1767,25 +1769,31 @@ static int vmlinux_path__init(void)
1767 goto out_fail; 1769 goto out_fail;
1768 ++vmlinux_path__nr_entries; 1770 ++vmlinux_path__nr_entries;
1769 1771
1770 /* only try running kernel version if no symfs was given */ 1772 /* only try kernel version if no symfs was given */
1771 if (symbol_conf.symfs[0] != 0) 1773 if (symbol_conf.symfs[0] != 0)
1772 return 0; 1774 return 0;
1773 1775
1774 if (uname(&uts) < 0) 1776 if (env) {
1775 goto out_fail; 1777 kernel_version = env->os_release;
1778 } else {
1779 if (uname(&uts) < 0)
1780 goto out_fail;
1781
1782 kernel_version = uts.release;
1783 }
1776 1784
1777 snprintf(bf, sizeof(bf), "/boot/vmlinux-%s", uts.release); 1785 snprintf(bf, sizeof(bf), "/boot/vmlinux-%s", kernel_version);
1778 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf); 1786 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf);
1779 if (vmlinux_path[vmlinux_path__nr_entries] == NULL) 1787 if (vmlinux_path[vmlinux_path__nr_entries] == NULL)
1780 goto out_fail; 1788 goto out_fail;
1781 ++vmlinux_path__nr_entries; 1789 ++vmlinux_path__nr_entries;
1782 snprintf(bf, sizeof(bf), "/lib/modules/%s/build/vmlinux", uts.release); 1790 snprintf(bf, sizeof(bf), "/lib/modules/%s/build/vmlinux", kernel_version);
1783 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf); 1791 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf);
1784 if (vmlinux_path[vmlinux_path__nr_entries] == NULL) 1792 if (vmlinux_path[vmlinux_path__nr_entries] == NULL)
1785 goto out_fail; 1793 goto out_fail;
1786 ++vmlinux_path__nr_entries; 1794 ++vmlinux_path__nr_entries;
1787 snprintf(bf, sizeof(bf), "/usr/lib/debug/lib/modules/%s/vmlinux", 1795 snprintf(bf, sizeof(bf), "/usr/lib/debug/lib/modules/%s/vmlinux",
1788 uts.release); 1796 kernel_version);
1789 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf); 1797 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf);
1790 if (vmlinux_path[vmlinux_path__nr_entries] == NULL) 1798 if (vmlinux_path[vmlinux_path__nr_entries] == NULL)
1791 goto out_fail; 1799 goto out_fail;
@@ -1831,7 +1839,7 @@ static bool symbol__read_kptr_restrict(void)
1831 return value; 1839 return value;
1832} 1840}
1833 1841
1834int symbol__init(void) 1842int symbol__init(struct perf_session_env *env)
1835{ 1843{
1836 const char *symfs; 1844 const char *symfs;
1837 1845
@@ -1846,7 +1854,7 @@ int symbol__init(void)
1846 symbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) - 1854 symbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) -
1847 sizeof(struct symbol)); 1855 sizeof(struct symbol));
1848 1856
1849 if (symbol_conf.try_vmlinux_path && vmlinux_path__init() < 0) 1857 if (symbol_conf.try_vmlinux_path && vmlinux_path__init(env) < 0)
1850 return -1; 1858 return -1;
1851 1859
1852 if (symbol_conf.field_sep && *symbol_conf.field_sep == '.') { 1860 if (symbol_conf.field_sep && *symbol_conf.field_sep == '.') {