Skip to content

Commit 9de0736

Browse files
James-A-Clarkacmel
authored andcommitted
perf cs-etm: Fix corrupt inject files when only last branch option is enabled
'perf inject' with Coresight data generates files that cannot be opened when only the last branch option is specified: perf inject -i perf.data --itrace=l -o inject.data perf script -i inject.data 0x33faa8 [0x8]: failed to process type: 9 [Bad address] This is because cs_etm__synth_instruction_sample() is called even when the sample type for instructions hasn't been setup. Last branch records are attached to instruction samples so it doesn't make sense to generate them when --itrace=i isn't specified anyway. This change disables all calls of cs_etm__synth_instruction_sample() unless --itrace=i is specified, resulting in a file with no samples if only --itrace=l is provided, rather than a bad file. Reviewed-by: Leo Yan <[email protected]> Signed-off-by: James Clark <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Poirier <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 0b31ea6 commit 9de0736

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/perf/util/cs-etm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq,
15531553
goto swap_packet;
15541554

15551555
if (etmq->etm->synth_opts.last_branch &&
1556+
etmq->etm->synth_opts.instructions &&
15561557
tidq->prev_packet->sample_type == CS_ETM_RANGE) {
15571558
u64 addr;
15581559

@@ -1610,6 +1611,7 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq,
16101611
* the trace.
16111612
*/
16121613
if (etmq->etm->synth_opts.last_branch &&
1614+
etmq->etm->synth_opts.instructions &&
16131615
tidq->prev_packet->sample_type == CS_ETM_RANGE) {
16141616
u64 addr;
16151617

0 commit comments

Comments
 (0)