2010-02-03 21:52:04 +03:00
|
|
|
/*
|
|
|
|
* build-id.c
|
|
|
|
*
|
|
|
|
* build-id support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009, 2010 Red Hat Inc.
|
|
|
|
* Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <acme@redhat.com>
|
|
|
|
*/
|
2010-05-20 19:15:33 +04:00
|
|
|
#include "util.h"
|
|
|
|
#include <stdio.h>
|
2010-02-03 21:52:04 +03:00
|
|
|
#include "build-id.h"
|
|
|
|
#include "event.h"
|
|
|
|
#include "symbol.h"
|
|
|
|
#include <linux/kernel.h>
|
2010-07-31 01:28:42 +04:00
|
|
|
#include "debug.h"
|
2011-11-25 14:19:45 +04:00
|
|
|
#include "session.h"
|
2011-11-28 14:30:20 +04:00
|
|
|
#include "tool.h"
|
2010-02-03 21:52:04 +03:00
|
|
|
|
2012-08-07 16:56:05 +04:00
|
|
|
int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
|
|
|
|
union perf_event *event,
|
2013-08-27 12:23:06 +04:00
|
|
|
struct perf_sample *sample,
|
2012-08-07 16:56:05 +04:00
|
|
|
struct perf_evsel *evsel __maybe_unused,
|
|
|
|
struct machine *machine)
|
2010-02-03 21:52:04 +03:00
|
|
|
{
|
|
|
|
struct addr_location al;
|
|
|
|
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
|
2013-08-27 12:23:06 +04:00
|
|
|
struct thread *thread = machine__findnew_thread(machine, sample->pid,
|
|
|
|
sample->pid);
|
2010-02-03 21:52:04 +03:00
|
|
|
|
|
|
|
if (thread == NULL) {
|
|
|
|
pr_err("problem processing %d event, skipping it.\n",
|
|
|
|
event->header.type);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-11-28 13:56:39 +04:00
|
|
|
thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION,
|
2013-08-27 12:23:06 +04:00
|
|
|
sample->ip, &al);
|
2010-02-03 21:52:04 +03:00
|
|
|
|
|
|
|
if (al.map != NULL)
|
|
|
|
al.map->dso->hit = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-11 02:15:03 +04:00
|
|
|
static int perf_event__exit_del_thread(struct perf_tool *tool __maybe_unused,
|
2011-11-25 14:19:45 +04:00
|
|
|
union perf_event *event,
|
2012-09-11 02:15:03 +04:00
|
|
|
struct perf_sample *sample
|
|
|
|
__maybe_unused,
|
2011-11-28 13:56:39 +04:00
|
|
|
struct machine *machine)
|
2010-07-31 01:28:42 +04:00
|
|
|
{
|
2013-08-27 12:23:03 +04:00
|
|
|
struct thread *thread = machine__findnew_thread(machine,
|
|
|
|
event->fork.pid,
|
|
|
|
event->fork.tid);
|
2010-07-31 01:28:42 +04:00
|
|
|
|
2011-01-29 19:01:45 +03:00
|
|
|
dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
|
|
|
|
event->fork.ppid, event->fork.ptid);
|
2010-07-31 01:28:42 +04:00
|
|
|
|
|
|
|
if (thread) {
|
2011-11-28 13:56:39 +04:00
|
|
|
rb_erase(&thread->rb_node, &machine->threads);
|
|
|
|
machine->last_match = NULL;
|
2010-07-31 01:28:42 +04:00
|
|
|
thread__delete(thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-28 14:30:20 +04:00
|
|
|
struct perf_tool build_id__mark_dso_hit_ops = {
|
2010-02-03 21:52:04 +03:00
|
|
|
.sample = build_id__mark_dso_hit,
|
2011-01-29 19:01:45 +03:00
|
|
|
.mmap = perf_event__process_mmap,
|
2012-10-06 22:44:59 +04:00
|
|
|
.fork = perf_event__process_fork,
|
2011-01-29 19:01:45 +03:00
|
|
|
.exit = perf_event__exit_del_thread,
|
2012-05-15 15:28:15 +04:00
|
|
|
.attr = perf_event__process_attr,
|
|
|
|
.build_id = perf_event__process_build_id,
|
2010-02-03 21:52:04 +03:00
|
|
|
};
|
2010-05-20 19:15:33 +04:00
|
|
|
|
2012-10-28 01:18:28 +04:00
|
|
|
int build_id__sprintf(const u8 *build_id, int len, char *bf)
|
|
|
|
{
|
|
|
|
char *bid = bf;
|
|
|
|
const u8 *raw = build_id;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; ++i) {
|
|
|
|
sprintf(bid, "%02x", *raw);
|
|
|
|
++raw;
|
|
|
|
bid += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return raw - build_id;
|
|
|
|
}
|
|
|
|
|
2010-05-20 19:15:33 +04:00
|
|
|
char *dso__build_id_filename(struct dso *self, char *bf, size_t size)
|
|
|
|
{
|
|
|
|
char build_id_hex[BUILD_ID_SIZE * 2 + 1];
|
|
|
|
|
|
|
|
if (!self->has_build_id)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
build_id__sprintf(self->build_id, sizeof(self->build_id), build_id_hex);
|
|
|
|
if (bf == NULL) {
|
perf buildid: add perfconfig option to specify buildid cache dir
This patch adds the ability to specify an alternate directory to store the
buildid cache (buildids, copy of binaries). By default, it is hardcoded to
$HOME/.debug. This directory contains immutable data. The layout of the
directory is such that no conflicts in filenames are possible. A modification
in a file, yields a different buildid and thus a different location in the
subdir hierarchy.
You may want to put the buildid cache elsewhere because of disk space
limitation or simply to share the cache between users. It is also useful for
remote collect vs. local analysis of profiles.
This patch adds a new config option to the perfconfig file. Under the tag
'buildid', there is a dir option. For instance, if you have:
$ cat /etc/perfconfig
[buildid]
dir = /var/cache/perf-buildid
All buildids and binaries are be saved in the directory specified. The perf
record, buildid-list, buildid-cache, report, annotate, and archive commands
will it to pull information out.
The option can be set in the system-wide perfconfig file or in the
$HOME/.perfconfig file.
Cc: David S. Miller <davem@davemloft.net>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <4c055fb7.df0ce30a.5f0d.ffffae52@mx.google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-06-01 23:25:01 +04:00
|
|
|
if (asprintf(&bf, "%s/.build-id/%.2s/%s", buildid_dir,
|
|
|
|
build_id_hex, build_id_hex + 2) < 0)
|
2010-05-20 19:15:33 +04:00
|
|
|
return NULL;
|
|
|
|
} else
|
perf buildid: add perfconfig option to specify buildid cache dir
This patch adds the ability to specify an alternate directory to store the
buildid cache (buildids, copy of binaries). By default, it is hardcoded to
$HOME/.debug. This directory contains immutable data. The layout of the
directory is such that no conflicts in filenames are possible. A modification
in a file, yields a different buildid and thus a different location in the
subdir hierarchy.
You may want to put the buildid cache elsewhere because of disk space
limitation or simply to share the cache between users. It is also useful for
remote collect vs. local analysis of profiles.
This patch adds a new config option to the perfconfig file. Under the tag
'buildid', there is a dir option. For instance, if you have:
$ cat /etc/perfconfig
[buildid]
dir = /var/cache/perf-buildid
All buildids and binaries are be saved in the directory specified. The perf
record, buildid-list, buildid-cache, report, annotate, and archive commands
will it to pull information out.
The option can be set in the system-wide perfconfig file or in the
$HOME/.perfconfig file.
Cc: David S. Miller <davem@davemloft.net>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <4c055fb7.df0ce30a.5f0d.ffffae52@mx.google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-06-01 23:25:01 +04:00
|
|
|
snprintf(bf, size, "%s/.build-id/%.2s/%s", buildid_dir,
|
|
|
|
build_id_hex, build_id_hex + 2);
|
2010-05-20 19:15:33 +04:00
|
|
|
return bf;
|
|
|
|
}
|