aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/event.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-01-21 10:46:41 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-24 10:17:56 -0500
commitd0dd74e853a0a6f37e8061d6d50be41c7034c54c (patch)
tree1292a98711611cbc4595785ed17605f20a90800c /tools/perf/util/event.c
parentfd78260b5376173faeb17127bd63b3c99a8e8bfb (diff)
perf tools: Move event__parse_sample to evsel.c
To avoid linking more stuff in the python binding I'm working on, future csets will make the sample type be taken from the evsel itself, but for that we need to first have one file per cpu and per sample_type, not a single perf.data file. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> 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: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/event.c')
-rw-r--r--tools/perf/util/event.c125
1 files changed, 0 insertions, 125 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 1478ab4ee222..e4db8b888546 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -826,128 +826,3 @@ out_filtered:
826 al->filtered = true; 826 al->filtered = true;
827 return 0; 827 return 0;
828} 828}
829
830static int event__parse_id_sample(const event_t *event,
831 struct perf_session *session,
832 struct sample_data *sample)
833{
834 const u64 *array;
835 u64 type;
836
837 sample->cpu = sample->pid = sample->tid = -1;
838 sample->stream_id = sample->id = sample->time = -1ULL;
839
840 if (!session->sample_id_all)
841 return 0;
842
843 array = event->sample.array;
844 array += ((event->header.size -
845 sizeof(event->header)) / sizeof(u64)) - 1;
846 type = session->sample_type;
847
848 if (type & PERF_SAMPLE_CPU) {
849 u32 *p = (u32 *)array;
850 sample->cpu = *p;
851 array--;
852 }
853
854 if (type & PERF_SAMPLE_STREAM_ID) {
855 sample->stream_id = *array;
856 array--;
857 }
858
859 if (type & PERF_SAMPLE_ID) {
860 sample->id = *array;
861 array--;
862 }
863
864 if (type & PERF_SAMPLE_TIME) {
865 sample->time = *array;
866 array--;
867 }
868
869 if (type & PERF_SAMPLE_TID) {
870 u32 *p = (u32 *)array;
871 sample->pid = p[0];
872 sample->tid = p[1];
873 }
874
875 return 0;
876}
877
878int event__parse_sample(const event_t *event, struct perf_session *session,
879 struct sample_data *data)
880{
881 const u64 *array;
882 u64 type;
883
884 if (event->header.type != PERF_RECORD_SAMPLE)
885 return event__parse_id_sample(event, session, data);
886
887 array = event->sample.array;
888 type = session->sample_type;
889
890 if (type & PERF_SAMPLE_IP) {
891 data->ip = event->ip.ip;
892 array++;
893 }
894
895 if (type & PERF_SAMPLE_TID) {
896 u32 *p = (u32 *)array;
897 data->pid = p[0];
898 data->tid = p[1];
899 array++;
900 }
901
902 if (type & PERF_SAMPLE_TIME) {
903 data->time = *array;
904 array++;
905 }
906
907 if (type & PERF_SAMPLE_ADDR) {
908 data->addr = *array;
909 array++;
910 }
911
912 data->id = -1ULL;
913 if (type & PERF_SAMPLE_ID) {
914 data->id = *array;
915 array++;
916 }
917
918 if (type & PERF_SAMPLE_STREAM_ID) {
919 data->stream_id = *array;
920 array++;
921 }
922
923 if (type & PERF_SAMPLE_CPU) {
924 u32 *p = (u32 *)array;
925 data->cpu = *p;
926 array++;
927 } else
928 data->cpu = -1;
929
930 if (type & PERF_SAMPLE_PERIOD) {
931 data->period = *array;
932 array++;
933 }
934
935 if (type & PERF_SAMPLE_READ) {
936 pr_debug("PERF_SAMPLE_READ is unsuported for now\n");
937 return -1;
938 }
939
940 if (type & PERF_SAMPLE_CALLCHAIN) {
941 data->callchain = (struct ip_callchain *)array;
942 array += 1 + data->callchain->nr;
943 }
944
945 if (type & PERF_SAMPLE_RAW) {
946 u32 *p = (u32 *)array;
947 data->raw_size = *p;
948 p++;
949 data->raw_data = p;
950 }
951
952 return 0;
953}