Skip to content

Commit 0a77582

Browse files
mhiramatacmel
authored andcommitted
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: Masami Hiramatsu <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Brendan Gregg <[email protected]> Cc: Hemant Kumar <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/20160515031935.4017.50971.stgit@devbox Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a1f3d56 commit 0a77582

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

tools/perf/builtin-buildid-cache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
119119
if (build_id_cache__kcore_buildid(from_dir, sbuildid) < 0)
120120
return -1;
121121

122-
scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s",
123-
buildid_dir, sbuildid);
122+
scnprintf(to_dir, sizeof(to_dir), "%s/%s/%s",
123+
buildid_dir, DSO__NAME_KCORE, sbuildid);
124124

125125
if (!force &&
126126
!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)
131131
if (build_id_cache__kcore_dir(dir, sizeof(dir)))
132132
return -1;
133133

134-
scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s/%s",
135-
buildid_dir, sbuildid, dir);
134+
scnprintf(to_dir, sizeof(to_dir), "%s/%s/%s/%s",
135+
buildid_dir, DSO__NAME_KCORE, sbuildid, dir);
136136

137137
if (mkdir_p(to_dir, 0755))
138138
return -1;

tools/perf/util/annotate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
11221122
} else if (dso__is_kcore(dso)) {
11231123
goto fallback;
11241124
} else if (readlink(symfs_filename, command, sizeof(command)) < 0 ||
1125-
strstr(command, "[kernel.kallsyms]") ||
1125+
strstr(command, DSO__NAME_KALLSYMS) ||
11261126
access(symfs_filename, R_OK)) {
11271127
free(filename);
11281128
fallback:

tools/perf/util/machine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ static struct dso *machine__get_kernel(struct machine *machine)
709709
if (machine__is_host(machine)) {
710710
vmlinux_name = symbol_conf.vmlinux_name;
711711
if (!vmlinux_name)
712-
vmlinux_name = "[kernel.kallsyms]";
712+
vmlinux_name = DSO__NAME_KALLSYMS;
713713

714714
kernel = machine__findnew_kernel(machine, vmlinux_name,
715715
"[kernel]", DSO_TYPE_KERNEL);

tools/perf/util/symbol.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,8 +1662,8 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
16621662

16631663
build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
16641664

1665-
scnprintf(path, sizeof(path), "%s/[kernel.kcore]/%s", buildid_dir,
1666-
sbuild_id);
1665+
scnprintf(path, sizeof(path), "%s/%s/%s", buildid_dir,
1666+
DSO__NAME_KCORE, sbuild_id);
16671667

16681668
/* Use /proc/kallsyms if possible */
16691669
if (is_host) {
@@ -1699,8 +1699,8 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
16991699
if (!find_matching_kcore(map, path, sizeof(path)))
17001700
return strdup(path);
17011701

1702-
scnprintf(path, sizeof(path), "%s/[kernel.kallsyms]/%s",
1703-
buildid_dir, sbuild_id);
1702+
scnprintf(path, sizeof(path), "%s/%s/%s",
1703+
buildid_dir, DSO__NAME_KALLSYMS, sbuild_id);
17041704

17051705
if (access(path, F_OK)) {
17061706
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,
17691769

17701770
if (err > 0 && !dso__is_kcore(dso)) {
17711771
dso->binary_type = DSO_BINARY_TYPE__KALLSYMS;
1772-
dso__set_long_name(dso, "[kernel.kallsyms]", false);
1772+
dso__set_long_name(dso, DSO__NAME_KALLSYMS, false);
17731773
map__fixup_start(map);
17741774
map__fixup_end(map);
17751775
}

tools/perf/util/symbol.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
4444
#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
4545
#endif
4646

47+
#define DSO__NAME_KALLSYMS "[kernel.kallsyms]"
48+
#define DSO__NAME_KCORE "[kernel.kcore]"
49+
4750
/** struct symbol - symtab entry
4851
*
4952
* @ignore - resolvable but tools ignore it (e.g. idle routines)

0 commit comments

Comments
 (0)