Skip to content

Commit 7504a1c

Browse files
captain5050acmel
authored andcommitted
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 <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Benjamin Gray <bgray@linux.ibm.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Xu Yang <xu.yang_2@nxp.com> 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 <acme@redhat.com>
1 parent 625f4de commit 7504a1c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/perf/pmu-events/jevents.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,11 @@ def build_c_string(self, metric: bool) -> str:
430430
def to_c_string(self, metric: bool) -> str:
431431
"""Representation of the event as a C struct initializer."""
432432

433+
def fix_comment(s: str) -> str:
434+
return s.replace('*/', r'\*\/')
435+
433436
s = self.build_c_string(metric)
434-
return f'{{ { _bcs.offsets[s] } }}, /* {s} */\n'
437+
return f'{{ { _bcs.offsets[s] } }}, /* {fix_comment(s)} */\n'
435438

436439

437440
@lru_cache(maxsize=None)

0 commit comments

Comments
 (0)