summaryrefslogtreecommitdiff
path: root/tools/perf/util/data-convert-json.c
diff options
context:
space:
mode:
authorDmitrii Dolgov <9erthalion6@gmail.com>2022-11-09 11:39:32 +0100
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-11-10 15:35:37 -0300
commit9d895e46842908aa49a042e699097df64ab20b7f (patch)
tree81182ab7833e0552ed14c2a70ad030b451c3999f /tools/perf/util/data-convert-json.c
parent30b331d2e3bc5c7c95568477d4bf2661b6e6cb3e (diff)
perf data: Add tracepoint fields when converting to JSON
When converting recorded data into JSON format, perf data omits probe variables. Add them to the output in the format "field name": "field value" using tep_print_field: $ perf data convert --to-json output.json // output.json { "linux-perf-json-version": 1, "headers": { ... }, "samples": [ { "timestamp": 29182079082999, "pid": 309194, [...] "__probe_ip": "0x93ee35", "query_string_string": "select 2;", "nxids": "0" } ] } Signed-off-by: Dmitrii Dolgov <9erthalion6@gmail.com> Acked-by: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20221109103932.65675-1-9erthalion6@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/data-convert-json.c')
-rw-r--r--tools/perf/util/data-convert-json.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c
index 613d6ae82663..57db59068cb6 100644
--- a/tools/perf/util/data-convert-json.c
+++ b/tools/perf/util/data-convert-json.c
@@ -217,6 +217,26 @@ static int process_sample_event(struct perf_tool *tool,
}
output_json_format(out, false, 3, "]");
+ if (sample->raw_data) {
+ int i;
+ struct tep_format_field **fields;
+
+ fields = tep_event_fields(evsel->tp_format);
+ if (fields) {
+ i = 0;
+ while (fields[i]) {
+ struct trace_seq s;
+
+ trace_seq_init(&s);
+ tep_print_field(&s, sample->raw_data, fields[i]);
+ output_json_key_string(out, true, 3, fields[i]->name, s.buffer);
+
+ i++;
+ }
+ free(fields);
+ }
+ }
+
output_json_format(out, false, 2, "}");
return 0;
}