From 5237ada4fe6dea492c3dafa7522ab836b270643c Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Thu, 7 Feb 2013 18:02:11 +0900 Subject: [PATCH] --- yaml --- r: 350111 b: refs/heads/master c: eeb49845425375481f14c0e5721f88242642e88e h: refs/heads/master i: 350109: fdbac618eee8ab0297a34eb2b28829eb05560e96 350107: 0bdeb673181d65ca7db38b2122a5150594859a52 350103: 611e1345e51f3c9214d5f5332f3a610dcd77c994 350095: c9ec5bf127874b0e8c633488caebeb85593d4fac 350079: d406930bb4190f5ee38efa5f5aa031e74c5c6b9c v: v3 --- [refs] | 2 +- .../perf/Documentation/perf-buildid-cache.txt | 4 ++ trunk/tools/perf/builtin-buildid-cache.c | 50 ++++++++++++++++++- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 3f0de9a45de7..d612d23a44fa 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a3d4fd7a2d81604fedfa270d29c824b8d3380c2e +refs/heads/master: eeb49845425375481f14c0e5721f88242642e88e diff --git a/trunk/tools/perf/Documentation/perf-buildid-cache.txt b/trunk/tools/perf/Documentation/perf-buildid-cache.txt index 8e798baae0fd..e9a8349a7172 100644 --- a/trunk/tools/perf/Documentation/perf-buildid-cache.txt +++ b/trunk/tools/perf/Documentation/perf-buildid-cache.txt @@ -27,6 +27,10 @@ OPTIONS -M:: --missing=:: List missing build ids in the cache for the specified file. +-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/trunk/tools/perf/builtin-buildid-cache.c b/trunk/tools/perf/builtin-buildid-cache.c index a336014e0286..c96c8fa38243 100644 --- a/trunk/tools/perf/builtin-buildid-cache.c +++ b/trunk/tools/perf/builtin-buildid-cache.c @@ -93,6 +93,32 @@ static int build_id_cache__fprintf_missing(const char *filename, bool force, FIL return 0; } +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) { @@ -103,7 +129,9 @@ int cmd_buildid_cache(int argc, const char **argv, char debugdir[PATH_MAX]; char const *add_name_list_str = NULL, *remove_name_list_str = NULL, - *missing_filename = NULL; + *missing_filename = 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"), @@ -112,6 +140,8 @@ int cmd_buildid_cache(int argc, const char **argv, OPT_STRING('M', "missing", &missing_filename, "file", "to find missing build ids in the cache"), OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), + OPT_STRING('u', "update", &update_name_list_str, "file list", + "file(s) to update"), OPT_INCR('v', "verbose", &verbose, "be more verbose"), OPT_END() }; @@ -169,5 +199,23 @@ int cmd_buildid_cache(int argc, const char **argv, if (missing_filename) ret = build_id_cache__fprintf_missing(missing_filename, force, stdout); + 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 ret; }