diff options
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r-- | tools/perf/builtin-annotate.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 5ebd0c3b71b6..4087ab19823c 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -28,8 +28,10 @@ | |||
28 | #include "util/hist.h" | 28 | #include "util/hist.h" |
29 | #include "util/session.h" | 29 | #include "util/session.h" |
30 | #include "util/tool.h" | 30 | #include "util/tool.h" |
31 | #include "util/data.h" | ||
31 | #include "arch/common.h" | 32 | #include "arch/common.h" |
32 | 33 | ||
34 | #include <dlfcn.h> | ||
33 | #include <linux/bitmap.h> | 35 | #include <linux/bitmap.h> |
34 | 36 | ||
35 | struct perf_annotate { | 37 | struct perf_annotate { |
@@ -63,7 +65,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel, | |||
63 | return 0; | 65 | return 0; |
64 | } | 66 | } |
65 | 67 | ||
66 | he = __hists__add_entry(&evsel->hists, al, NULL, 1, 1); | 68 | he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 1, 1, 0); |
67 | if (he == NULL) | 69 | if (he == NULL) |
68 | return -ENOMEM; | 70 | return -ENOMEM; |
69 | 71 | ||
@@ -116,11 +118,11 @@ static int hist_entry__tty_annotate(struct hist_entry *he, | |||
116 | ann->print_line, ann->full_paths, 0, 0); | 118 | ann->print_line, ann->full_paths, 0, 0); |
117 | } | 119 | } |
118 | 120 | ||
119 | static void hists__find_annotations(struct hists *self, | 121 | static void hists__find_annotations(struct hists *hists, |
120 | struct perf_evsel *evsel, | 122 | struct perf_evsel *evsel, |
121 | struct perf_annotate *ann) | 123 | struct perf_annotate *ann) |
122 | { | 124 | { |
123 | struct rb_node *nd = rb_first(&self->entries), *next; | 125 | struct rb_node *nd = rb_first(&hists->entries), *next; |
124 | int key = K_RIGHT; | 126 | int key = K_RIGHT; |
125 | 127 | ||
126 | while (nd) { | 128 | while (nd) { |
@@ -142,8 +144,18 @@ find_next: | |||
142 | 144 | ||
143 | if (use_browser == 2) { | 145 | if (use_browser == 2) { |
144 | int ret; | 146 | int ret; |
147 | int (*annotate)(struct hist_entry *he, | ||
148 | struct perf_evsel *evsel, | ||
149 | struct hist_browser_timer *hbt); | ||
150 | |||
151 | annotate = dlsym(perf_gtk_handle, | ||
152 | "hist_entry__gtk_annotate"); | ||
153 | if (annotate == NULL) { | ||
154 | ui__error("GTK browser not found!\n"); | ||
155 | return; | ||
156 | } | ||
145 | 157 | ||
146 | ret = hist_entry__gtk_annotate(he, evsel, NULL); | 158 | ret = annotate(he, evsel, NULL); |
147 | if (!ret || !ann->skip_missing) | 159 | if (!ret || !ann->skip_missing) |
148 | return; | 160 | return; |
149 | 161 | ||
@@ -188,9 +200,13 @@ static int __cmd_annotate(struct perf_annotate *ann) | |||
188 | struct perf_session *session; | 200 | struct perf_session *session; |
189 | struct perf_evsel *pos; | 201 | struct perf_evsel *pos; |
190 | u64 total_nr_samples; | 202 | u64 total_nr_samples; |
203 | struct perf_data_file file = { | ||
204 | .path = input_name, | ||
205 | .mode = PERF_DATA_MODE_READ, | ||
206 | .force = ann->force, | ||
207 | }; | ||
191 | 208 | ||
192 | session = perf_session__new(input_name, O_RDONLY, | 209 | session = perf_session__new(&file, false, &ann->tool); |
193 | ann->force, false, &ann->tool); | ||
194 | if (session == NULL) | 210 | if (session == NULL) |
195 | return -ENOMEM; | 211 | return -ENOMEM; |
196 | 212 | ||
@@ -231,7 +247,7 @@ static int __cmd_annotate(struct perf_annotate *ann) | |||
231 | 247 | ||
232 | if (nr_samples > 0) { | 248 | if (nr_samples > 0) { |
233 | total_nr_samples += nr_samples; | 249 | total_nr_samples += nr_samples; |
234 | hists__collapse_resort(hists); | 250 | hists__collapse_resort(hists, NULL); |
235 | hists__output_resort(hists); | 251 | hists__output_resort(hists); |
236 | 252 | ||
237 | if (symbol_conf.event_group && | 253 | if (symbol_conf.event_group && |
@@ -243,12 +259,21 @@ static int __cmd_annotate(struct perf_annotate *ann) | |||
243 | } | 259 | } |
244 | 260 | ||
245 | if (total_nr_samples == 0) { | 261 | if (total_nr_samples == 0) { |
246 | ui__error("The %s file has no samples!\n", session->filename); | 262 | ui__error("The %s file has no samples!\n", file.path); |
247 | goto out_delete; | 263 | goto out_delete; |
248 | } | 264 | } |
249 | 265 | ||
250 | if (use_browser == 2) | 266 | if (use_browser == 2) { |
251 | perf_gtk__show_annotations(); | 267 | void (*show_annotations)(void); |
268 | |||
269 | show_annotations = dlsym(perf_gtk_handle, | ||
270 | "perf_gtk__show_annotations"); | ||
271 | if (show_annotations == NULL) { | ||
272 | ui__error("GTK browser not found!\n"); | ||
273 | goto out_delete; | ||
274 | } | ||
275 | show_annotations(); | ||
276 | } | ||
252 | 277 | ||
253 | out_delete: | 278 | out_delete: |
254 | /* | 279 | /* |