Newer
Older
page_size = sysconf(_SC_PAGE_SIZE);
argc = parse_options(argc, argv, options, top_usage, 0);
if (argc)
usage_with_options(top_usage, options);
/*
* XXX For now start disabled, only using TUI if explicitely asked for.
* Change that when handle_keys equivalent gets written, live annotation
* done, etc.
*/
use_browser = 0;
if (use_stdio)
use_browser = 0;
else if (use_tui)
use_browser = 1;
setup_browser(false);
/* CPU and PID are mutually exclusive */
if (top.target_tid > 0 && top.cpu_list) {
printf("WARNING: PID switch overriding CPU\n");
sleep(1);
top.cpu_list = NULL;
if (top.target_pid != -1)
top.target_tid = top.target_pid;
if (perf_evlist__create_maps(top.evlist, top.target_pid,
top.target_tid, top.cpu_list) < 0)
usage_with_options(top_usage, options);
if (!top.evlist->nr_entries &&
perf_evlist__add_default(top.evlist) < 0) {
pr_err("Not enough memory for event selector list\n");
return -ENOMEM;
}
if (top.delay_secs < 1)
top.delay_secs = 1;
/*
* User specified count overrides default frequency.
*/
if (default_interval)
top.freq = 0;
else if (top.freq) {
default_interval = top.freq;
} else {
fprintf(stderr, "frequency and count are zero, aborting\n");
exit(EXIT_FAILURE);
}
list_for_each_entry(pos, &top.evlist->entries, node) {
if (perf_evsel__alloc_fd(pos, top.evlist->cpus->nr,
top.evlist->threads->nr) < 0)
goto out_free_fd;
/*
* Fill in the ones not specifically initialized via -c:
*/
if (pos->attr.sample_period)
continue;
pos->attr.sample_period = default_interval;
}
if (perf_evlist__alloc_pollfd(top.evlist) < 0 ||
perf_evlist__alloc_mmap(top.evlist) < 0)
top.sym_evsel = list_entry(top.evlist->entries.next, struct perf_evsel, node);
symbol_conf.priv_size = (sizeof(struct sym_entry) + sizeof(struct annotation) +
(top.evlist->nr_entries + 1) * sizeof(unsigned long));
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
if (symbol__init() < 0)
return -1;
get_term_dimensions(&winsize);
if (top.print_entries == 0) {
update_print_entries(&winsize);
signal(SIGWINCH, sig_winch_handler);
}
status = __cmd_top();
out_free_fd:
perf_evlist__delete(top.evlist);