Skip to content

Commit bcee4bf

Browse files
mikel-armbbgregkh
authored andcommitted
perf: tools: cs-etm: Fix print issue for Coresight debug in ETE/TRBE trace
[ Upstream commit 6c478e7 ] Building perf with CORESIGHT=1 and the optional CSTRACE_RAW=1 enables additional debug printing of raw trace data when using command:- perf report --dump. This raw trace prints the CoreSight formatted trace frames, which may be used to investigate suspected issues with trace quality / corruption / decode. These frames are not present in ETE + TRBE trace. This fix removes the unnecessary call to print these frames. This fix also rationalises implementation - original code had helper function that unnecessarily repeated initialisation calls that had already been made. Due to an addtional fault with the OpenCSD library, this call when ETE/TRBE are being decoded will cause a segfault in perf. This fix also prevents that problem for perf using older (<= 1.8.0 version) OpenCSD libraries. Fixes: 68ffe39 ("perf tools: Add decoder mechanic to support dumping trace data") Reported-by: Leo Yan <leo.yan@arm.com> Signed-off-by: Mike Leach <mike.leach@arm.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5a71159 commit bcee4bf

1 file changed

Lines changed: 13 additions & 38 deletions

File tree

tools/perf/util/cs-etm-decoder/cs-etm-decoder.c

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -237,46 +237,24 @@ cs_etm_decoder__init_def_logger_printing(struct cs_etm_decoder_params *d_params,
237237
(void *)decoder,
238238
cs_etm_decoder__print_str_cb);
239239
if (ret != 0)
240-
ret = -1;
241-
242-
return 0;
243-
}
240+
return -1;
244241

245242
#ifdef CS_LOG_RAW_FRAMES
246-
static void
247-
cs_etm_decoder__init_raw_frame_logging(struct cs_etm_decoder_params *d_params,
248-
struct cs_etm_decoder *decoder)
249-
{
250-
/* Only log these during a --dump operation */
251-
if (d_params->operation == CS_ETM_OPERATION_PRINT) {
252-
/* set up a library default logger to process the
253-
* raw frame printer we add later
254-
*/
255-
ocsd_def_errlog_init(OCSD_ERR_SEV_ERROR, 1);
256-
257-
/* no stdout / err / file output */
258-
ocsd_def_errlog_config_output(C_API_MSGLOGOUT_FLG_NONE, NULL);
259-
260-
/* set the string CB for the default logger,
261-
* passes strings to perf print logger.
262-
*/
263-
ocsd_def_errlog_set_strprint_cb(decoder->dcd_tree,
264-
(void *)decoder,
265-
cs_etm_decoder__print_str_cb);
266-
243+
/*
244+
* Only log raw frames if --dump operation and hardware is actually
245+
* generating formatted CoreSight trace frames
246+
*/
247+
if ((d_params->operation == CS_ETM_OPERATION_PRINT) &&
248+
(d_params->formatted == true)) {
267249
/* use the built in library printer for the raw frames */
268-
ocsd_dt_set_raw_frame_printer(decoder->dcd_tree,
269-
CS_RAW_DEBUG_FLAGS);
250+
ret = ocsd_dt_set_raw_frame_printer(decoder->dcd_tree,
251+
CS_RAW_DEBUG_FLAGS);
252+
if (ret != 0)
253+
return -1;
270254
}
271-
}
272-
#else
273-
static void
274-
cs_etm_decoder__init_raw_frame_logging(
275-
struct cs_etm_decoder_params *d_params __maybe_unused,
276-
struct cs_etm_decoder *decoder __maybe_unused)
277-
{
278-
}
279255
#endif
256+
return 0;
257+
}
280258

281259
static ocsd_datapath_resp_t
282260
cs_etm_decoder__do_soft_timestamp(struct cs_etm_queue *etmq,
@@ -755,9 +733,6 @@ cs_etm_decoder__new(int decoders, struct cs_etm_decoder_params *d_params,
755733
if (ret != 0)
756734
goto err_free_decoder;
757735

758-
/* init raw frame logging if required */
759-
cs_etm_decoder__init_raw_frame_logging(d_params, decoder);
760-
761736
for (i = 0; i < decoders; i++) {
762737
ret = cs_etm_decoder__create_etm_decoder(d_params,
763738
&t_params[i],

0 commit comments

Comments
 (0)