All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org, Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Hemant Kumar <hemant@linux.vnet.ibm.com>,
	Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>,
	Brendan Gregg <brendan.d.gregg@gmail.com>
Subject: [PATCH perf/core v8 01/16] perf buildid: Introduce DSO__NAME_KALLSYMS and DSO__NAME_KCORE
Date: Sun, 15 May 2016 12:19:40 +0900	[thread overview]
Message-ID: <20160515031935.4017.50971.stgit@devbox> (raw)
In-Reply-To: <20160515031922.4017.13932.stgit@devbox>

Instead of using raw string, use DSO__NAME_KALLSYMS and DSO__NAME_KCORE
macros for kallsyms and kcore.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/perf/builtin-buildid-cache.c |    8 ++++----
 tools/perf/util/annotate.c         |    2 +-
 tools/perf/util/machine.c          |    2 +-
 tools/perf/util/symbol.c           |   10 +++++-----
 tools/perf/util/symbol.h           |    3 +++
 5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index 632efc6..d75bded 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -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)
 		return -1;
 
-	scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s",
-		  buildid_dir, sbuildid);
+	scnprintf(to_dir, sizeof(to_dir), "%s/%s/%s",
+		  buildid_dir, DSO__NAME_KCORE, sbuildid);
 
 	if (!force &&
 	    !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)
 	if (build_id_cache__kcore_dir(dir, sizeof(dir)))
 		return -1;
 
-	scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s/%s",
-		  buildid_dir, sbuildid, dir);
+	scnprintf(to_dir, sizeof(to_dir), "%s/%s/%s/%s",
+		  buildid_dir, DSO__NAME_KCORE, sbuildid, dir);
 
 	if (mkdir_p(to_dir, 0755))
 		return -1;
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 4db73d5..b811924 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1122,7 +1122,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
 	} else if (dso__is_kcore(dso)) {
 		goto fallback;
 	} else if (readlink(symfs_filename, command, sizeof(command)) < 0 ||
-		   strstr(command, "[kernel.kallsyms]") ||
+		   strstr(command, DSO__NAME_KALLSYMS) ||
 		   access(symfs_filename, R_OK)) {
 		free(filename);
 fallback:
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 639a290..18dd96b 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -709,7 +709,7 @@ static struct dso *machine__get_kernel(struct machine *machine)
 	if (machine__is_host(machine)) {
 		vmlinux_name = symbol_conf.vmlinux_name;
 		if (!vmlinux_name)
-			vmlinux_name = "[kernel.kallsyms]";
+			vmlinux_name = DSO__NAME_KALLSYMS;
 
 		kernel = machine__findnew_kernel(machine, vmlinux_name,
 						 "[kernel]", DSO_TYPE_KERNEL);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 7fb3330..2252b54 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -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);
 
-	scnprintf(path, sizeof(path), "%s/[kernel.kcore]/%s", buildid_dir,
-		  sbuild_id);
+	scnprintf(path, sizeof(path), "%s/%s/%s", buildid_dir,
+		  DSO__NAME_KCORE, sbuild_id);
 
 	/* Use /proc/kallsyms if possible */
 	if (is_host) {
@@ -1699,8 +1699,8 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map)
 	if (!find_matching_kcore(map, path, sizeof(path)))
 		return strdup(path);
 
-	scnprintf(path, sizeof(path), "%s/[kernel.kallsyms]/%s",
-		  buildid_dir, sbuild_id);
+	scnprintf(path, sizeof(path), "%s/%s/%s",
+		  buildid_dir, DSO__NAME_KALLSYMS, sbuild_id);
 
 	if (access(path, F_OK)) {
 		pr_err("No kallsyms or vmlinux with build-id %s was found\n",
@@ -1769,7 +1769,7 @@ do_kallsyms:
 
 	if (err > 0 && !dso__is_kcore(dso)) {
 		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_end(map);
 	}
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 2b5e4ed..25f2fd67 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -44,6 +44,9 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
 #define DMGL_ANSI        (1 << 1)       /* Include const, volatile, etc */
 #endif
 
+#define DSO__NAME_KALLSYMS	"[kernel.kallsyms]"
+#define DSO__NAME_KCORE		"[kernel.kcore]"
+
 /** struct symbol - symtab entry
  *
  * @ignore - resolvable but tools ignore it (e.g. idle routines)

  reply	other threads:[~2016-05-15  3:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-15  3:19 [PATCH perf/core v8 00/16] perf-probe --cache and SDT support Masami Hiramatsu
2016-05-15  3:19 ` Masami Hiramatsu [this message]
2016-05-20  6:44   ` [tip:perf/urgent] perf symbols: Introduce DSO__NAME_KALLSYMS and DSO__NAME_KCORE tip-bot for Masami Hiramatsu
2016-05-15  3:19 ` [PATCH perf/core v8 02/16] perf symbol: Cleanup the code flow of dso__find_kallsyms Masami Hiramatsu
2016-05-16 13:30   ` Arnaldo Carvalho de Melo
2016-05-15  3:20 ` [PATCH perf/core v8 03/16] perf-buildid-cache: Use path/to/bin/buildid/elf instead of path/to/bin/buildid Masami Hiramatsu
2016-05-15  3:20 ` [PATCH perf/core v8 04/16] perf probe: Add --cache option to cache the probe definitions Masami Hiramatsu
2016-05-15  3:20 ` [PATCH perf/core v8 05/16] perf probe: Use cache entry if possible Masami Hiramatsu
2016-05-15  3:20 ` [PATCH perf/core v8 06/16] perf probe: Show all cached probes Masami Hiramatsu
2016-05-15  3:20 ` [PATCH perf/core v8 07/16] perf probe: Remove caches when --cache is given Masami Hiramatsu
2016-05-19  0:45   ` Hemant Kumar
2016-05-19  5:21     ` Masami Hiramatsu
2016-05-15  3:21 ` [PATCH perf/core v8 08/16] perf/sdt: ELF support for SDT Masami Hiramatsu
2016-05-15  3:21 ` [PATCH perf/core v8 09/16] perf probe: Add group name support Masami Hiramatsu
2016-05-15  3:21 ` [PATCH perf/core v8 10/16] perf buildid-cache: Scan and import user SDT events to probe cache Masami Hiramatsu
2016-05-15  3:21 ` [PATCH perf/core v8 11/16] perf probe: Accept %sdt and %cached event name Masami Hiramatsu
2016-05-15  3:21 ` [PATCH perf/core v8 12/16] perf-list: Show SDT and pre-cached events Masami Hiramatsu
2016-05-20  2:48   ` Hemant Kumar
2016-05-15  3:21 ` [PATCH perf/core v8 13/16] perf-list: Skip SDTs placed in invalid binaries Masami Hiramatsu
2016-05-15  3:21 ` [PATCH perf/core v8 14/16] perf probe: Allow wildcard for cached events Masami Hiramatsu
2016-05-15  3:22 ` [PATCH perf/core v8 15/16] perf probe: Support @BUILDID or @FILE suffix for SDT events Masami Hiramatsu
2016-05-15  3:22 ` [PATCH perf/core v8 16/16] perf probe: Support a special SDT probe format Masami Hiramatsu
2016-05-20  4:51 ` [PATCH perf/core v8 00/16] perf-probe --cache and SDT support Hemant Kumar
2016-05-20 11:03   ` Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160515031935.4017.50971.stgit@devbox \
    --to=mhiramat@kernel.org \
    --cc=acme@kernel.org \
    --cc=ananth@linux.vnet.ibm.com \
    --cc=brendan.d.gregg@gmail.com \
    --cc=hemant@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.