 +					cpumode = PERF_RECORD_MISC_USER;
 +					break;
 +				default:
-+					pr_debug("invalid callchain context: "
-+						"%"PRId64"\n", (s64) ip);
++					pr_debug("invalid callchain context: %"
++							PRId64 "\n", (s64) ip);
 +					break;
 +				}
 +				continue;
 +			}
 +
-+			if (first_callchain) {
++			if (first_callchain)
 +				first_callchain = false;
-+			} else {
-+				fprintf(out, ",");
-+			}
++			else
++				fputc(',', out);
 +
 +			ok = thread__find_symbol(al.thread, cpumode, ip, &tal);
 +			output_sample_callchain_entry(tool, ip, ok ? &tal : NULL);

From 3c92a5f8cb1476885b98df31dd1385067ed9f228 Mon Sep 17 00:00:00 2001
From: Nicholas Fraser <nfraser@codeweavers.com>
Date: Wed, 24 Mar 2021 08:55:02 -0400
Subject: [PATCH] perf data: Add JSON export

This adds a feature to export perf data to a bespoke JSON file. It uses
a (very) minimal inline JSON encoding, no external dependencies.
Currently it only outputs some sample metadata but it's easily
extensible.

Signed-off-by: Nicholas Fraser <nfraser@codeweavers.com>
---
 tools/perf/Documentation/perf-data.txt |   5 +-
 tools/perf/builtin-data.c              |  39 ++++-
 tools/perf/util/Build                  |   1 +
 tools/perf/util/data-convert-json.c    | 228 +++++++++++++++++++++++++
 tools/perf/util/data-convert-json.h    |   9 +
 tools/perf/util/data-convert.h         |   2 +
 6 files changed, 276 insertions(+), 8 deletions(-)
 create mode 100644 tools/perf/util/data-convert-json.c
 create mode 100644 tools/perf/util/data-convert-json.h

diff --git a/tools/perf/Documentation/perf-data.txt b/tools/perf/Documentation/perf-data.txt
index 726b9bc9e1a7..417bf17e265c 100644

 	Convert time to wall clock time.
 
diff --git a/tools/perf/builtin-data.c b/tools/perf/builtin-data.c
index 8d23b8d6ee8e..15ca23675ef0 100644
--- a/tools/perf/builtin-data.c
+++ b/tools/perf/builtin-data.c
@@ -7,7 +7,6 @@
 #include "debug.h"
 #include <subcmd/parse-options.h>
 #include "data-convert.h"
-#include "data-convert-bt.h"
 
 typedef int (*data_cmd_fn_t)(int argc, const char **argv);
 
@@ -55,7 +54,8 @@ static const char * const data_convert_usage[] = {
 
 static int cmd_data_convert(int argc, const char **argv)
 {
