aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-12-27 18:37:06 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-28 03:03:36 -0500
commit4cf40131a5cf4918e83b3756e58a1fc9e984f8ef (patch)
tree88df943f704ce3a52660f975195a0b4b1b91243d /tools/perf/util/symbol.c
parent55aa640f54280da25046acd2075842d464f451e6 (diff)
perf record: Introduce a symtab cache
Now a cache will be created in a ~/.debug debuginfo like hierarchy, so that at the end of a 'perf record' session all the binaries (with build-ids) involved get collected and indexed by their build-ids, so that perf report can find them. This is interesting when developing software where you want to do a 'perf diff' with the previous build and opens avenues for lots more interesting tools, like a 'perf diff --graph' that takes more than two binaries into account. Tunables for collecting just the symtabs can be added if one doesn't want to have the full binary, but having the full binary allows things like 'perf rerecord' or other tools that can re-run the tests by having access to the exact binary in some perf.data file, so it may well be interesting to keep the full binary there. Space consumption is minimised by trying to use hard links, a 'perf cache' tool to manage the space used, a la ccache is required to purge older entries. With this in place it will be possible also to introduce new commands, 'perf archive' and 'perf restore' (or some more suitable and future proof names) to create a cpio/tar file with the perf data and the files in the cache that _had_ perf hits of interest. There are more aspects to polish, like finding the right vmlinux file to cache, etc, but this is enough for a first step. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1261957026-15580-10-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r--tools/perf/util/symbol.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index ab92763edb03..79ca6a099f96 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -22,6 +22,7 @@
22enum dso_origin { 22enum dso_origin {
23 DSO__ORIG_KERNEL = 0, 23 DSO__ORIG_KERNEL = 0,
24 DSO__ORIG_JAVA_JIT, 24 DSO__ORIG_JAVA_JIT,
25 DSO__ORIG_BUILD_ID_CACHE,
25 DSO__ORIG_FEDORA, 26 DSO__ORIG_FEDORA,
26 DSO__ORIG_UBUNTU, 27 DSO__ORIG_UBUNTU,
27 DSO__ORIG_BUILDID, 28 DSO__ORIG_BUILDID,
@@ -1191,6 +1192,7 @@ char dso__symtab_origin(const struct dso *self)
1191 static const char origin[] = { 1192 static const char origin[] = {
1192 [DSO__ORIG_KERNEL] = 'k', 1193 [DSO__ORIG_KERNEL] = 'k',
1193 [DSO__ORIG_JAVA_JIT] = 'j', 1194 [DSO__ORIG_JAVA_JIT] = 'j',
1195 [DSO__ORIG_BUILD_ID_CACHE] = 'B',
1194 [DSO__ORIG_FEDORA] = 'f', 1196 [DSO__ORIG_FEDORA] = 'f',
1195 [DSO__ORIG_UBUNTU] = 'u', 1197 [DSO__ORIG_UBUNTU] = 'u',
1196 [DSO__ORIG_BUILDID] = 'b', 1198 [DSO__ORIG_BUILDID] = 'b',
@@ -1209,6 +1211,7 @@ int dso__load(struct dso *self, struct map *map, struct perf_session *session,
1209 int size = PATH_MAX; 1211 int size = PATH_MAX;
1210 char *name; 1212 char *name;
1211 u8 build_id[BUILD_ID_SIZE]; 1213 u8 build_id[BUILD_ID_SIZE];
1214 char build_id_hex[BUILD_ID_SIZE * 2 + 1];
1212 int ret = -1; 1215 int ret = -1;
1213 int fd; 1216 int fd;
1214 1217
@@ -1230,8 +1233,16 @@ int dso__load(struct dso *self, struct map *map, struct perf_session *session,
1230 return ret; 1233 return ret;
1231 } 1234 }
1232 1235
1233 self->origin = DSO__ORIG_FEDORA - 1; 1236 self->origin = DSO__ORIG_BUILD_ID_CACHE;
1234 1237
1238 if (self->has_build_id) {
1239 build_id__sprintf(self->build_id, sizeof(self->build_id),
1240 build_id_hex);
1241 snprintf(name, size, "%s/%s/.build-id/%.2s/%s",
1242 getenv("HOME"), DEBUG_CACHE_DIR,
1243 build_id_hex, build_id_hex + 2);
1244 goto open_file;
1245 }
1235more: 1246more:
1236 do { 1247 do {
1237 self->origin++; 1248 self->origin++;
@@ -1247,8 +1258,6 @@ more:
1247 case DSO__ORIG_BUILDID: 1258 case DSO__ORIG_BUILDID:
1248 if (filename__read_build_id(self->long_name, build_id, 1259 if (filename__read_build_id(self->long_name, build_id,
1249 sizeof(build_id))) { 1260 sizeof(build_id))) {
1250 char build_id_hex[BUILD_ID_SIZE * 2 + 1];
1251
1252 build_id__sprintf(build_id, sizeof(build_id), 1261 build_id__sprintf(build_id, sizeof(build_id),
1253 build_id_hex); 1262 build_id_hex);
1254 snprintf(name, size, 1263 snprintf(name, size,
@@ -1276,7 +1285,7 @@ compare_build_id:
1276 if (!dso__build_id_equal(self, build_id)) 1285 if (!dso__build_id_equal(self, build_id))
1277 goto more; 1286 goto more;
1278 } 1287 }
1279 1288open_file:
1280 fd = open(name, O_RDONLY); 1289 fd = open(name, O_RDONLY);
1281 } while (fd < 0); 1290 } while (fd < 0);
1282 1291