2010-02-03 18:52:04 +00: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 15:15:33 +00:00
|
|
|
#include "util.h"
|
|
|
|
#include <stdio.h>
|
2010-02-03 18:52:04 +00:00
|
|
|
#include "build-id.h"
|
|
|
|
#include "event.h"
|
|
|
|
#include "symbol.h"
|
|
|
|
#include <linux/kernel.h>
|
2010-07-30 21:28:42 +00:00
|
|
|
#include "debug.h"
|
2011-11-25 10:19:45 +00:00
|
|
|
#include "session.h"
|
2010-02-03 18:52:04 +00:00
|
|
|
|
2011-11-25 10:19:45 +00:00
|
|
|
static int build_id__mark_dso_hit(struct perf_event_ops *ops __used,
|
|
|
|
union perf_event *event,
|
2011-01-29 15:02:00 +00:00
|
|
|
struct perf_sample *sample __used,
|
2011-03-15 18:44:01 +00:00
|
|
|
struct perf_evsel *evsel __used,
|
perf session: Parse sample earlier
At perf_session__process_event, so that we reduce the number of lines in eache
tool sample processing routine that now receives a sample_data pointer already
parsed.
This will also be useful in the next patch, where we'll allow sample the
identity fields in MMAP, FORK, EXIT, etc, when it will be possible to see (cpu,
timestamp) just after before every event.
Also validate callchains in perf_session__process_event, i.e. as early as
possible, and keep a counter of the number of events discarded due to invalid
callchains, warning the user about it if it happens.
There is an assumption that was kept that all events have the same sample_type,
that will be dealt with in the future, when this preexisting limitation will be
removed.
Tested-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ian Munsie <imunsie@au1.ibm.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <1291318772-30880-4-git-send-email-acme@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-12-02 16:10:21 +00:00
|
|
|
struct perf_session *session)
|
2010-02-03 18:52:04 +00:00
|
|
|
{
|
|
|
|
struct addr_location al;
|
|
|
|
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
|
|
|
|
struct thread *thread = perf_session__findnew(session, event->ip.pid);
|
|
|
|
|
|
|
|
if (thread == NULL) {
|
|
|
|
pr_err("problem processing %d event, skipping it.\n",
|
|
|
|
event->header.type);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION,
|
2010-04-19 05:32:50 +00:00
|
|
|
event->ip.pid, event->ip.ip, &al);
|
2010-02-03 18:52:04 +00:00
|
|
|
|
|
|
|
if (al.map != NULL)
|
|
|
|
al.map->dso->hit = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-25 10:19:45 +00:00
|
|
|
static int perf_event__exit_del_thread(struct perf_event_ops *ops __used,
|
|
|
|
union perf_event *event,
|
2011-01-29 16:01:45 +00:00
|
|
|
struct perf_sample *sample __used,
|
|
|
|
struct perf_session *session)
|
2010-07-30 21:28:42 +00:00
|
|
|
{
|
2011-01-29 16:01:45 +00:00
|
|
|
struct thread *thread = perf_session__findnew(session, event->fork.tid);
|
2010-07-30 21:28:42 +00:00
|
|
|
|
2011-01-29 16:01:45 +00:00
|
|
|
dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
|
|
|
|
event->fork.ppid, event->fork.ptid);
|
2010-07-30 21:28:42 +00:00
|
|
|
|
|
|
|
if (thread) {
|
2011-11-09 15:24:25 +00:00
|
|
|
rb_erase(&thread->rb_node, &session->host_machine.threads);
|
|
|
|
session->host_machine.last_match = NULL;
|
2010-07-30 21:28:42 +00:00
|
|
|
thread__delete(thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-02-03 18:52:04 +00:00
|
|
|
struct perf_event_ops build_id__mark_dso_hit_ops = {
|
|
|
|
.sample = build_id__mark_dso_hit,
|
2011-01-29 16:01:45 +00:00
|
|
|
.mmap = perf_event__process_mmap,
|
|
|
|
.fork = perf_event__process_task,
|
|
|
|
.exit = perf_event__exit_del_thread,
|
2010-02-03 18:52:04 +00:00
|
|
|
};
|
2010-05-20 15:15:33 +00: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 19:25:01 +00:00
|
|
|
if (asprintf(&bf, "%s/.build-id/%.2s/%s", buildid_dir,
|
|
|
|
build_id_hex, build_id_hex + 2) < 0)
|
2010-05-20 15:15:33 +00: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 19:25:01 +00:00
|
|
|
snprintf(bf, size, "%s/.build-id/%.2s/%s", buildid_dir,
|
|
|
|
build_id_hex, build_id_hex + 2);
|
2010-05-20 15:15:33 +00:00
|
|
|
return bf;
|
|
|
|
}
|