Commit 0a77582f authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Arnaldo Carvalho de Melo

perf symbols: Introduce DSO__NAME_KALLSYMS and DSO__NAME_KCORE

Instead of using a raw string, use DSO__NAME_KALLSYMS and
DSO__NAME_KCORE macros for kallsyms and kcore.
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20160515031935.4017.50971.stgit@devboxSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a1f3d567
...@@ -119,8 +119,8 @@ static int build_id_cache__add_kcore(const char *filename, bool force) ...@@ -119,8 +119,8 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
if (build_id_cache__kcore_buildid(from_dir, sbuildid) < 0) if (build_id_cache__kcore_buildid(from_dir, sbuildid) < 0)
return -1; return -1;
scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s", scnprintf(to_dir, sizeof(to_dir), "%s/%s/%s",
buildid_dir, sbuildid); buildid_dir, DSO__NAME_KCORE, sbuildid);
if (!force && if (!force &&
!build_id_cache__kcore_existing(from_dir, to_dir, sizeof(to_dir))) { !build_id_cache__kcore_existing(from_dir, to_dir, sizeof(to_dir))) {
...@@ -131,8 +131,8 @@ static int build_id_cache__add_kcore(const char *filename, bool force) ...@@ -131,8 +131,8 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
if (build_id_cache__kcore_dir(dir, sizeof(dir))) if (build_id_cache__kcore_dir(dir, sizeof(dir)))
return -1; return -1;
scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s/%s", scnprintf(to_dir, sizeof(to_dir), "%s/%s/%s/%s",
buildid_dir, sbuildid, dir); buildid_dir, DSO__NAME_KCORE, sbuildid, dir);
if (mkdir_p(to_dir, 0755)) if (mkdir_p(to_dir, 0755))
return -1; return -1;
......
...@@ -1122,7 +1122,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize) ...@@ -1122,7 +1122,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
} else if (dso__is_kcore(dso)) { } else if (dso__is_kcore(dso)) {
goto fallback; goto fallback;
} else if (readlink(symfs_filename, command, sizeof(command)) < 0 || } else if (readlink(symfs_filename, command, sizeof(command)) < 0 ||
strstr(command, "[kernel.kallsyms]") || strstr(command, DSO__NAME_KALLSYMS) ||
access(symfs_filename, R_OK)) { access(symfs_filename, R_OK)) {
free(filename); free(filename);
fallback: fallback:
......
...@@ -709,7 +709,7 @@ static struct dso *machine__get_kernel(struct machine *machine) ...@@ -709,7 +709,7 @@ static struct dso *machine__get_kernel(struct machine *machine)
if (machine__is_host(machine)) { if (machine__is_host(machine)) {
vmlinux_name = symbol_conf.vmlinux_name; vmlinux_name = symbol_conf.vmlinux_name;
if (!vmlinux_name) if (!vmlinux_name)
vmlinux_name = "[kernel.kallsyms]"; vmlinux_name = DSO__NAME_KALLSYMS;
kernel = machine__findnew_kernel(machine, vmlinux_name, kernel = machine__findnew_kernel(machine, vmlinux_name,
"[kernel]", DSO_TYPE_KERNEL); "[kernel]", DSO_TYPE_KERNEL);
......
...@@ -1662,8 +1662,8 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map) ...@@ -1662,8 +1662,8 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id); build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
scnprintf(path, sizeof(path), "%s/[kernel.kcore]/%s", buildid_dir, scnprintf(path, sizeof(path), "%s/%s/%s", buildid_dir,
sbuild_id); DSO__NAME_KCORE, sbuild_id);
/* Use /proc/kallsyms if possible */ /* Use /proc/kallsyms if possible */
if (is_host) { if (is_host) {
...@@ -1699,8 +1699,8 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map) ...@@ -1699,8 +1699,8 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
if (!find_matching_kcore(map, path, sizeof(path))) if (!find_matching_kcore(map, path, sizeof(path)))
return strdup(path); return strdup(path);
scnprintf(path, sizeof(path), "%s/[kernel.kallsyms]/%s", scnprintf(path, sizeof(path), "%s/%s/%s",
buildid_dir, sbuild_id); buildid_dir, DSO__NAME_KALLSYMS, sbuild_id);
if (access(path, F_OK)) { if (access(path, F_OK)) {
pr_err("No kallsyms or vmlinux with build-id %s was found\n", pr_err("No kallsyms or vmlinux with build-id %s was found\n",
...@@ -1769,7 +1769,7 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map, ...@@ -1769,7 +1769,7 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map,
if (err > 0 && !dso__is_kcore(dso)) { if (err > 0 && !dso__is_kcore(dso)) {
dso->binary_type = DSO_BINARY_TYPE__KALLSYMS; dso->binary_type = DSO_BINARY_TYPE__KALLSYMS;
dso__set_long_name(dso, "[kernel.kallsyms]", false); dso__set_long_name(dso, DSO__NAME_KALLSYMS, false);
map__fixup_start(map); map__fixup_start(map);
map__fixup_end(map); map__fixup_end(map);
} }
......
...@@ -44,6 +44,9 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, ...@@ -44,6 +44,9 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
#endif #endif
#define DSO__NAME_KALLSYMS "[kernel.kallsyms]"
#define DSO__NAME_KCORE "[kernel.kcore]"
/** struct symbol - symtab entry /** struct symbol - symtab entry
* *
* @ignore - resolvable but tools ignore it (e.g. idle routines) * @ignore - resolvable but tools ignore it (e.g. idle routines)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment