diff options
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 33667b534634..9b16df881af8 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -400,10 +400,20 @@ static inline int output_type(unsigned int type) static inline int evsel__output_type(struct evsel *evsel) { - if (evsel->script_output_type == OUTPUT_TYPE_UNSET) - evsel->script_output_type = output_type(evsel->core.attr.type); + int type = evsel->script_output_type; - return evsel->script_output_type; + if (type == OUTPUT_TYPE_UNSET) { + type = output_type(evsel->core.attr.type); + if (type == OUTPUT_TYPE_OTHER) { + struct perf_pmu *pmu = evsel__find_pmu(evsel); + + if (pmu && pmu->is_core) + type = PERF_TYPE_RAW; + } + evsel->script_output_type = type; + } + + return type; } static bool output_set_by_user(void) @@ -783,14 +793,20 @@ tod_scnprintf(struct perf_script *script, char *buf, int buflen, static int perf_sample__fprintf_iregs(struct perf_sample *sample, struct perf_event_attr *attr, const char *arch, FILE *fp) { - return perf_sample__fprintf_regs(&sample->intr_regs, + if (!sample->intr_regs) + return 0; + + return perf_sample__fprintf_regs(perf_sample__intr_regs(sample), attr->sample_regs_intr, arch, fp); } static int perf_sample__fprintf_uregs(struct perf_sample *sample, struct perf_event_attr *attr, const char *arch, FILE *fp) { - return perf_sample__fprintf_regs(&sample->user_regs, + if (!sample->user_regs) + return 0; + + return perf_sample__fprintf_regs(perf_sample__user_regs(sample), attr->sample_regs_user, arch, fp); } @@ -929,19 +945,25 @@ static int perf_sample__fprintf_start(struct perf_script *script, return printed; } -static inline char -mispred_str(struct branch_entry *br) +static inline size_t +bstack_event_str(struct branch_entry *br, char *buf, size_t sz) { - if (!(br->flags.mispred || br->flags.predicted)) - return '-'; + if (!(br->flags.mispred || br->flags.predicted || br->flags.not_taken)) + return snprintf(buf, sz, "-"); - return br->flags.predicted ? 'P' : 'M'; + return snprintf(buf, sz, "%s%s", + br->flags.predicted ? "P" : "M", + br->flags.not_taken ? "N" : ""); } static int print_bstack_flags(FILE *fp, struct branch_entry *br) { - return fprintf(fp, "/%c/%c/%c/%d/%s/%s ", - mispred_str(br), + char events[16] = { 0 }; + size_t pos; + + pos = bstack_event_str(br, events, sizeof(events)); + return fprintf(fp, "/%s/%c/%c/%d/%s/%s ", + pos < 0 ? "-" : events, br->flags.in_tx ? 'X' : '-', br->flags.abort ? 'A' : '-', br->flags.cycles, @@ -1703,9 +1725,14 @@ static int perf_sample__fprintf_bts(struct perf_sample *sample, static int perf_sample__fprintf_flags(u32 flags, FILE *fp) { char str[SAMPLE_FLAGS_BUF_SIZE]; + int ret; + + ret = perf_sample__sprintf_flags(flags, str, sizeof(str)); + if (ret < 0) + return fprintf(fp, " raw flags:0x%-*x ", + SAMPLE_FLAGS_STR_ALIGNED_SIZE - 12, flags); - perf_sample__sprintf_flags(flags, str, sizeof(str)); - return fprintf(fp, " %-21s ", str); + return fprintf(fp, " %-*s ", SAMPLE_FLAGS_STR_ALIGNED_SIZE, str); } struct printer_data { |