Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf json: Pipe mode --to-json support

In pipe mode the environment may not be fully initialized so be robust
to fields being NULL. Add default handling of feature and attr events.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Derek Foreman <derek.foreman@collabora.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
6db2f7c6 8772598b

+16
+16
tools/perf/util/data-convert-json.c
··· 48 48 static void output_json_string(FILE *out, const char *s) 49 49 { 50 50 fputc('"', out); 51 + if (!s) 52 + goto out; 53 + 51 54 while (*s) { 52 55 switch (*s) { 53 56 ··· 74 71 75 72 ++s; 76 73 } 74 + out: 77 75 fputc('"', out); 78 76 } 79 77 ··· 326 322 output_json_format(out, false, 2, "]"); 327 323 } 328 324 325 + static int process_feature_event(const struct perf_tool *tool __maybe_unused, 326 + struct perf_session *session, 327 + union perf_event *event) 328 + { 329 + if (event->feat.feat_id < HEADER_LAST_FEATURE) 330 + return perf_event__process_feature(session, event); 331 + 332 + return 0; 333 + } 334 + 329 335 int bt_convert__perf2json(const char *input_name, const char *output_name, 330 336 struct perf_data_convert_opts *opts __maybe_unused) 331 337 { ··· 374 360 c.tool.auxtrace_info = perf_event__process_auxtrace_info; 375 361 c.tool.auxtrace = perf_event__process_auxtrace; 376 362 c.tool.event_update = perf_event__process_event_update; 363 + c.tool.attr = perf_event__process_attr; 364 + c.tool.feature = process_feature_event; 377 365 c.tool.ordering_requires_timestamps = true; 378 366 379 367 if (opts->all) {