diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/Makefile | 2 | ||||
| -rw-r--r-- | tools/perf/builtin-buildid-list.c | 31 | ||||
| -rw-r--r-- | tools/perf/util/build-id.c | 39 | ||||
| -rw-r--r-- | tools/perf/util/build-id.h | 8 |
4 files changed, 51 insertions, 29 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 42969303e20b..3a5fb36ccc97 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
| @@ -357,6 +357,7 @@ LIB_H += util/include/asm/uaccess.h | |||
| 357 | LIB_H += perf.h | 357 | LIB_H += perf.h |
| 358 | LIB_H += util/cache.h | 358 | LIB_H += util/cache.h |
| 359 | LIB_H += util/callchain.h | 359 | LIB_H += util/callchain.h |
| 360 | LIB_H += util/build-id.h | ||
| 360 | LIB_H += util/debug.h | 361 | LIB_H += util/debug.h |
| 361 | LIB_H += util/debugfs.h | 362 | LIB_H += util/debugfs.h |
| 362 | LIB_H += util/event.h | 363 | LIB_H += util/event.h |
| @@ -390,6 +391,7 @@ LIB_H += util/probe-event.h | |||
| 390 | 391 | ||
| 391 | LIB_OBJS += util/abspath.o | 392 | LIB_OBJS += util/abspath.o |
| 392 | LIB_OBJS += util/alias.o | 393 | LIB_OBJS += util/alias.o |
| 394 | LIB_OBJS += util/build-id.o | ||
| 393 | LIB_OBJS += util/config.o | 395 | LIB_OBJS += util/config.o |
| 394 | LIB_OBJS += util/ctype.o | 396 | LIB_OBJS += util/ctype.o |
| 395 | LIB_OBJS += util/debugfs.o | 397 | LIB_OBJS += util/debugfs.o |
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 431f204bde64..d0675c02f81e 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | */ | 8 | */ |
| 9 | #include "builtin.h" | 9 | #include "builtin.h" |
| 10 | #include "perf.h" | 10 | #include "perf.h" |
| 11 | #include "util/build-id.h" | ||
| 11 | #include "util/cache.h" | 12 | #include "util/cache.h" |
| 12 | #include "util/debug.h" | 13 | #include "util/debug.h" |
| 13 | #include "util/parse-options.h" | 14 | #include "util/parse-options.h" |
| @@ -33,34 +34,6 @@ static const struct option options[] = { | |||
| 33 | OPT_END() | 34 | OPT_END() |
| 34 | }; | 35 | }; |
| 35 | 36 | ||
| 36 | static int build_id_list__process_event(event_t *event, | ||
| 37 | struct perf_session *session) | ||
| 38 | { | ||
| 39 | struct addr_location al; | ||
| 40 | u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | ||
| 41 | struct thread *thread = perf_session__findnew(session, event->ip.pid); | ||
| 42 | |||
| 43 | if (thread == NULL) { | ||
| 44 | pr_err("problem processing %d event, skipping it.\n", | ||
| 45 | event->header.type); | ||
| 46 | return -1; | ||
| 47 | } | ||
| 48 | |||
| 49 | thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, | ||
| 50 | event->ip.ip, &al); | ||
| 51 | |||
| 52 | if (al.map != NULL) | ||
| 53 | al.map->dso->hit = 1; | ||
| 54 | |||
| 55 | return 0; | ||
| 56 | } | ||
| 57 | |||
| 58 | static struct perf_event_ops build_id_list__event_ops = { | ||
| 59 | .sample = build_id_list__process_event, | ||
| 60 | .mmap = event__process_mmap, | ||
| 61 | .fork = event__process_task, | ||
| 62 | }; | ||
| 63 | |||
| 64 | static int __cmd_buildid_list(void) | 37 | static int __cmd_buildid_list(void) |
| 65 | { | 38 | { |
| 66 | int err = -1; | 39 | int err = -1; |
| @@ -71,7 +44,7 @@ static int __cmd_buildid_list(void) | |||
| 71 | return -1; | 44 | return -1; |
| 72 | 45 | ||
| 73 | if (with_hits) | 46 | if (with_hits) |
| 74 | perf_session__process_events(session, &build_id_list__event_ops); | 47 | perf_session__process_events(session, &build_id__mark_dso_hit_ops); |
| 75 | 48 | ||
| 76 | dsos__fprintf_buildid(stdout, with_hits); | 49 | dsos__fprintf_buildid(stdout, with_hits); |
| 77 | 50 | ||
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c new file mode 100644 index 000000000000..04904b35ba81 --- /dev/null +++ b/tools/perf/util/build-id.c | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | /* | ||
| 2 | * build-id.c | ||
| 3 | * | ||
| 4 | * build-id support | ||
| 5 | * | ||
| 6 | * Copyright (C) 2009, 2010 Red Hat Inc. | ||
| 7 | * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <acme@redhat.com> | ||
| 8 | */ | ||
| 9 | #include "build-id.h" | ||
| 10 | #include "event.h" | ||
| 11 | #include "symbol.h" | ||
| 12 | #include <linux/kernel.h> | ||
| 13 | |||
| 14 | static int build_id__mark_dso_hit(event_t *event, struct perf_session *session) | ||
| 15 | { | ||
| 16 | struct addr_location al; | ||
| 17 | u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | ||
| 18 | struct thread *thread = perf_session__findnew(session, event->ip.pid); | ||
| 19 | |||
| 20 | if (thread == NULL) { | ||
| 21 | pr_err("problem processing %d event, skipping it.\n", | ||
| 22 | event->header.type); | ||
| 23 | return -1; | ||
| 24 | } | ||
| 25 | |||
| 26 | thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION, | ||
| 27 | event->ip.ip, &al); | ||
| 28 | |||
| 29 | if (al.map != NULL) | ||
| 30 | al.map->dso->hit = 1; | ||
| 31 | |||
| 32 | return 0; | ||
| 33 | } | ||
| 34 | |||
| 35 | struct perf_event_ops build_id__mark_dso_hit_ops = { | ||
| 36 | .sample = build_id__mark_dso_hit, | ||
| 37 | .mmap = event__process_mmap, | ||
| 38 | .fork = event__process_task, | ||
| 39 | }; | ||
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h new file mode 100644 index 000000000000..1d981d63cf9a --- /dev/null +++ b/tools/perf/util/build-id.h | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #ifndef PERF_BUILD_ID_H_ | ||
| 2 | #define PERF_BUILD_ID_H_ 1 | ||
| 3 | |||
| 4 | #include "session.h" | ||
| 5 | |||
| 6 | extern struct perf_event_ops build_id__mark_dso_hit_ops; | ||
| 7 | |||
| 8 | #endif | ||
