aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
authorTom Zanussi <tzanussi@gmail.com>2010-04-02 00:59:20 -0400
committerIngo Molnar <mingo@elte.hu>2010-04-14 05:56:07 -0400
commitcd19a035f3b63fee6dcbdb5371c4b22276f7dc8c (patch)
tree0d0f6ce913a070372854d524bca068032dd3ff8f /tools/perf/util/header.c
parent2c46dbb517a10b18d459e6ceffefde5bfb290cf6 (diff)
perf: Convert perf event types into event type events
Bypasses the event type perf header code and replaces it with a synthesized event and processing function that accomplishes the same thing, used when reading/writing perf data to/from a pipe. Signed-off-by: Tom Zanussi <tzanussi@gmail.com> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: fweisbec@gmail.com Cc: rostedt@goodmis.org Cc: k-keiichi@bx.jp.nec.com Cc: acme@ghostprotocols.net LKML-Reference: <1270184365-8281-7-git-send-email-tzanussi@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r--tools/perf/util/header.c62
1 files changed, 55 insertions, 7 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index e36173934e8b..44637999dbc1 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -99,13 +99,6 @@ int perf_header__add_attr(struct perf_header *self,
99 return 0; 99 return 0;
100} 100}
101 101
102#define MAX_EVENT_NAME 64
103
104struct perf_trace_event_type {
105 u64 event_id;
106 char name[MAX_EVENT_NAME];
107};
108
109static int event_count; 102static int event_count;
110static struct perf_trace_event_type *events; 103static struct perf_trace_event_type *events;
111 104
@@ -886,3 +879,58 @@ int event__process_attr(event_t *self, struct perf_session *session)
886 879
887 return 0; 880 return 0;
888} 881}
882
883int event__synthesize_event_type(u64 event_id, char *name,
884 event__handler_t process,
885 struct perf_session *session)
886{
887 event_t ev;
888 size_t size = 0;
889 int err = 0;
890
891 memset(&ev, 0, sizeof(ev));
892
893 ev.event_type.event_type.event_id = event_id;
894 memset(ev.event_type.event_type.name, 0, MAX_EVENT_NAME);
895 strncpy(ev.event_type.event_type.name, name, MAX_EVENT_NAME - 1);
896
897 ev.event_type.header.type = PERF_RECORD_HEADER_EVENT_TYPE;
898 size = strlen(name);
899 size = ALIGN(size, sizeof(u64));
900 ev.event_type.header.size = sizeof(ev.event_type) -
901 (sizeof(ev.event_type.event_type.name) - size);
902
903 err = process(&ev, session);
904
905 return err;
906}
907
908int event__synthesize_event_types(event__handler_t process,
909 struct perf_session *session)
910{
911 struct perf_trace_event_type *type;
912 int i, err = 0;
913
914 for (i = 0; i < event_count; i++) {
915 type = &events[i];
916
917 err = event__synthesize_event_type(type->event_id, type->name,
918 process, session);
919 if (err) {
920 pr_debug("failed to create perf header event type\n");
921 return err;
922 }
923 }
924
925 return err;
926}
927
928int event__process_event_type(event_t *self,
929 struct perf_session *session __unused)
930{
931 if (perf_header__push_event(self->event_type.event_type.event_id,
932 self->event_type.event_type.name) < 0)
933 return -ENOMEM;
934
935 return 0;
936}