diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-06-15 04:22:15 -0400 |
---|---|---|
committer | Jiri Olsa <jolsa@kernel.org> | 2014-06-20 03:34:18 -0400 |
commit | d755330c5e0658d8056242b5b81e2f44ed7a96d8 (patch) | |
tree | 91189b0a8953822941cdcaee88751e4e74e9da65 /tools/perf/ui | |
parent | cf230918cda19532e4a5cc4f0d5c82fa7e5e94f6 (diff) |
perf tools: Fix segfault in cumulative.callchain report
When cumulative callchain mode is on, we could get samples with
with no actual hits. This breaks the assumption of the annotation
code, that each sample has annotation counts allocated and leads
to segfault.
Fixing this by additional checks for annotation stats.
Acked-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
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/1402821332-12419-1-git-send-email-jolsa@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 52c03fbbba17..04a229aa5c0f 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include "../util.h" | 17 | #include "../util.h" |
18 | #include "../ui.h" | 18 | #include "../ui.h" |
19 | #include "map.h" | 19 | #include "map.h" |
20 | #include "annotate.h" | ||
20 | 21 | ||
21 | struct hist_browser { | 22 | struct hist_browser { |
22 | struct ui_browser b; | 23 | struct ui_browser b; |
@@ -1593,13 +1594,18 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
1593 | bi->to.sym->name) > 0) | 1594 | bi->to.sym->name) > 0) |
1594 | annotate_t = nr_options++; | 1595 | annotate_t = nr_options++; |
1595 | } else { | 1596 | } else { |
1596 | |||
1597 | if (browser->selection != NULL && | 1597 | if (browser->selection != NULL && |
1598 | browser->selection->sym != NULL && | 1598 | browser->selection->sym != NULL && |
1599 | !browser->selection->map->dso->annotate_warned && | 1599 | !browser->selection->map->dso->annotate_warned) { |
1600 | asprintf(&options[nr_options], "Annotate %s", | 1600 | struct annotation *notes; |
1601 | browser->selection->sym->name) > 0) | 1601 | |
1602 | annotate = nr_options++; | 1602 | notes = symbol__annotation(browser->selection->sym); |
1603 | |||
1604 | if (notes->src && | ||
1605 | asprintf(&options[nr_options], "Annotate %s", | ||
1606 | browser->selection->sym->name) > 0) | ||
1607 | annotate = nr_options++; | ||
1608 | } | ||
1603 | } | 1609 | } |
1604 | 1610 | ||
1605 | if (thread != NULL && | 1611 | if (thread != NULL && |
@@ -1656,6 +1662,7 @@ retry_popup_menu: | |||
1656 | 1662 | ||
1657 | if (choice == annotate || choice == annotate_t || choice == annotate_f) { | 1663 | if (choice == annotate || choice == annotate_t || choice == annotate_f) { |
1658 | struct hist_entry *he; | 1664 | struct hist_entry *he; |
1665 | struct annotation *notes; | ||
1659 | int err; | 1666 | int err; |
1660 | do_annotate: | 1667 | do_annotate: |
1661 | if (!objdump_path && perf_session_env__lookup_objdump(env)) | 1668 | if (!objdump_path && perf_session_env__lookup_objdump(env)) |
@@ -1679,6 +1686,10 @@ do_annotate: | |||
1679 | he->ms.map = he->branch_info->to.map; | 1686 | he->ms.map = he->branch_info->to.map; |
1680 | } | 1687 | } |
1681 | 1688 | ||
1689 | notes = symbol__annotation(he->ms.sym); | ||
1690 | if (!notes->src) | ||
1691 | continue; | ||
1692 | |||
1682 | /* | 1693 | /* |
1683 | * Don't let this be freed, say, by hists__decay_entry. | 1694 | * Don't let this be freed, say, by hists__decay_entry. |
1684 | */ | 1695 | */ |