lkml.org 
[lkml]   [2013]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH V5 12/12] perf tools: add a sample parsing test
On Thu, Jul 11, 2013 at 04:12:21PM +0300, Adrian Hunter wrote:
> Add a test that checks that sample parsing is correctly
> implemented.

nice!!! :)

>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

SNIP

> +static int do_test(u64 sample_type, u64 sample_regs_user)
> +{
> + struct perf_evsel evsel = {
> + .needs_swap = false,
> + .attr = {
> + .sample_type = sample_type,
> + .sample_regs_user = sample_regs_user,
> + },
> + };
> + union perf_event event = {
> + .header = {
> + .type = PERF_RECORD_SAMPLE,
> + .size = sizeof(union perf_event),
> + },
> + };

maybe I'm missing something but how does event.sample.array get
allocated? It's used in perf_event__synthesize_sample func.

do we need to use something like in the patch below..

thanks,
jirka

---
diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c
index c6e6813..dcbd40d 100644
--- a/tools/perf/tests/sample-parsing.c
+++ b/tools/perf/tests/sample-parsing.c
@@ -111,12 +111,8 @@ static int do_test(u64 sample_type, u64 sample_regs_user)
.sample_regs_user = sample_regs_user,
},
};
- union perf_event event = {
- .header = {
- .type = PERF_RECORD_SAMPLE,
- .size = sizeof(union perf_event),
- },
- };
+ u64 buf[100];
+ union perf_event *event = (union perf_event *) buf;
union {
struct ip_callchain callchain;
u64 data[64];
@@ -162,10 +158,15 @@ static int do_test(u64 sample_type, u64 sample_regs_user)
size_t i;
int err;

+ event->sample.header = (struct perf_event_header) {
+ .type = PERF_RECORD_SAMPLE,
+ .size = sizeof(union perf_event),
+ };
+
for (i = 0; i < sizeof(user_regs); i++)
*(u8 *)user_regs = i;

- err = perf_event__synthesize_sample(&event, sample_type,
+ err = perf_event__synthesize_sample(event, sample_type,
sample_regs_user, &sample, false);
if (err) {
pr_debug("%s failed for sample_type %#"PRIx64", error %d\n",
@@ -175,7 +176,7 @@ static int do_test(u64 sample_type, u64 sample_regs_user)

evsel.sample_size = __perf_evsel__sample_size(sample_type);

- err = perf_evsel__parse_sample(&evsel, &event, &sample_out);
+ err = perf_evsel__parse_sample(&evsel, event, &sample_out);
if (err) {
pr_debug("%s failed for sample_type %#"PRIx64", error %d\n",
"perf_evsel__parse_sample", sample_type, err);

\
 
 \ /
  Last update: 2013-07-16 15:41    [W:0.128 / U:1.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site