From: Dmitrii Dolgov <9erthalion6@gmail.com>
To: linux-perf-users@vger.kernel.org
Cc: acme@kernel.org, mingo@redhat.com, jolsa@kernel.org,
Dmitrii Dolgov <9erthalion6@gmail.com>
Subject: [RFC PATCH v1] perf data: Add fields when converting to json
Date: Tue, 8 Nov 2022 20:00:19 +0100 [thread overview]
Message-ID: <20221108190019.19265-1-9erthalion6@gmail.com> (raw)
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>
---
tools/perf/util/data-convert-json.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c
index 613d6ae82663..d30816eafb2f 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 != NULL) {
+ 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;
}
--
2.27.0
next reply other threads:[~2022-11-08 19:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 19:00 Dmitrii Dolgov [this message]
2022-11-09 1:35 ` [RFC PATCH v1] perf data: Add fields when converting to json Ian Rogers
2022-11-09 10:37 ` Dmitry Dolgov
2022-11-10 18:37 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221108190019.19265-1-9erthalion6@gmail.com \
--to=9erthalion6@gmail.com \
--cc=acme@kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).