perf cs-etm: Show a warning for an unknown magic number
authorJames Clark <james.clark@arm.com>
Fri, 6 Aug 2021 13:41:09 +0000 (14:41 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 3 Sep 2021 11:18:24 +0000 (08:18 -0300)
Currently perf reports "Cannot allocate memory" which isn't very helpful
for a potentially user facing issue. If we add a new magic number in
the future, perf will be able to report unrecognised magic numbers.

Reviewed-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: James Clark <james.clark@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https //lore.kernel.org/r/20210806134109.1182235-10-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/cs-etm.c

index 5b19b38..f323adb 100644 (file)
@@ -2981,6 +2981,11 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
 
                        /* ETE shares first part of metadata with ETMv4 */
                        trcidr_idx = CS_ETMV4_TRCTRACEIDR;
+               } else {
+                       ui__error("CS ETM Trace: Unrecognised magic number %#"PRIx64". File could be from a newer version of perf.\n",
+                                 ptr[i]);
+                       err = -EINVAL;
+                       goto err_free_metadata;
                }
 
                if (!metadata[j]) {