]>
Commit | Line | Data |
---|---|---|
df1b7722 GKH |
1 | From foo@baz Mon Apr 9 13:58:16 CEST 2018 |
2 | From: Jin Yao <yao.jin@linux.intel.com> | |
3 | Date: Tue, 26 Dec 2017 18:42:43 +0800 | |
4 | Subject: perf report: Fix a no annotate browser displayed issue | |
5 | ||
6 | From: Jin Yao <yao.jin@linux.intel.com> | |
7 | ||
8 | ||
9 | [ Upstream commit 40c39e3046411f84bab82f66783ff3593e2bcd9b ] | |
10 | ||
11 | When enabling '-b' option in perf record, for example, | |
12 | ||
13 | perf record -b ... | |
14 | perf report | |
15 | ||
16 | and then browsing the annotate browser from perf report (press 'A'), it | |
17 | would fail (annotate browser can't be displayed). | |
18 | ||
19 | It's because the '.add_entry_cb' op of struct report is overwritten by | |
20 | hist_iter__branch_callback() in builtin-report.c. But this function doesn't do | |
21 | something like mapping symbols and sources. So next, do_annotate() will return | |
22 | directly. | |
23 | ||
24 | notes = symbol__annotation(act->ms.sym); | |
25 | if (!notes->src) | |
26 | return 0; | |
27 | ||
28 | This patch adds the lost code to hist_iter__branch_callback (refer to | |
29 | hist_iter__report_callback). | |
30 | ||
31 | v2: | |
32 | ||
33 | Fix a crash bug when perform 'perf report --stdio'. | |
34 | ||
35 | The reason is that we init the symbol annotation only in browser mode, it | |
36 | doesn't allocate/init resources for stdio mode. | |
37 | ||
38 | So now in hist_iter__branch_callback(), it will return directly if it's not in | |
39 | browser mode. | |
40 | ||
41 | Signed-off-by: Jin Yao <yao.jin@linux.intel.com> | |
42 | Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> | |
43 | Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> | |
44 | Cc: Andi Kleen <ak@linux.intel.com> | |
45 | Cc: Jiri Olsa <jolsa@kernel.org> | |
46 | Cc: Kan Liang <kan.liang@intel.com> | |
47 | Cc: Peter Zijlstra <peterz@infradead.org> | |
48 | Link: http://lkml.kernel.org/r/1514284963-18587-1-git-send-email-yao.jin@linux.intel.com | |
49 | Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> | |
50 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
51 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
52 | --- | |
53 | tools/perf/builtin-report.c | 18 +++++++++++++++++- | |
54 | 1 file changed, 17 insertions(+), 1 deletion(-) | |
55 | ||
56 | --- a/tools/perf/builtin-report.c | |
57 | +++ b/tools/perf/builtin-report.c | |
58 | @@ -162,12 +162,28 @@ static int hist_iter__branch_callback(st | |
59 | struct hist_entry *he = iter->he; | |
60 | struct report *rep = arg; | |
61 | struct branch_info *bi; | |
62 | + struct perf_sample *sample = iter->sample; | |
63 | + struct perf_evsel *evsel = iter->evsel; | |
64 | + int err; | |
65 | + | |
66 | + if (!ui__has_annotation()) | |
67 | + return 0; | |
68 | + | |
69 | + hist__account_cycles(sample->branch_stack, al, sample, | |
70 | + rep->nonany_branch_mode); | |
71 | ||
72 | bi = he->branch_info; | |
73 | + err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx); | |
74 | + if (err) | |
75 | + goto out; | |
76 | + | |
77 | + err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx); | |
78 | + | |
79 | branch_type_count(&rep->brtype_stat, &bi->flags, | |
80 | bi->from.addr, bi->to.addr); | |
81 | ||
82 | - return 0; | |
83 | +out: | |
84 | + return err; | |
85 | } | |
86 | ||
87 | static int process_sample_event(struct perf_tool *tool, |