2010-02-04 02:52:04 +08: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 23:15:33 +08:00
|
|
|
#include "util.h"
|
|
|
|
#include <stdio.h>
|
2010-02-04 02:52:04 +08:00
|
|
|
#include "build-id.h"
|
|
|
|
#include "event.h"
|
|
|
|
#include "symbol.h"
|
|
|
|
#include <linux/kernel.h>
|
2010-07-31 05:28:42 +08:00
|
|
|
#include "debug.h"
|
2011-11-25 18:19:45 +08:00
|
|
|
#include "session.h"
|
2011-11-28 18:30:20 +08:00
|
|
|
#include "tool.h"
|
2010-02-04 02:52:04 +08:00
|
|
|
|
2012-08-07 20:56:05 +08:00
|
|
|
int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
|
|
|
|
union perf_event *event,
|
|
|
|
struct perf_sample *sample __maybe_unused,
|
|
|
|
struct perf_evsel *evsel __maybe_unused,
|
|
|
|
struct machine *machine)
|
2010-02-04 02:52:04 +08:00
|
|
|
{
|
|
|
|
struct addr_location al;
|
|
|
|
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
|
2011-11-28 17:56:39 +08:00
|
|
|
struct thread *thread = machine__findnew_thread(machine, event->ip.pid);
|
2010-02-04 02:52:04 +08:00
|
|
|
|
|
|
|
if (thread == NULL) {
|
|
|
|
pr_err("problem processing %d event, skipping it.\n",
|
|
|
|
event->header.type);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-11-28 17:56:39 +08:00
|
|
|
thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION,
|
|
|
|
event->ip.ip, &al);
|
2010-02-04 02:52:04 +08:00
|
|
|
|
|
|
|
if (al.map != NULL)
|
|
|
|
al.map->dso->hit = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-11 06:15:03 +08:00
|
|
|
static int perf_event__exit_del_thread(struct perf_tool *tool __maybe_unused,
|
2011-11-25 18:19:45 +08:00
|
|
|
union perf_event *event,
|
2012-09-11 06:15:03 +08:00
|
|
|
struct perf_sample *sample
|
|
|
|
__maybe_unused,
|
2011-11-28 17:56:39 +08:00
|
|
|
struct machine *machine)
|
2010-07-31 05:28:42 +08:00
|
|
|
{
|
2011-11-28 17:56:39 +08:00
|
|
|
struct thread *thread = machine__findnew_thread(machine, event->fork.tid);
|
2010-07-31 05:28:42 +08:00
|
|
|
|
2011-01-30 00:01:45 +08:00
|
|
|
dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
|
|
|
|
event->fork.ppid, event->fork.ptid);
|
2010-07-31 05:28:42 +08:00
|
|
|
|
|
|
|
if (thread) {
|
2011-11-28 17:56:39 +08:00
|
|
|
rb_erase(&thread->rb_node, &machine->threads);
|
|
|
|
machine->last_match = NULL;
|
2010-07-31 05:28:42 +08:00
|
|
|
thread__delete(thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-28 18:30:20 +08:00
|
|
|
struct perf_tool build_id__mark_dso_hit_ops = {
|
2010-02-04 02:52:04 +08:00
|
|
|
.sample = build_id__mark_dso_hit,
|
2011-01-30 00:01:45 +08:00
|
|
|
.mmap = perf_event__process_mmap,
|
2012-10-07 02:44:59 +08:00
|
|
|
.fork = perf_event__process_fork,
|
2011-01-30 00:01:45 +08:00
|
|
|
.exit = perf_event__exit_del_thread,
|
2012-05-15 19:28:15 +08:00
|
|
|
.attr = perf_event__process_attr,
|
|
|
|
.build_id = perf_event__process_build_id,
|
2010-02-04 02:52:04 +08:00
|
|
|
};
|
2010-05-20 23:15:33 +08: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-02 03:25:01 +08:00
|
|
|
if (asprintf(&bf, "%s/.build-id/%.2s/%s", buildid_dir,
|
|
|
|
build_id_hex, build_id_hex + 2) < 0)
|
2010-05-20 23:15:33 +08: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-02 03:25:01 +08:00
|
|
|
snprintf(bf, size, "%s/.build-id/%.2s/%s", buildid_dir,
|
|
|
|
build_id_hex, build_id_hex + 2);
|
2010-05-20 23:15:33 +08:00
|
|
|
return bf;
|
|
|
|
}
|