aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2013-05-01 11:47:44 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2013-05-01 11:47:44 -0400
commitbf61c8840efe60fd8f91446860b63338fb424158 (patch)
tree7a71832407a4f0d6346db773343f4c3ae2257b19 /tools/perf/builtin-annotate.c
parent5846115b30f3a881e542c8bfde59a699c1c13740 (diff)
parent0c6a61657da78098472fd0eb71cc01f2387fa1bb (diff)
Merge branch 'next' into for-linus
Prepare first set of updates for 3.10 merge window.
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 9ea38540b873..2e6961ea3184 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -28,15 +28,16 @@
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 "arch/common.h"
31 32
32#include <linux/bitmap.h> 33#include <linux/bitmap.h>
33 34
34struct perf_annotate { 35struct perf_annotate {
35 struct perf_tool tool; 36 struct perf_tool tool;
36 char const *input_name; 37 bool force, use_tui, use_stdio, use_gtk;
37 bool force, use_tui, use_stdio;
38 bool full_paths; 38 bool full_paths;
39 bool print_line; 39 bool print_line;
40 bool skip_missing;
40 const char *sym_hist_filter; 41 const char *sym_hist_filter;
41 const char *cpu_list; 42 const char *cpu_list;
42 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); 43 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
@@ -138,9 +139,22 @@ find_next:
138 continue; 139 continue;
139 } 140 }
140 141
141 if (use_browser > 0) { 142 if (use_browser == 2) {
142 key = hist_entry__tui_annotate(he, evidx, NULL, NULL, 0); 143 int ret;
144
145 ret = hist_entry__gtk_annotate(he, evidx, NULL);
146 if (!ret || !ann->skip_missing)
147 return;
148
149 /* skip missing symbols */
150 nd = rb_next(nd);
151 } else if (use_browser == 1) {
152 key = hist_entry__tui_annotate(he, evidx, NULL);
143 switch (key) { 153 switch (key) {
154 case -1:
155 if (!ann->skip_missing)
156 return;
157 /* fall through */
144 case K_RIGHT: 158 case K_RIGHT:
145 next = rb_next(nd); 159 next = rb_next(nd);
146 break; 160 break;
@@ -174,7 +188,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
174 struct perf_evsel *pos; 188 struct perf_evsel *pos;
175 u64 total_nr_samples; 189 u64 total_nr_samples;
176 190
177 session = perf_session__new(ann->input_name, O_RDONLY, 191 session = perf_session__new(input_name, O_RDONLY,
178 ann->force, false, &ann->tool); 192 ann->force, false, &ann->tool);
179 if (session == NULL) 193 if (session == NULL)
180 return -ENOMEM; 194 return -ENOMEM;
@@ -186,6 +200,12 @@ static int __cmd_annotate(struct perf_annotate *ann)
186 goto out_delete; 200 goto out_delete;
187 } 201 }
188 202
203 if (!objdump_path) {
204 ret = perf_session_env__lookup_objdump(&session->header.env);
205 if (ret)
206 goto out_delete;
207 }
208
189 ret = perf_session__process_events(session, &ann->tool); 209 ret = perf_session__process_events(session, &ann->tool);
190 if (ret) 210 if (ret)
191 goto out_delete; 211 goto out_delete;
@@ -218,6 +238,10 @@ static int __cmd_annotate(struct perf_annotate *ann)
218 ui__error("The %s file has no samples!\n", session->filename); 238 ui__error("The %s file has no samples!\n", session->filename);
219 goto out_delete; 239 goto out_delete;
220 } 240 }
241
242 if (use_browser == 2)
243 perf_gtk__show_annotations();
244
221out_delete: 245out_delete:
222 /* 246 /*
223 * Speed up the exit process, for large files this can 247 * Speed up the exit process, for large files this can
@@ -246,13 +270,14 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
246 .sample = process_sample_event, 270 .sample = process_sample_event,
247 .mmap = perf_event__process_mmap, 271 .mmap = perf_event__process_mmap,
248 .comm = perf_event__process_comm, 272 .comm = perf_event__process_comm,
249 .fork = perf_event__process_task, 273 .exit = perf_event__process_exit,
274 .fork = perf_event__process_fork,
250 .ordered_samples = true, 275 .ordered_samples = true,
251 .ordering_requires_timestamps = true, 276 .ordering_requires_timestamps = true,
252 }, 277 },
253 }; 278 };
254 const struct option options[] = { 279 const struct option options[] = {
255 OPT_STRING('i', "input", &annotate.input_name, "file", 280 OPT_STRING('i', "input", &input_name, "file",
256 "input file name"), 281 "input file name"),
257 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", 282 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
258 "only consider symbols in these dsos"), 283 "only consider symbols in these dsos"),
@@ -263,6 +288,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
263 "be more verbose (show symbol address, etc)"), 288 "be more verbose (show symbol address, etc)"),
264 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 289 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
265 "dump raw trace in ASCII"), 290 "dump raw trace in ASCII"),
291 OPT_BOOLEAN(0, "gtk", &annotate.use_gtk, "Use the GTK interface"),
266 OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"), 292 OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"),
267 OPT_BOOLEAN(0, "stdio", &annotate.use_stdio, "Use the stdio interface"), 293 OPT_BOOLEAN(0, "stdio", &annotate.use_stdio, "Use the stdio interface"),
268 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, 294 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
@@ -273,6 +299,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
273 "print matching source lines (may be slow)"), 299 "print matching source lines (may be slow)"),
274 OPT_BOOLEAN('P', "full-paths", &annotate.full_paths, 300 OPT_BOOLEAN('P', "full-paths", &annotate.full_paths,
275 "Don't shorten the displayed pathnames"), 301 "Don't shorten the displayed pathnames"),
302 OPT_BOOLEAN(0, "skip-missing", &annotate.skip_missing,
303 "Skip symbols that cannot be annotated"),
276 OPT_STRING('C', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"), 304 OPT_STRING('C', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"),
277 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", 305 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
278 "Look for files with symbols relative to this directory"), 306 "Look for files with symbols relative to this directory"),
@@ -293,6 +321,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
293 use_browser = 0; 321 use_browser = 0;
294 else if (annotate.use_tui) 322 else if (annotate.use_tui)
295 use_browser = 1; 323 use_browser = 1;
324 else if (annotate.use_gtk)
325 use_browser = 2;
296 326
297 setup_browser(true); 327 setup_browser(true);
298 328
@@ -302,7 +332,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
302 if (symbol__init() < 0) 332 if (symbol__init() < 0)
303 return -1; 333 return -1;
304 334
305 setup_sorting(annotate_usage, options); 335 if (setup_sorting() < 0)
336 usage_with_options(annotate_usage, options);
306 337
307 if (argc) { 338 if (argc) {
308 /* 339 /*