aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Documentation/perf-buildid-cache.txt11
-rw-r--r--tools/perf/builtin-buildid-cache.c6
-rw-r--r--tools/perf/util/build-id.c12
-rw-r--r--tools/perf/util/build-id.h1
4 files changed, 25 insertions, 5 deletions
diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt
index 0294c57b1f5e..cec6b57e8be6 100644
--- a/tools/perf/Documentation/perf-buildid-cache.txt
+++ b/tools/perf/Documentation/perf-buildid-cache.txt
@@ -41,9 +41,14 @@ OPTIONS
41--missing=:: 41--missing=::
42 List missing build ids in the cache for the specified file. 42 List missing build ids in the cache for the specified file.
43-u:: 43-u::
44--update:: 44--update=::
45 Update specified file of the cache. It can be used to update kallsyms 45 Update specified file of the cache. Note that this doesn't remove
46 kernel dso to vmlinux in order to support annotation. 46 older entires since those may be still needed for annotating old
47 (or remote) perf.data. Only if there is already a cache which has
48 exactly same build-id, that is replaced by new one. It can be used
49 to update kallsyms and kernel dso to vmlinux in order to support
50 annotation.
51
47-v:: 52-v::
48--verbose:: 53--verbose::
49 Be more verbose. 54 Be more verbose.
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index d929d9544664..e7568f5844ad 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -255,7 +255,7 @@ static int build_id_cache__update_file(const char *filename)
255 u8 build_id[BUILD_ID_SIZE]; 255 u8 build_id[BUILD_ID_SIZE];
256 char sbuild_id[BUILD_ID_SIZE * 2 + 1]; 256 char sbuild_id[BUILD_ID_SIZE * 2 + 1];
257 257
258 int err; 258 int err = 0;
259 259
260 if (filename__read_build_id(filename, &build_id, sizeof(build_id)) < 0) { 260 if (filename__read_build_id(filename, &build_id, sizeof(build_id)) < 0) {
261 pr_debug("Couldn't read a build-id in %s\n", filename); 261 pr_debug("Couldn't read a build-id in %s\n", filename);
@@ -263,7 +263,9 @@ static int build_id_cache__update_file(const char *filename)
263 } 263 }
264 264
265 build_id__sprintf(build_id, sizeof(build_id), sbuild_id); 265 build_id__sprintf(build_id, sizeof(build_id), sbuild_id);
266 err = build_id_cache__remove_s(sbuild_id); 266 if (build_id_cache__cached(sbuild_id))
267 err = build_id_cache__remove_s(sbuild_id);
268
267 if (!err) 269 if (!err)
268 err = build_id_cache__add_s(sbuild_id, filename, false, false); 270 err = build_id_cache__add_s(sbuild_id, filename, false, false);
269 271
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index adbc36028636..0bc33be5a78c 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -352,6 +352,18 @@ static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size,
352 return build_id_cache__add_s(sbuild_id, name, is_kallsyms, is_vdso); 352 return build_id_cache__add_s(sbuild_id, name, is_kallsyms, is_vdso);
353} 353}
354 354
355bool build_id_cache__cached(const char *sbuild_id)
356{
357 bool ret = false;
358 char *filename = build_id__filename(sbuild_id, NULL, 0);
359
360 if (filename && !access(filename, F_OK))
361 ret = true;
362 free(filename);
363
364 return ret;
365}
366
355int build_id_cache__remove_s(const char *sbuild_id) 367int build_id_cache__remove_s(const char *sbuild_id)
356{ 368{
357 const size_t size = PATH_MAX; 369 const size_t size = PATH_MAX;
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index 31b3c6332a1a..2a094982f954 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -22,6 +22,7 @@ bool perf_session__read_build_ids(struct perf_session *session, bool with_hits);
22int perf_session__write_buildid_table(struct perf_session *session, int fd); 22int perf_session__write_buildid_table(struct perf_session *session, int fd);
23int perf_session__cache_build_ids(struct perf_session *session); 23int perf_session__cache_build_ids(struct perf_session *session);
24 24
25bool build_id_cache__cached(const char *sbuild_id);
25int build_id_cache__add_s(const char *sbuild_id, 26int build_id_cache__add_s(const char *sbuild_id,
26 const char *name, bool is_kallsyms, bool is_vdso); 27 const char *name, bool is_kallsyms, bool is_vdso);
27int build_id_cache__remove_s(const char *sbuild_id); 28int build_id_cache__remove_s(const char *sbuild_id);