[PATCH v5 03/14] perf jevents: Provide path to json file on error

From: Ian Rogers
Date: Fri Aug 12 2022 - 19:10:17 EST


If a JSONDecoderError or similar is raised then it is useful to know the
path. Print this and then raise the exception agan.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/pmu-events/jevents.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index 8e8462cb359b..31936eafa9ff 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -225,7 +225,12 @@ class JsonEvent:

def read_json_events(path: str) -> Sequence[JsonEvent]:
"""Read json events from the specified file."""
- return json.load(open(path), object_hook=lambda d: JsonEvent(d))
+
+ try:
+ return json.load(open(path), object_hook=lambda d: JsonEvent(d))
+ except BaseException as err:
+ print(f"Exception processing {path}")
+ raise


def preprocess_arch_std_files(archpath: str) -> None:
--
2.37.1.595.g718a3a8f04-goog