* [PATCH 1/2] perf buildid-cache: Add --update option
@ 2012-11-20 4:47 Namhyung Kim
2012-11-20 4:47 ` [PATCH 2/2] perf annotate: Fix warning message on vmlinux Namhyung Kim
0 siblings, 1 reply; 2+ messages in thread
From: Namhyung Kim @ 2012-11-20 4:47 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim
From: Namhyung Kim <namhyung.kim@lge.com>
When adding vmlinux file to build-id cache, it'd be fail since
kallsyms dso with a same build-id was already added by perf record.
So one needs to remove the kallsyms first to add vmlinux into the
cache. Add --update option for doing it at once.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/Documentation/perf-buildid-cache.txt | 4 ++
tools/perf/builtin-buildid-cache.c | 49 ++++++++++++++++++++++++-
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt
index c1057701a7dc..3b0caf745964 100644
--- a/tools/perf/Documentation/perf-buildid-cache.txt
+++ b/tools/perf/Documentation/perf-buildid-cache.txt
@@ -24,6 +24,10 @@ OPTIONS
-r::
--remove=::
Remove specified file from the cache.
+-u::
+--update::
+ Update specified file of the cache. It can be used to update kallsyms
+ kernel dso to vmlinux in order to support annotation.
-v::
--verbose::
Be more verbose.
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index fae8b250b2ca..855d9941f49a 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -58,6 +58,32 @@ static int build_id_cache__remove_file(const char *filename,
return err;
}
+static int build_id_cache__update_file(const char *filename,
+ const char *debugdir)
+{
+ u8 build_id[BUILD_ID_SIZE];
+ char sbuild_id[BUILD_ID_SIZE * 2 + 1];
+
+ int err;
+
+ if (filename__read_build_id(filename, &build_id, sizeof(build_id)) < 0) {
+ pr_debug("Couldn't read a build-id in %s\n", filename);
+ return -1;
+ }
+
+ build_id__sprintf(build_id, sizeof(build_id), sbuild_id);
+ err = build_id_cache__remove_s(sbuild_id, debugdir);
+ if (!err) {
+ err = build_id_cache__add_s(sbuild_id, debugdir, filename,
+ false, false);
+ }
+ if (verbose)
+ pr_info("Updating %s %s: %s\n", sbuild_id, filename,
+ err ? "FAIL" : "Ok");
+
+ return err;
+}
+
int cmd_buildid_cache(int argc, const char **argv,
const char *prefix __maybe_unused)
{
@@ -65,12 +91,15 @@ int cmd_buildid_cache(int argc, const char **argv,
struct str_node *pos;
char debugdir[PATH_MAX];
char const *add_name_list_str = NULL,
- *remove_name_list_str = NULL;
+ *remove_name_list_str = NULL,
+ *update_name_list_str = NULL;
const struct option buildid_cache_options[] = {
OPT_STRING('a', "add", &add_name_list_str,
"file list", "file(s) to add"),
OPT_STRING('r', "remove", &remove_name_list_str, "file list",
"file(s) to remove"),
+ OPT_STRING('u', "update", &update_name_list_str, "file list",
+ "file(s) to update"),
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
OPT_END()
};
@@ -125,5 +154,23 @@ int cmd_buildid_cache(int argc, const char **argv,
}
}
+ if (update_name_list_str) {
+ list = strlist__new(true, update_name_list_str);
+ if (list) {
+ strlist__for_each(pos, list)
+ if (build_id_cache__update_file(pos->s, debugdir)) {
+ if (errno == ENOENT) {
+ pr_debug("%s wasn't in the cache\n",
+ pos->s);
+ continue;
+ }
+ pr_warning("Couldn't update %s: %s\n",
+ pos->s, strerror(errno));
+ }
+
+ strlist__delete(list);
+ }
+ }
+
return 0;
}
--
1.7.11.7
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 2/2] perf annotate: Fix warning message on vmlinux
2012-11-20 4:47 [PATCH 1/2] perf buildid-cache: Add --update option Namhyung Kim
@ 2012-11-20 4:47 ` Namhyung Kim
0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2012-11-20 4:47 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim
From: Namhyung Kim <namhyung.kim@lge.com>
When perf report runs with perf.data which was recorded on a different
kernel, it fails to run annotate browser with the kernel symbol and it
recommends to run perf buildid-cache with proper vmlinux.
But running perf buildid-cache -av vmlinux as the message gives me
a following error:
$ perf buildid-cache -av /home/namhyung/build/kernel/vmlinux
Couldn't add v: No such file or directory
Since the -a option receives a parameter, 'v' should not be after the
option.
In addition -a option is not work for this case since the build-id
cache already has a kallsyms with same build-id so it'll fail with
EEXIST. Use recently added -u (--update) option for it.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/annotate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 07aaeea60000..d33fe937e6f1 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -809,7 +809,7 @@ fallback:
pr_err("Can't annotate %s:\n\n"
"No vmlinux file%s\nwas found in the path.\n\n"
"Please use:\n\n"
- " perf buildid-cache -av vmlinux\n\n"
+ " perf buildid-cache -vu vmlinux\n\n"
"or:\n\n"
" --vmlinux vmlinux\n",
sym->name, build_id_msg ?: "");
--
1.7.11.7
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-20 4:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-20 4:47 [PATCH 1/2] perf buildid-cache: Add --update option Namhyung Kim
2012-11-20 4:47 ` [PATCH 2/2] perf annotate: Fix warning message on vmlinux Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®