perf script: Fix error when printing 'weight' field
authorGerman Gomez <german.gomez@arm.com>
Mon, 21 Feb 2022 17:17:06 +0000 (17:17 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 23 Feb 2022 00:17:55 +0000 (21:17 -0300)
commit13e741b834538a225512912608f0182079fc64e2
treed78b57f34c30f95f41d43aa81eba76b4e10e394c
parent5b061a322b05a5e023d9a0df1ae1f8bb562ed87b
perf script: Fix error when printing 'weight' field

In SPE traces the 'weight' field can't be printed in 'perf script'
because the 'dummy:u' event doesn't have the WEIGHT attribute set.

Use evsel__do_check_stype(..) to check this field, as it's done with
other fields such as "phys_addr".

Before:

  $ perf record -e arm_spe_0// -- sleep 1
  $ perf script -F event,ip,weight
  Samples for 'dummy:u' event do not have WEIGHT attribute set. Cannot print 'weight' field.

After:

  $ perf script -F event,ip,weight
     l1d-access:               12 ffffaf629d4cb320
     tlb-access:               12 ffffaf629d4cb320
         memory:               12 ffffaf629d4cb320

Fixes: b0fde9c6e291e528 ("perf arm-spe: Add SPE total latency as PERF_SAMPLE_WEIGHT")
Signed-off-by: German Gomez <german.gomez@arm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220221171707.62960-1-german.gomez@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-script.c