diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-10-16 10:07:03 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-10-29 08:28:20 -0400 |
commit | 428560e762601d1248359052361322b71561c093 (patch) | |
tree | 3b886922d41fe748016aa1842d560258c6d67464 /tools | |
parent | 0199d244d6ed6bc1fcab38a8732fdba1ddf04080 (diff) |
perf tools: Fix report -F mispredict for data without branch info
The branch field sorting code assumes hist_entry::branch_info is
allocated, which is wrong and following perf session ends up with report
segfault.
$ perf record ls
$ perf report -F mispredict
perf: Segmentation fault
Checking that hist_entry::branch_info is valid and display "N/A" string
in snprint callback if it's not.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1413468427-31049-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/sort.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 9bcdb57076b8..0c68af83e7dd 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -471,11 +471,13 @@ struct sort_entry sort_sym_to = { | |||
471 | static int64_t | 471 | static int64_t |
472 | sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right) | 472 | sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right) |
473 | { | 473 | { |
474 | const unsigned char mp = left->branch_info->flags.mispred != | 474 | unsigned char mp, p; |
475 | right->branch_info->flags.mispred; | ||
476 | const unsigned char p = left->branch_info->flags.predicted != | ||
477 | right->branch_info->flags.predicted; | ||
478 | 475 | ||
476 | if (!left->branch_info || !right->branch_info) | ||
477 | return cmp_null(left->branch_info, right->branch_info); | ||
478 | |||
479 | mp = left->branch_info->flags.mispred != right->branch_info->flags.mispred; | ||
480 | p = left->branch_info->flags.predicted != right->branch_info->flags.predicted; | ||
479 | return mp || p; | 481 | return mp || p; |
480 | } | 482 | } |
481 | 483 | ||
@@ -483,10 +485,12 @@ static int hist_entry__mispredict_snprintf(struct hist_entry *he, char *bf, | |||
483 | size_t size, unsigned int width){ | 485 | size_t size, unsigned int width){ |
484 | static const char *out = "N/A"; | 486 | static const char *out = "N/A"; |
485 | 487 | ||
486 | if (he->branch_info->flags.predicted) | 488 | if (he->branch_info) { |
487 | out = "N"; | 489 | if (he->branch_info->flags.predicted) |
488 | else if (he->branch_info->flags.mispred) | 490 | out = "N"; |
489 | out = "Y"; | 491 | else if (he->branch_info->flags.mispred) |
492 | out = "Y"; | ||
493 | } | ||
490 | 494 | ||
491 | return repsep_snprintf(bf, size, "%-*.*s", width, width, out); | 495 | return repsep_snprintf(bf, size, "%-*.*s", width, width, out); |
492 | } | 496 | } |