From 7504a1c20eb799adcf028a34855c7d9f3dd99545 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Wed, 13 Nov 2024 08:55:58 -0800 Subject: [PATCH] perf jevents: Fix build issue in '*/' in event descriptions For big string offsets we output comments for what string the offset is for. If the string contains a '*/' as seen in Intel Arrowlake event descriptions, then this causes C parsing issues for the generated pmu-events.c. Catch such '*/' values and escape to avoid this. Signed-off-by: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Benjamin Gray Cc: Ingo Molnar Cc: Jiri Olsa Cc: John Garry Cc: Kan Liang Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Sandipan Das Cc: Xu Yang Link: https://lore.kernel.org/r/20241113165558.628856-1-irogers@google.com [ Used return s.replace('*/', r'\*\/') based on failure followed by request by Ian ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/pmu-events/jevents.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index d781a377757a..139dae1f1f83 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -430,8 +430,11 @@ class JsonEvent: def to_c_string(self, metric: bool) -> str: """Representation of the event as a C struct initializer.""" + def fix_comment(s: str) -> str: + return s.replace('*/', r'\*\/') + s = self.build_c_string(metric) - return f'{{ { _bcs.offsets[s] } }}, /* {s} */\n' + return f'{{ { _bcs.offsets[s] } }}, /* {fix_comment(s)} */\n' @lru_cache(maxsize=None) -- 2.50.1