Re: [PATCH v1] perf jevents: Fix build issue in '*/' in event descriptions

From: Ian Rogers
Date: Mon Dec 09 2024 - 13:35:53 EST


On Wed, Nov 13, 2024 at 8:56 AM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> 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@xxxxxxxxxx>

Ping.

Thanks,
Ian

> ---
> 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 6e71b09dbc2a..028cf3c43881 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('*/', '\*\/')
> +
> 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.47.0.277.g8800431eea-goog
>