aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/build-id.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/build-id.c')
-rw-r--r--tools/perf/util/build-id.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 0f60a3906808..70c5cf87d020 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -6,6 +6,8 @@
6 * Copyright (C) 2009, 2010 Red Hat Inc. 6 * Copyright (C) 2009, 2010 Red Hat Inc.
7 * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <acme@redhat.com> 7 * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <acme@redhat.com>
8 */ 8 */
9#include "util.h"
10#include <stdio.h>
9#include "build-id.h" 11#include "build-id.h"
10#include "event.h" 12#include "event.h"
11#include "symbol.h" 13#include "symbol.h"
@@ -37,3 +39,23 @@ struct perf_event_ops build_id__mark_dso_hit_ops = {
37 .mmap = event__process_mmap, 39 .mmap = event__process_mmap,
38 .fork = event__process_task, 40 .fork = event__process_task,
39}; 41};
42
43char *dso__build_id_filename(struct dso *self, char *bf, size_t size)
44{
45 char build_id_hex[BUILD_ID_SIZE * 2 + 1];
46 const char *home;
47
48 if (!self->has_build_id)
49 return NULL;
50
51 build_id__sprintf(self->build_id, sizeof(self->build_id), build_id_hex);
52 home = getenv("HOME");
53 if (bf == NULL) {
54 if (asprintf(&bf, "%s/%s/.build-id/%.2s/%s", home,
55 DEBUG_CACHE_DIR, build_id_hex, build_id_hex + 2) < 0)
56 return NULL;
57 } else
58 snprintf(bf, size, "%s/%s/.build-id/%.2s/%s", home,
59 DEBUG_CACHE_DIR, build_id_hex, build_id_hex + 2);
60 return bf;
61}