diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2013-02-07 04:02:11 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-02-14 12:59:27 -0500 |
commit | eeb49845425375481f14c0e5721f88242642e88e (patch) | |
tree | 270a3922425ca32771d1777bf1fbab46e8166585 /tools | |
parent | a3d4fd7a2d81604fedfa270d29c824b8d3380c2e (diff) |
perf buildid-cache: Add --update option
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>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1360227734-375-5-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Documentation/perf-buildid-cache.txt | 4 | ||||
-rw-r--r-- | tools/perf/builtin-buildid-cache.c | 50 |
2 files changed, 53 insertions, 1 deletions
diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt index 8e798baae0fd..e9a8349a7172 100644 --- a/tools/perf/Documentation/perf-buildid-cache.txt +++ b/tools/perf/Documentation/perf-buildid-cache.txt | |||
@@ -27,6 +27,10 @@ OPTIONS | |||
27 | -M:: | 27 | -M:: |
28 | --missing=:: | 28 | --missing=:: |
29 | List missing build ids in the cache for the specified file. | 29 | List missing build ids in the cache for the specified file. |
30 | -u:: | ||
31 | --update:: | ||
32 | Update specified file of the cache. It can be used to update kallsyms | ||
33 | kernel dso to vmlinux in order to support annotation. | ||
30 | -v:: | 34 | -v:: |
31 | --verbose:: | 35 | --verbose:: |
32 | Be more verbose. | 36 | Be more verbose. |
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index a336014e0286..c96c8fa38243 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c | |||
@@ -93,6 +93,32 @@ static int build_id_cache__fprintf_missing(const char *filename, bool force, FIL | |||
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
95 | 95 | ||
96 | static int build_id_cache__update_file(const char *filename, | ||
97 | const char *debugdir) | ||
98 | { | ||
99 | u8 build_id[BUILD_ID_SIZE]; | ||
100 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; | ||
101 | |||
102 | int err; | ||
103 | |||
104 | if (filename__read_build_id(filename, &build_id, sizeof(build_id)) < 0) { | ||
105 | pr_debug("Couldn't read a build-id in %s\n", filename); | ||
106 | return -1; | ||
107 | } | ||
108 | |||
109 | build_id__sprintf(build_id, sizeof(build_id), sbuild_id); | ||
110 | err = build_id_cache__remove_s(sbuild_id, debugdir); | ||
111 | if (!err) { | ||
112 | err = build_id_cache__add_s(sbuild_id, debugdir, filename, | ||
113 | false, false); | ||
114 | } | ||
115 | if (verbose) | ||
116 | pr_info("Updating %s %s: %s\n", sbuild_id, filename, | ||
117 | err ? "FAIL" : "Ok"); | ||
118 | |||
119 | return err; | ||
120 | } | ||
121 | |||
96 | int cmd_buildid_cache(int argc, const char **argv, | 122 | int cmd_buildid_cache(int argc, const char **argv, |
97 | const char *prefix __maybe_unused) | 123 | const char *prefix __maybe_unused) |
98 | { | 124 | { |
@@ -103,7 +129,9 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
103 | char debugdir[PATH_MAX]; | 129 | char debugdir[PATH_MAX]; |
104 | char const *add_name_list_str = NULL, | 130 | char const *add_name_list_str = NULL, |
105 | *remove_name_list_str = NULL, | 131 | *remove_name_list_str = NULL, |
106 | *missing_filename = NULL; | 132 | *missing_filename = NULL, |
133 | *update_name_list_str = NULL; | ||
134 | |||
107 | const struct option buildid_cache_options[] = { | 135 | const struct option buildid_cache_options[] = { |
108 | OPT_STRING('a', "add", &add_name_list_str, | 136 | OPT_STRING('a', "add", &add_name_list_str, |
109 | "file list", "file(s) to add"), | 137 | "file list", "file(s) to add"), |
@@ -112,6 +140,8 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
112 | OPT_STRING('M', "missing", &missing_filename, "file", | 140 | OPT_STRING('M', "missing", &missing_filename, "file", |
113 | "to find missing build ids in the cache"), | 141 | "to find missing build ids in the cache"), |
114 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | 142 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), |
143 | OPT_STRING('u', "update", &update_name_list_str, "file list", | ||
144 | "file(s) to update"), | ||
115 | OPT_INCR('v', "verbose", &verbose, "be more verbose"), | 145 | OPT_INCR('v', "verbose", &verbose, "be more verbose"), |
116 | OPT_END() | 146 | OPT_END() |
117 | }; | 147 | }; |
@@ -169,5 +199,23 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
169 | if (missing_filename) | 199 | if (missing_filename) |
170 | ret = build_id_cache__fprintf_missing(missing_filename, force, stdout); | 200 | ret = build_id_cache__fprintf_missing(missing_filename, force, stdout); |
171 | 201 | ||
202 | if (update_name_list_str) { | ||
203 | list = strlist__new(true, update_name_list_str); | ||
204 | if (list) { | ||
205 | strlist__for_each(pos, list) | ||
206 | if (build_id_cache__update_file(pos->s, debugdir)) { | ||
207 | if (errno == ENOENT) { | ||
208 | pr_debug("%s wasn't in the cache\n", | ||
209 | pos->s); | ||
210 | continue; | ||
211 | } | ||
212 | pr_warning("Couldn't update %s: %s\n", | ||
213 | pos->s, strerror(errno)); | ||
214 | } | ||
215 | |||
216 | strlist__delete(list); | ||
217 | } | ||
218 | } | ||
219 | |||
172 | return ret; | 220 | return ret; |
173 | } | 221 | } |