diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2009-09-12 01:52:51 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-09-19 05:42:11 -0400 |
commit | 8755a8f27ae590dde225f9005ee18c6d9c4c6d78 (patch) | |
tree | 1a86744bf0f5ee71bc5f2d0c29f86f9721aa6f4a /tools/perf/util/parse-events.c | |
parent | 393b2ad8c757ba3ccd2a99ca5bbcd6db4d3fa53d (diff) |
perf: Store trace event name/id pairs in perf.data
The trace event name<->id mapping is dynamic for each kernel
compile. In order for perf.data to be useable outside the actual
system, we thus need to store a table of this mapping for later
use.
This patch adds this table to perf.data, and provides helper
functions for lookup up fields from this table.
To avoid mistakes, lookup-from-table is kept completely seprate
from lookup-from-local-debugfs.
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <20090912130405.6960d099@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r-- | tools/perf/util/parse-events.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index a9bdcab8c070..89172fd0038b 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include "exec_cmd.h" | 6 | #include "exec_cmd.h" |
7 | #include "string.h" | 7 | #include "string.h" |
8 | #include "cache.h" | 8 | #include "cache.h" |
9 | #include "header.h" | ||
9 | 10 | ||
10 | int nr_counters; | 11 | int nr_counters; |
11 | 12 | ||
@@ -687,11 +688,35 @@ modifier: | |||
687 | return ret; | 688 | return ret; |
688 | } | 689 | } |
689 | 690 | ||
691 | static void store_event_type(const char *orgname) | ||
692 | { | ||
693 | char filename[PATH_MAX], *c; | ||
694 | FILE *file; | ||
695 | int id; | ||
696 | |||
697 | sprintf(filename, "/sys/kernel/debug/tracing/events/%s/id", orgname); | ||
698 | c = strchr(filename, ':'); | ||
699 | if (c) | ||
700 | *c = '/'; | ||
701 | |||
702 | file = fopen(filename, "r"); | ||
703 | if (!file) | ||
704 | return; | ||
705 | if (fscanf(file, "%i", &id) < 1) | ||
706 | die("cannot store event ID"); | ||
707 | fclose(file); | ||
708 | perf_header__push_event(id, orgname); | ||
709 | } | ||
710 | |||
711 | |||
690 | int parse_events(const struct option *opt __used, const char *str, int unset __used) | 712 | int parse_events(const struct option *opt __used, const char *str, int unset __used) |
691 | { | 713 | { |
692 | struct perf_counter_attr attr; | 714 | struct perf_counter_attr attr; |
693 | enum event_result ret; | 715 | enum event_result ret; |
694 | 716 | ||
717 | if (strchr(str, ':')) | ||
718 | store_event_type(str); | ||
719 | |||
695 | for (;;) { | 720 | for (;;) { |
696 | if (nr_counters == MAX_COUNTERS) | 721 | if (nr_counters == MAX_COUNTERS) |
697 | return -1; | 722 | return -1; |