Commit b2dac688 authored by James Clark's avatar James Clark Committed by Arnaldo Carvalho de Melo

perf script: Refactor branch stack printing

Remove duplicate code so that future changes to flags are always made to
all 3 printing variations.
Signed-off-by: default avatarJames Clark <james.clark@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220307171917.2555829-4-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 66fd6c9d
...@@ -857,6 +857,15 @@ mispred_str(struct branch_entry *br) ...@@ -857,6 +857,15 @@ mispred_str(struct branch_entry *br)
return br->flags.predicted ? 'P' : 'M'; return br->flags.predicted ? 'P' : 'M';
} }
static int print_bstack_flags(FILE *fp, struct branch_entry *br)
{
return fprintf(fp, "/%c/%c/%c/%d ",
mispred_str(br),
br->flags.in_tx ? 'X' : '-',
br->flags.abort ? 'A' : '-',
br->flags.cycles);
}
static int perf_sample__fprintf_brstack(struct perf_sample *sample, static int perf_sample__fprintf_brstack(struct perf_sample *sample,
struct thread *thread, struct thread *thread,
struct perf_event_attr *attr, FILE *fp) struct perf_event_attr *attr, FILE *fp)
...@@ -895,11 +904,7 @@ static int perf_sample__fprintf_brstack(struct perf_sample *sample, ...@@ -895,11 +904,7 @@ static int perf_sample__fprintf_brstack(struct perf_sample *sample,
printed += fprintf(fp, ")"); printed += fprintf(fp, ")");
} }
printed += fprintf(fp, "/%c/%c/%c/%d ", printed += print_bstack_flags(fp, entries + i);
mispred_str(entries + i),
entries[i].flags.in_tx ? 'X' : '-',
entries[i].flags.abort ? 'A' : '-',
entries[i].flags.cycles);
} }
return printed; return printed;
...@@ -941,11 +946,7 @@ static int perf_sample__fprintf_brstacksym(struct perf_sample *sample, ...@@ -941,11 +946,7 @@ static int perf_sample__fprintf_brstacksym(struct perf_sample *sample,
printed += map__fprintf_dsoname(alt.map, fp); printed += map__fprintf_dsoname(alt.map, fp);
printed += fprintf(fp, ")"); printed += fprintf(fp, ")");
} }
printed += fprintf(fp, "/%c/%c/%c/%d ", printed += print_bstack_flags(fp, entries + i);
mispred_str(entries + i),
entries[i].flags.in_tx ? 'X' : '-',
entries[i].flags.abort ? 'A' : '-',
entries[i].flags.cycles);
} }
return printed; return printed;
...@@ -991,11 +992,7 @@ static int perf_sample__fprintf_brstackoff(struct perf_sample *sample, ...@@ -991,11 +992,7 @@ static int perf_sample__fprintf_brstackoff(struct perf_sample *sample,
printed += map__fprintf_dsoname(alt.map, fp); printed += map__fprintf_dsoname(alt.map, fp);
printed += fprintf(fp, ")"); printed += fprintf(fp, ")");
} }
printed += fprintf(fp, "/%c/%c/%c/%d ", printed += print_bstack_flags(fp, entries + i);
mispred_str(entries + i),
entries[i].flags.in_tx ? 'X' : '-',
entries[i].flags.abort ? 'A' : '-',
entries[i].flags.cycles);
} }
return printed; return printed;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment