aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-12-07 14:28:27 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-12-09 06:46:08 -0500
commitfbb6976c2f7a6ab2c4d8511181d686f5f2aaf476 (patch)
treee4fab6b002a79a4479370da7432618e66fdd895a /tools/perf
parent417c2ff6806fd9183cb36682dcf32c4d068aba5e (diff)
perf buildid-cache: Add option to show build ids that are missing in the cache
This will allow to connect with services being put in place by distros such as Fedora, where one can retrieve DSOs by their build-id. Example usage: for buildid in $(perf buildid-cache --missing perf.data | cut -d' ' -f1) ; do echo "trying to get $buildid" wget -q https://darkserver.fedoraproject.org/buildids/$buildid cat $buildid ; echo rm -f $buildid done Now its just a matter of some porcelain to get the details provided by such a service, retrieve the file and use 'perf buildid-cache --add $FILE' to insert it in the cache, then use 'perf report' or 'annotate' that will find the required files in the cache. More information about the darkserver service at: https://darkserver.fedoraproject.org/ Cc: David Ahern <dsahern@gmail.com> Cc: Frank Eigler <fche@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kushal Das <kdas@redhat.com> Cc: Mark Wielaard <mjw@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-6fuktuiyjn4jykxmt7c9f7xq@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Documentation/perf-buildid-cache.txt3
-rw-r--r--tools/perf/builtin-buildid-cache.c48
2 files changed, 49 insertions, 2 deletions
diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt
index c1057701a7dc..8e798baae0fd 100644
--- a/tools/perf/Documentation/perf-buildid-cache.txt
+++ b/tools/perf/Documentation/perf-buildid-cache.txt
@@ -24,6 +24,9 @@ OPTIONS
24-r:: 24-r::
25--remove=:: 25--remove=::
26 Remove specified file from the cache. 26 Remove specified file from the cache.
27-M::
28--missing=::
29 List missing build ids in the cache for the specified file.
27-v:: 30-v::
28--verbose:: 31--verbose::
29 Be more verbose. 32 Be more verbose.
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index fae8b250b2ca..a336014e0286 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -14,6 +14,7 @@
14#include "util/parse-options.h" 14#include "util/parse-options.h"
15#include "util/strlist.h" 15#include "util/strlist.h"
16#include "util/build-id.h" 16#include "util/build-id.h"
17#include "util/session.h"
17#include "util/symbol.h" 18#include "util/symbol.h"
18 19
19static int build_id_cache__add_file(const char *filename, const char *debugdir) 20static int build_id_cache__add_file(const char *filename, const char *debugdir)
@@ -58,19 +59,59 @@ static int build_id_cache__remove_file(const char *filename,
58 return err; 59 return err;
59} 60}
60 61
62static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused)
63{
64 char filename[PATH_MAX];
65 u8 build_id[BUILD_ID_SIZE];
66
67 if (dso__build_id_filename(dso, filename, sizeof(filename)) &&
68 filename__read_build_id(filename, build_id,
69 sizeof(build_id)) != sizeof(build_id)) {
70 if (errno == ENOENT)
71 return false;
72
73 pr_warning("Problems with %s file, consider removing it from the cache\n",
74 filename);
75 } else if (memcmp(dso->build_id, build_id, sizeof(dso->build_id))) {
76 pr_warning("Problems with %s file, consider removing it from the cache\n",
77 filename);
78 }
79
80 return true;
81}
82
83static int build_id_cache__fprintf_missing(const char *filename, bool force, FILE *fp)
84{
85 struct perf_session *session = perf_session__new(filename, O_RDONLY,
86 force, false, NULL);
87 if (session == NULL)
88 return -1;
89
90 perf_session__fprintf_dsos_buildid(session, fp, dso__missing_buildid_cache, 0);
91 perf_session__delete(session);
92
93 return 0;
94}
95
61int cmd_buildid_cache(int argc, const char **argv, 96int cmd_buildid_cache(int argc, const char **argv,
62 const char *prefix __maybe_unused) 97 const char *prefix __maybe_unused)
63{ 98{
64 struct strlist *list; 99 struct strlist *list;
65 struct str_node *pos; 100 struct str_node *pos;
101 int ret = 0;
102 bool force = false;
66 char debugdir[PATH_MAX]; 103 char debugdir[PATH_MAX];
67 char const *add_name_list_str = NULL, 104 char const *add_name_list_str = NULL,
68 *remove_name_list_str = NULL; 105 *remove_name_list_str = NULL,
106 *missing_filename = NULL;
69 const struct option buildid_cache_options[] = { 107 const struct option buildid_cache_options[] = {
70 OPT_STRING('a', "add", &add_name_list_str, 108 OPT_STRING('a', "add", &add_name_list_str,
71 "file list", "file(s) to add"), 109 "file list", "file(s) to add"),
72 OPT_STRING('r', "remove", &remove_name_list_str, "file list", 110 OPT_STRING('r', "remove", &remove_name_list_str, "file list",
73 "file(s) to remove"), 111 "file(s) to remove"),
112 OPT_STRING('M', "missing", &missing_filename, "file",
113 "to find missing build ids in the cache"),
114 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
74 OPT_INCR('v', "verbose", &verbose, "be more verbose"), 115 OPT_INCR('v', "verbose", &verbose, "be more verbose"),
75 OPT_END() 116 OPT_END()
76 }; 117 };
@@ -125,5 +166,8 @@ int cmd_buildid_cache(int argc, const char **argv,
125 } 166 }
126 } 167 }
127 168
128 return 0; 169 if (missing_filename)
170 ret = build_id_cache__fprintf_missing(missing_filename, force, stdout);
171
172 return ret;
129} 173}