aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-11-17 09:33:21 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-11-28 07:38:40 -0500
commit7009cc34b964939815160d7de64cf0215cdbf8bb (patch)
tree34d5ba9b52aed3f2990ffeefaa3424f4ad38fa2e /tools/perf
parentfa372aae335c6dfbe808d5a728fe10cd202dde45 (diff)
perf annotate: Group options in a struct
Paving the way to remove these globals when we change the perf_event_ops to receive as a first parameter a pointer to a perf_event_ops that will then provide access to perf_annotate via container_of. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-xduzibqrdg3h5cttmk6p5wwc@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-annotate.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 8b9091bce98d..4f0c3d98352d 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -30,18 +30,17 @@
30 30
31#include <linux/bitmap.h> 31#include <linux/bitmap.h>
32 32
33static char const *input_name = "perf.data"; 33static struct perf_annotate {
34 34 char const *input_name;
35static bool force, use_tui, use_stdio; 35 bool force, use_tui, use_stdio;
36 36 bool full_paths;
37static bool full_paths; 37 bool print_line;
38 38 const char *sym_hist_filter;
39static bool print_line; 39 const char *cpu_list;
40 40 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
41static const char *sym_hist_filter; 41} annotate = {
42 42 .input_name = "perf.data",
43static const char *cpu_list; 43}, *ann = &annotate;
44static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
45 44
46static int perf_evsel__add_sample(struct perf_evsel *evsel, 45static int perf_evsel__add_sample(struct perf_evsel *evsel,
47 struct perf_sample *sample, 46 struct perf_sample *sample,
@@ -50,8 +49,9 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
50 struct hist_entry *he; 49 struct hist_entry *he;
51 int ret; 50 int ret;
52 51
53 if (sym_hist_filter != NULL && 52 if (ann->sym_hist_filter != NULL &&
54 (al->sym == NULL || strcmp(sym_hist_filter, al->sym->name) != 0)) { 53 (al->sym == NULL ||
54 strcmp(ann->sym_hist_filter, al->sym->name) != 0)) {
55 /* We're only interested in a symbol named sym_hist_filter */ 55 /* We're only interested in a symbol named sym_hist_filter */
56 if (al->sym != NULL) { 56 if (al->sym != NULL) {
57 rb_erase(&al->sym->rb_node, 57 rb_erase(&al->sym->rb_node,
@@ -93,7 +93,7 @@ static int process_sample_event(union perf_event *event,
93 return -1; 93 return -1;
94 } 94 }
95 95
96 if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) 96 if (ann->cpu_list && !test_bit(sample->cpu, ann->cpu_bitmap))
97 return 0; 97 return 0;
98 98
99 if (!al.filtered && perf_evsel__add_sample(evsel, sample, &al)) { 99 if (!al.filtered && perf_evsel__add_sample(evsel, sample, &al)) {
@@ -108,7 +108,7 @@ static int process_sample_event(union perf_event *event,
108static int hist_entry__tty_annotate(struct hist_entry *he, int evidx) 108static int hist_entry__tty_annotate(struct hist_entry *he, int evidx)
109{ 109{
110 return symbol__tty_annotate(he->ms.sym, he->ms.map, evidx, 110 return symbol__tty_annotate(he->ms.sym, he->ms.map, evidx,
111 print_line, full_paths, 0, 0); 111 ann->print_line, ann->full_paths, 0, 0);
112} 112}
113 113
114static void hists__find_annotations(struct hists *self, int evidx) 114static void hists__find_annotations(struct hists *self, int evidx)
@@ -178,12 +178,14 @@ static int __cmd_annotate(void)
178 struct perf_evsel *pos; 178 struct perf_evsel *pos;
179 u64 total_nr_samples; 179 u64 total_nr_samples;
180 180
181 session = perf_session__new(input_name, O_RDONLY, force, false, &event_ops); 181 session = perf_session__new(ann->input_name, O_RDONLY,
182 ann->force, false, &event_ops);
182 if (session == NULL) 183 if (session == NULL)
183 return -ENOMEM; 184 return -ENOMEM;
184 185
185 if (cpu_list) { 186 if (ann->cpu_list) {
186 ret = perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap); 187 ret = perf_session__cpu_bitmap(session, ann->cpu_list,
188 ann->cpu_bitmap);
187 if (ret) 189 if (ret)
188 goto out_delete; 190 goto out_delete;
189 } 191 }
@@ -217,7 +219,7 @@ static int __cmd_annotate(void)
217 } 219 }
218 220
219 if (total_nr_samples == 0) { 221 if (total_nr_samples == 0) {
220 ui__warning("The %s file has no samples!\n", input_name); 222 ui__warning("The %s file has no samples!\n", ann->input_name);
221 goto out_delete; 223 goto out_delete;
222 } 224 }
223out_delete: 225out_delete:
@@ -242,28 +244,28 @@ static const char * const annotate_usage[] = {
242}; 244};
243 245
244static const struct option options[] = { 246static const struct option options[] = {
245 OPT_STRING('i', "input", &input_name, "file", 247 OPT_STRING('i', "input", &annotate.input_name, "file",
246 "input file name"), 248 "input file name"),
247 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", 249 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
248 "only consider symbols in these dsos"), 250 "only consider symbols in these dsos"),
249 OPT_STRING('s', "symbol", &sym_hist_filter, "symbol", 251 OPT_STRING('s', "symbol", &annotate.sym_hist_filter, "symbol",
250 "symbol to annotate"), 252 "symbol to annotate"),
251 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), 253 OPT_BOOLEAN('f', "force", &annotate.force, "don't complain, do it"),
252 OPT_INCR('v', "verbose", &verbose, 254 OPT_INCR('v', "verbose", &verbose,
253 "be more verbose (show symbol address, etc)"), 255 "be more verbose (show symbol address, etc)"),
254 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 256 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
255 "dump raw trace in ASCII"), 257 "dump raw trace in ASCII"),
256 OPT_BOOLEAN(0, "tui", &use_tui, "Use the TUI interface"), 258 OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"),
257 OPT_BOOLEAN(0, "stdio", &use_stdio, "Use the stdio interface"), 259 OPT_BOOLEAN(0, "stdio", &annotate.use_stdio, "Use the stdio interface"),
258 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, 260 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
259 "file", "vmlinux pathname"), 261 "file", "vmlinux pathname"),
260 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, 262 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
261 "load module symbols - WARNING: use only with -k and LIVE kernel"), 263 "load module symbols - WARNING: use only with -k and LIVE kernel"),
262 OPT_BOOLEAN('l', "print-line", &print_line, 264 OPT_BOOLEAN('l', "print-line", &annotate.print_line,
263 "print matching source lines (may be slow)"), 265 "print matching source lines (may be slow)"),
264 OPT_BOOLEAN('P', "full-paths", &full_paths, 266 OPT_BOOLEAN('P', "full-paths", &annotate.full_paths,
265 "Don't shorten the displayed pathnames"), 267 "Don't shorten the displayed pathnames"),
266 OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"), 268 OPT_STRING('c', "cpu", &annotate.cpu_list, "cpu", "list of cpus to profile"),
267 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", 269 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
268 "Look for files with symbols relative to this directory"), 270 "Look for files with symbols relative to this directory"),
269 OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src, 271 OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src,
@@ -279,9 +281,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used)
279{ 281{
280 argc = parse_options(argc, argv, options, annotate_usage, 0); 282 argc = parse_options(argc, argv, options, annotate_usage, 0);
281 283
282 if (use_stdio) 284 if (annotate.use_stdio)
283 use_browser = 0; 285 use_browser = 0;
284 else if (use_tui) 286 else if (annotate.use_tui)
285 use_browser = 1; 287 use_browser = 1;
286 288
287 setup_browser(true); 289 setup_browser(true);
@@ -302,7 +304,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used)
302 if (argc > 1) 304 if (argc > 1)
303 usage_with_options(annotate_usage, options); 305 usage_with_options(annotate_usage, options);
304 306
305 sym_hist_filter = argv[0]; 307 annotate.sym_hist_filter = argv[0];
306 } 308 }
307 309
308 if (field_sep && *field_sep == '.') { 310 if (field_sep && *field_sep == '.') {