From: Namhyung Kim Date: Fri, 2 Dec 2022 19:04:47 +0000 (-0800) Subject: perf stat: Fix multi-line metric output in JSON X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=117195d9f8af74c65bf57d9b56f496b5b3655bcb;p=linux.git perf stat: Fix multi-line metric output in JSON When a metric produces more than one values, it missed to print the opening bracket. Fixes: ab6baaae27357290 ("perf stat: Fix JSON output in metric-only mode") Reported-by: Weilin Wang Signed-off-by: Namhyung Kim Tested-by: Weilin Wang Cc: Adrian Hunter Cc: Athira Jajeev Cc: Ian Rogers Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Kan Liang Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Xing Zhengjun Link: https://lore.kernel.org/r/20221202190447.1588680-1-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 660e4f6616f55..7f885b04c23fb 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -441,7 +441,7 @@ static void new_line_json(struct perf_stat_config *config, void *ctx) { struct outstate *os = ctx; - fputc('\n', os->fh); + fputs("\n{", os->fh); if (os->prefix) fprintf(os->fh, "%s", os->prefix); aggr_printout(config, os->evsel, os->id, os->nr);