diff options
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r-- | tools/perf/util/session.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index b8da60d1ecb5..00e180e116e7 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -23,12 +23,20 @@ int perf_session__parse_sample(struct perf_session *session, | |||
23 | struct perf_evsel *first; | 23 | struct perf_evsel *first; |
24 | first = list_entry(session->evlist->entries.next, struct perf_evsel, node); | 24 | first = list_entry(session->evlist->entries.next, struct perf_evsel, node); |
25 | 25 | ||
26 | return perf_event__parse_sample(event, session->sample_type, | 26 | return perf_event__parse_sample(event, first->attr.sample_type, |
27 | first->sample_size, | 27 | first->sample_size, |
28 | session->sample_id_all, sample, | 28 | session->sample_id_all, sample, |
29 | session->header.needs_swap); | 29 | session->header.needs_swap); |
30 | } | 30 | } |
31 | 31 | ||
32 | int perf_session__synthesize_sample(struct perf_session *session, | ||
33 | union perf_event *event, | ||
34 | const struct perf_sample *sample) | ||
35 | { | ||
36 | return perf_event__synthesize_sample(event, perf_evlist__sample_type(session->evlist), | ||
37 | sample, session->header.needs_swap); | ||
38 | } | ||
39 | |||
32 | static int perf_session__open(struct perf_session *self, bool force) | 40 | static int perf_session__open(struct perf_session *self, bool force) |
33 | { | 41 | { |
34 | struct stat input_stat; | 42 | struct stat input_stat; |
@@ -95,7 +103,6 @@ out_close: | |||
95 | 103 | ||
96 | void perf_session__update_sample_type(struct perf_session *self) | 104 | void perf_session__update_sample_type(struct perf_session *self) |
97 | { | 105 | { |
98 | self->sample_type = perf_evlist__sample_type(self->evlist); | ||
99 | self->sample_id_all = perf_evlist__sample_id_all(self->evlist); | 106 | self->sample_id_all = perf_evlist__sample_id_all(self->evlist); |
100 | self->id_hdr_size = perf_evlist__id_hdr_size(self->evlist); | 107 | self->id_hdr_size = perf_evlist__id_hdr_size(self->evlist); |
101 | self->host_machine.id_hdr_size = self->id_hdr_size; | 108 | self->host_machine.id_hdr_size = self->id_hdr_size; |
@@ -877,16 +884,18 @@ static void perf_session__print_tstamp(struct perf_session *session, | |||
877 | union perf_event *event, | 884 | union perf_event *event, |
878 | struct perf_sample *sample) | 885 | struct perf_sample *sample) |
879 | { | 886 | { |
887 | u64 sample_type = perf_evlist__sample_type(session->evlist); | ||
888 | |||
880 | if (event->header.type != PERF_RECORD_SAMPLE && | 889 | if (event->header.type != PERF_RECORD_SAMPLE && |
881 | !session->sample_id_all) { | 890 | !session->sample_id_all) { |
882 | fputs("-1 -1 ", stdout); | 891 | fputs("-1 -1 ", stdout); |
883 | return; | 892 | return; |
884 | } | 893 | } |
885 | 894 | ||
886 | if ((session->sample_type & PERF_SAMPLE_CPU)) | 895 | if ((sample_type & PERF_SAMPLE_CPU)) |
887 | printf("%u ", sample->cpu); | 896 | printf("%u ", sample->cpu); |
888 | 897 | ||
889 | if (session->sample_type & PERF_SAMPLE_TIME) | 898 | if (sample_type & PERF_SAMPLE_TIME) |
890 | printf("%" PRIu64 " ", sample->time); | 899 | printf("%" PRIu64 " ", sample->time); |
891 | } | 900 | } |
892 | 901 | ||
@@ -911,6 +920,8 @@ static void dump_event(struct perf_session *session, union perf_event *event, | |||
911 | static void dump_sample(struct perf_session *session, union perf_event *event, | 920 | static void dump_sample(struct perf_session *session, union perf_event *event, |
912 | struct perf_sample *sample) | 921 | struct perf_sample *sample) |
913 | { | 922 | { |
923 | u64 sample_type; | ||
924 | |||
914 | if (!dump_trace) | 925 | if (!dump_trace) |
915 | return; | 926 | return; |
916 | 927 | ||
@@ -918,10 +929,12 @@ static void dump_sample(struct perf_session *session, union perf_event *event, | |||
918 | event->header.misc, sample->pid, sample->tid, sample->ip, | 929 | event->header.misc, sample->pid, sample->tid, sample->ip, |
919 | sample->period, sample->addr); | 930 | sample->period, sample->addr); |
920 | 931 | ||
921 | if (session->sample_type & PERF_SAMPLE_CALLCHAIN) | 932 | sample_type = perf_evlist__sample_type(session->evlist); |
933 | |||
934 | if (sample_type & PERF_SAMPLE_CALLCHAIN) | ||
922 | callchain__printf(sample); | 935 | callchain__printf(sample); |
923 | 936 | ||
924 | if (session->sample_type & PERF_SAMPLE_BRANCH_STACK) | 937 | if (sample_type & PERF_SAMPLE_BRANCH_STACK) |
925 | branch_stack__printf(sample); | 938 | branch_stack__printf(sample); |
926 | } | 939 | } |
927 | 940 | ||
@@ -1018,7 +1031,7 @@ static int perf_session__preprocess_sample(struct perf_session *session, | |||
1018 | union perf_event *event, struct perf_sample *sample) | 1031 | union perf_event *event, struct perf_sample *sample) |
1019 | { | 1032 | { |
1020 | if (event->header.type != PERF_RECORD_SAMPLE || | 1033 | if (event->header.type != PERF_RECORD_SAMPLE || |
1021 | !(session->sample_type & PERF_SAMPLE_CALLCHAIN)) | 1034 | !(perf_evlist__sample_type(session->evlist) & PERF_SAMPLE_CALLCHAIN)) |
1022 | return 0; | 1035 | return 0; |
1023 | 1036 | ||
1024 | if (!ip_callchain__valid(sample->callchain, event)) { | 1037 | if (!ip_callchain__valid(sample->callchain, event)) { |
@@ -1401,9 +1414,9 @@ int perf_session__process_events(struct perf_session *self, | |||
1401 | return err; | 1414 | return err; |
1402 | } | 1415 | } |
1403 | 1416 | ||
1404 | bool perf_session__has_traces(struct perf_session *self, const char *msg) | 1417 | bool perf_session__has_traces(struct perf_session *session, const char *msg) |
1405 | { | 1418 | { |
1406 | if (!(self->sample_type & PERF_SAMPLE_RAW)) { | 1419 | if (!(perf_evlist__sample_type(session->evlist) & PERF_SAMPLE_RAW)) { |
1407 | pr_err("No trace sample to read. Did you call 'perf %s'?\n", msg); | 1420 | pr_err("No trace sample to read. Did you call 'perf %s'?\n", msg); |
1408 | return false; | 1421 | return false; |
1409 | } | 1422 | } |