From: Ian Rogers Date: Wed, 13 Nov 2024 16:55:58 +0000 (-0800) Subject: perf jevents: Fix build issue in '*/' in event descriptions X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=7504a1c20eb799adcf028a34855c7d9f3dd99545;p=users%2Fdwmw2%2Flinux.git 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 --- diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index d781a377757a1..139dae1f1f832 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)