aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEkaterina Tumanova <tumanova@linux.vnet.ibm.com>2015-11-25 11:32:45 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-11-26 14:49:29 -0500
commitaac4864727f4b3838ec1c03277bbc47a237b7516 (patch)
treeb1ade62b3ebf87567ad4f167b0cf230b4dca7714
parent5e50426d5d9049dfdb8b2b18e761717e7e80a6ad (diff)
perf symbols: Refactor vmlinux_path__init() to ease path additions
Refactor vmlinux_path__init() to ease subsequent additions of new vmlinux locations. Signed-off-by: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> Acked-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1448469166-61363-2-git-send-email-tumanova@linux.vnet.ibm.com [ Rename vmlinux_path__update() to vmlinux_path__add() ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/symbol.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index cd08027a6d2c..e2ac6b6676e4 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1860,24 +1860,43 @@ static void vmlinux_path__exit(void)
1860 zfree(&vmlinux_path); 1860 zfree(&vmlinux_path);
1861} 1861}
1862 1862
1863static const char * const vmlinux_paths[] = {
1864 "vmlinux",
1865 "/boot/vmlinux"
1866};
1867
1868static const char * const vmlinux_paths_upd[] = {
1869 "/boot/vmlinux-%s",
1870 "/usr/lib/debug/boot/vmlinux-%s",
1871 "/lib/modules/%s/build/vmlinux",
1872 "/usr/lib/debug/lib/modules/%s/vmlinux"
1873};
1874
1875static int vmlinux_path__add(const char *new_entry)
1876{
1877 vmlinux_path[vmlinux_path__nr_entries] = strdup(new_entry);
1878 if (vmlinux_path[vmlinux_path__nr_entries] == NULL)
1879 return -1;
1880 ++vmlinux_path__nr_entries;
1881
1882 return 0;
1883}
1884
1863static int vmlinux_path__init(struct perf_env *env) 1885static int vmlinux_path__init(struct perf_env *env)
1864{ 1886{
1865 struct utsname uts; 1887 struct utsname uts;
1866 char bf[PATH_MAX]; 1888 char bf[PATH_MAX];
1867 char *kernel_version; 1889 char *kernel_version;
1890 unsigned int i;
1868 1891
1869 vmlinux_path = malloc(sizeof(char *) * 6); 1892 vmlinux_path = malloc(sizeof(char *) * (ARRAY_SIZE(vmlinux_paths) +
1893 ARRAY_SIZE(vmlinux_paths_upd)));
1870 if (vmlinux_path == NULL) 1894 if (vmlinux_path == NULL)
1871 return -1; 1895 return -1;
1872 1896
1873 vmlinux_path[vmlinux_path__nr_entries] = strdup("vmlinux"); 1897 for (i = 0; i < ARRAY_SIZE(vmlinux_paths); i++)
1874 if (vmlinux_path[vmlinux_path__nr_entries] == NULL) 1898 if (vmlinux_path__add(vmlinux_paths[i]) < 0)
1875 goto out_fail; 1899 goto out_fail;
1876 ++vmlinux_path__nr_entries;
1877 vmlinux_path[vmlinux_path__nr_entries] = strdup("/boot/vmlinux");
1878 if (vmlinux_path[vmlinux_path__nr_entries] == NULL)
1879 goto out_fail;
1880 ++vmlinux_path__nr_entries;
1881 1900
1882 /* only try kernel version if no symfs was given */ 1901 /* only try kernel version if no symfs was given */
1883 if (symbol_conf.symfs[0] != 0) 1902 if (symbol_conf.symfs[0] != 0)
@@ -1892,28 +1911,11 @@ static int vmlinux_path__init(struct perf_env *env)
1892 kernel_version = uts.release; 1911 kernel_version = uts.release;
1893 } 1912 }
1894 1913
1895 snprintf(bf, sizeof(bf), "/boot/vmlinux-%s", kernel_version); 1914 for (i = 0; i < ARRAY_SIZE(vmlinux_paths_upd); i++) {
1896 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf); 1915 snprintf(bf, sizeof(bf), vmlinux_paths_upd[i], kernel_version);
1897 if (vmlinux_path[vmlinux_path__nr_entries] == NULL) 1916 if (vmlinux_path__add(bf) < 0)
1898 goto out_fail; 1917 goto out_fail;
1899 ++vmlinux_path__nr_entries; 1918 }
1900 snprintf(bf, sizeof(bf), "/usr/lib/debug/boot/vmlinux-%s",
1901 kernel_version);
1902 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf);
1903 if (vmlinux_path[vmlinux_path__nr_entries] == NULL)
1904 goto out_fail;
1905 ++vmlinux_path__nr_entries;
1906 snprintf(bf, sizeof(bf), "/lib/modules/%s/build/vmlinux", kernel_version);
1907 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf);
1908 if (vmlinux_path[vmlinux_path__nr_entries] == NULL)
1909 goto out_fail;
1910 ++vmlinux_path__nr_entries;
1911 snprintf(bf, sizeof(bf), "/usr/lib/debug/lib/modules/%s/vmlinux",
1912 kernel_version);
1913 vmlinux_path[vmlinux_path__nr_entries] = strdup(bf);
1914 if (vmlinux_path[vmlinux_path__nr_entries] == NULL)
1915 goto out_fail;
1916 ++vmlinux_path__nr_entries;
1917 1919
1918 return 0; 1920 return 0;
1919 1921