Skip to content

Commit

Permalink
perf tools: Fix bug in raw sample parsing
Browse files Browse the repository at this point in the history
In perf_event__parse_sample(), the array variable was not incremented
by the amount of data used by the raw_data.

That was okay until we added PERF_SAMPLE_BRANCH_STACK which depends on
the array variable pointing to the beginning of the branch stack data.

But that was not the case if branch stack was combined with raw mode
sampling. That led to bogus branch stack addresses and count.

The bug would show up with:
$ perf record -R -b foo

This patch fixes the problem by correctly moving the array pointer
forward for RAW samples.

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20120317222317.GA8803@quad
[ committer note: Fix also later submitted by Jiri Olsa ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Stephane Eranian authored and Arnaldo Carvalho de Melo committed Mar 26, 2012
1 parent 6d4818c commit fa30c96
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
return -EFAULT;

data->raw_data = (void *) pdata;

array = (void *)array + data->raw_size + sizeof(u32);
}

if (type & PERF_SAMPLE_BRANCH_STACK) {
Expand Down

0 comments on commit fa30c96

Please sign in to comment.