Lines Matching +full:stdout +full:- +full:path
2 * builtin-top.c
36 #include "util/parse-options.h"
37 #include "util/parse-events.h"
73 ws->ws_row = atoi(s); in get_term_dimensions()
76 ws->ws_col = atoi(s); in get_term_dimensions()
77 if (ws->ws_row && ws->ws_col) in get_term_dimensions()
83 ws->ws_row && ws->ws_col) in get_term_dimensions()
86 ws->ws_row = 25; in get_term_dimensions()
87 ws->ws_col = 80; in get_term_dimensions()
92 if (top->print_entries > 9) in perf_top__update_print_entries()
93 top->print_entries -= 9; in perf_top__update_print_entries()
100 get_term_dimensions(&top->winsize); in perf_top__sig_winch()
101 if (!top->print_entries in perf_top__sig_winch()
102 || (top->print_entries+4) > top->winsize.ws_row) { in perf_top__sig_winch()
103 top->print_entries = top->winsize.ws_row; in perf_top__sig_winch()
105 top->print_entries += 4; in perf_top__sig_winch()
106 top->winsize.ws_row = top->print_entries; in perf_top__sig_winch()
116 int err = -1; in perf_top__parse_source()
118 if (!he || !he->ms.sym) in perf_top__parse_source()
119 return -1; in perf_top__parse_source()
121 sym = he->ms.sym; in perf_top__parse_source()
122 map = he->ms.map; in perf_top__parse_source()
127 if (map->dso->symtab_type == SYMTAB__KALLSYMS) { in perf_top__parse_source()
129 "path\n", sym->name); in perf_top__parse_source()
131 return -1; in perf_top__parse_source()
135 if (notes->src != NULL) { in perf_top__parse_source()
136 pthread_mutex_lock(¬es->lock); in perf_top__parse_source()
140 pthread_mutex_lock(¬es->lock); in perf_top__parse_source()
143 pthread_mutex_unlock(¬es->lock); in perf_top__parse_source()
145 sym->name); in perf_top__parse_source()
153 top->sym_filter_entry = he; in perf_top__parse_source()
156 pthread_mutex_unlock(¬es->lock); in perf_top__parse_source()
162 struct symbol *sym = he->ms.sym; in __zero_source_counters()
173 if (he == NULL || he->ms.sym == NULL || in perf_top__record_precise_ip()
174 ((top->sym_filter_entry == NULL || in perf_top__record_precise_ip()
175 top->sym_filter_entry->ms.sym != he->ms.sym) && use_browser != 1)) in perf_top__record_precise_ip()
178 sym = he->ms.sym; in perf_top__record_precise_ip()
181 if (pthread_mutex_trylock(¬es->lock)) in perf_top__record_precise_ip()
184 if (notes->src == NULL && symbol__alloc_hist(sym) < 0) { in perf_top__record_precise_ip()
185 pthread_mutex_unlock(¬es->lock); in perf_top__record_precise_ip()
187 sym->name); in perf_top__record_precise_ip()
192 ip = he->ms.map->map_ip(he->ms.map, ip); in perf_top__record_precise_ip()
193 symbol__inc_addr_samples(sym, he->ms.map, counter, ip); in perf_top__record_precise_ip()
195 pthread_mutex_unlock(¬es->lock); in perf_top__record_precise_ip()
200 struct hist_entry *he = top->sym_filter_entry; in perf_top__show_details()
208 symbol = he->ms.sym; in perf_top__show_details()
211 pthread_mutex_lock(¬es->lock); in perf_top__show_details()
213 if (notes->src == NULL) in perf_top__show_details()
216 printf("Showing %s for %s\n", event_name(top->sym_evsel), symbol->name); in perf_top__show_details()
217 printf(" Events Pcnt (>=%d%%)\n", top->sym_pcnt_filter); in perf_top__show_details()
219 more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel->idx, in perf_top__show_details()
220 0, top->sym_pcnt_filter, top->print_entries, 4); in perf_top__show_details()
221 if (top->zero) in perf_top__show_details()
222 symbol__annotate_zero_histogram(symbol, top->sym_evsel->idx); in perf_top__show_details()
224 symbol__annotate_decay_histogram(symbol, top->sym_evsel->idx); in perf_top__show_details()
228 pthread_mutex_unlock(¬es->lock); in perf_top__show_details()
239 he = __hists__add_entry(&evsel->hists, al, NULL, sample->period); in perf_evsel__add_hist_entry()
243 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); in perf_evsel__add_hist_entry()
251 const int win_width = top->winsize.ws_col - 1; in perf_top__print_sym_table()
260 printf("%-*.*s\n", win_width, win_width, graph_dotted_line); in perf_top__print_sym_table()
262 if (top->sym_evsel->hists.stats.nr_lost_warned != in perf_top__print_sym_table()
263 top->sym_evsel->hists.stats.nr_events[PERF_RECORD_LOST]) { in perf_top__print_sym_table()
264 top->sym_evsel->hists.stats.nr_lost_warned = in perf_top__print_sym_table()
265 top->sym_evsel->hists.stats.nr_events[PERF_RECORD_LOST]; in perf_top__print_sym_table()
266 color_fprintf(stdout, PERF_COLOR_RED, in perf_top__print_sym_table()
268 top->sym_evsel->hists.stats.nr_lost_warned); in perf_top__print_sym_table()
272 if (top->sym_filter_entry) { in perf_top__print_sym_table()
277 hists__collapse_resort_threaded(&top->sym_evsel->hists); in perf_top__print_sym_table()
278 hists__output_resort_threaded(&top->sym_evsel->hists); in perf_top__print_sym_table()
279 hists__decay_entries_threaded(&top->sym_evsel->hists, in perf_top__print_sym_table()
280 top->hide_user_symbols, in perf_top__print_sym_table()
281 top->hide_kernel_symbols); in perf_top__print_sym_table()
282 hists__output_recalc_col_len(&top->sym_evsel->hists, in perf_top__print_sym_table()
283 top->winsize.ws_row - 3); in perf_top__print_sym_table()
285 hists__fprintf(&top->sym_evsel->hists, NULL, false, false, in perf_top__print_sym_table()
286 top->winsize.ws_row - 4 - printed, win_width, stdout); in perf_top__print_sym_table()
295 fprintf(stdout, "\n%s: ", msg); in prompt_integer()
327 struct hist_entry *syme = top->sym_filter_entry, *n, *found = NULL; in perf_top__prompt_symbol()
334 top->sym_filter_entry = NULL; in perf_top__prompt_symbol()
337 fprintf(stdout, "\n%s: ", msg); in perf_top__prompt_symbol()
345 next = rb_first(&top->sym_evsel->hists.entries); in perf_top__prompt_symbol()
348 if (n->ms.sym && !strcmp(buf, n->ms.sym->name)) { in perf_top__prompt_symbol()
352 next = rb_next(&n->rb_node); in perf_top__prompt_symbol()
369 if (top->sym_filter_entry) { in perf_top__print_mapped_keys()
370 struct symbol *sym = top->sym_filter_entry->ms.sym; in perf_top__print_mapped_keys()
371 name = sym->name; in perf_top__print_mapped_keys()
374 fprintf(stdout, "\nMapped keys:\n"); in perf_top__print_mapped_keys()
375 fprintf(stdout, "\t[d] display refresh delay. \t(%d)\n", top->delay_secs); in perf_top__print_mapped_keys()
376 fprintf(stdout, "\t[e] display entries (lines). \t(%d)\n", top->print_entries); in perf_top__print_mapped_keys()
378 if (top->evlist->nr_entries > 1) in perf_top__print_mapped_keys()
379 …fprintf(stdout, "\t[E] active event counter. \t(%s)\n", event_name(top->sym_evsel… in perf_top__print_mapped_keys()
381 fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", top->count_filter); in perf_top__print_mapped_keys()
383 fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", top->sym_pcnt_filter); in perf_top__print_mapped_keys()
384 fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL"); in perf_top__print_mapped_keys()
385 fprintf(stdout, "\t[S] stop annotation.\n"); in perf_top__print_mapped_keys()
387 fprintf(stdout, in perf_top__print_mapped_keys()
389 top->hide_kernel_symbols ? "yes" : "no"); in perf_top__print_mapped_keys()
390 fprintf(stdout, in perf_top__print_mapped_keys()
392 top->hide_user_symbols ? "yes" : "no"); in perf_top__print_mapped_keys()
393 fprintf(stdout, "\t[z] toggle sample zeroing. \t(%d)\n", top->zero ? 1 : 0); in perf_top__print_mapped_keys()
394 fprintf(stdout, "\t[qQ] quit.\n"); in perf_top__print_mapped_keys()
413 return top->evlist->nr_entries > 1 ? 1 : 0; in perf_top__key_mapped()
428 fprintf(stdout, "\nEnter selection, or unmapped key to continue: "); in perf_top__handle_keypress()
429 fflush(stdout); in perf_top__handle_keypress()
438 poll(&stdin_poll, 1, -1); in perf_top__handle_keypress()
448 prompt_integer(&top->delay_secs, "Enter display delay"); in perf_top__handle_keypress()
449 if (top->delay_secs < 1) in perf_top__handle_keypress()
450 top->delay_secs = 1; in perf_top__handle_keypress()
453 prompt_integer(&top->print_entries, "Enter display entries (lines)"); in perf_top__handle_keypress()
454 if (top->print_entries == 0) { in perf_top__handle_keypress()
467 if (top->evlist->nr_entries > 1) { in perf_top__handle_keypress()
473 list_for_each_entry(top->sym_evsel, &top->evlist->entries, node) in perf_top__handle_keypress()
474 fprintf(stderr, "\n\t%d %s", top->sym_evsel->idx, event_name(top->sym_evsel)); in perf_top__handle_keypress()
478 if (counter >= top->evlist->nr_entries) { in perf_top__handle_keypress()
479 top->sym_evsel = list_entry(top->evlist->entries.next, struct perf_evsel, node); in perf_top__handle_keypress()
480 fprintf(stderr, "Sorry, no such event, using %s.\n", event_name(top->sym_evsel)); in perf_top__handle_keypress()
484 list_for_each_entry(top->sym_evsel, &top->evlist->entries, node) in perf_top__handle_keypress()
485 if (top->sym_evsel->idx == counter) in perf_top__handle_keypress()
488 top->sym_evsel = list_entry(top->evlist->entries.next, struct perf_evsel, node); in perf_top__handle_keypress()
491 prompt_integer(&top->count_filter, "Enter display event count filter"); in perf_top__handle_keypress()
494 prompt_percent(&top->sym_pcnt_filter, in perf_top__handle_keypress()
498 top->hide_kernel_symbols = !top->hide_kernel_symbols; in perf_top__handle_keypress()
503 if (top->dump_symtab) in perf_top__handle_keypress()
504 perf_session__fprintf_dsos(top->session, stderr); in perf_top__handle_keypress()
510 if (!top->sym_filter_entry) in perf_top__handle_keypress()
513 struct hist_entry *syme = top->sym_filter_entry; in perf_top__handle_keypress()
515 top->sym_filter_entry = NULL; in perf_top__handle_keypress()
520 top->hide_user_symbols = !top->hide_user_symbols; in perf_top__handle_keypress()
523 top->zero = !top->zero; in perf_top__handle_keypress()
535 if (t->evlist->selected != NULL) in perf_top__sort_new_samples()
536 t->sym_evsel = t->evlist->selected; in perf_top__sort_new_samples()
538 hists__collapse_resort_threaded(&t->sym_evsel->hists); in perf_top__sort_new_samples()
539 hists__output_resort_threaded(&t->sym_evsel->hists); in perf_top__sort_new_samples()
540 hists__decay_entries_threaded(&t->sym_evsel->hists, in perf_top__sort_new_samples()
541 t->hide_user_symbols, in perf_top__sort_new_samples()
542 t->hide_kernel_symbols); in perf_top__sort_new_samples()
548 const char *help = "For a higher level overview, try: perf top --sort comm,dso"; in display_thread_tui()
551 perf_evlist__tui_browse_hists(top->evlist, help, in display_thread_tui()
553 top, top->delay_secs); in display_thread_tui()
575 delay_msecs = top->delay_secs * 1000; in display_thread()
589 case -1: in display_thread()
624 const char *name = sym->name; in symbol_filter()
645 sym->ignore = true; in symbol_filter()
661 u64 ip = event->ip.ip; in perf_event__process_sample()
667 event->ip.pid); in perf_event__process_sample()
671 if (event->header.misc & PERF_RECORD_MISC_EXACT_IP) in perf_event__process_sample()
672 top->exact_samples++; in perf_event__process_sample()
679 if (!top->kptr_restrict_warned && in perf_event__process_sample()
686 !RB_EMPTY_ROOT(&al.map->dso->symbols[MAP__FUNCTION]) ? in perf_event__process_sample()
690 top->kptr_restrict_warned = true; in perf_event__process_sample()
702 * We may never get here, for instance, if we use -K/ in perf_event__process_sample()
703 * --hide-kernel-symbols, even if the user specifies an in perf_event__process_sample()
704 * invalid --vmlinux ;-) in perf_event__process_sample()
706 if (!top->kptr_restrict_warned && !top->vmlinux_warned && in perf_event__process_sample()
707 al.map == machine->vmlinux_maps[MAP__FUNCTION] && in perf_event__process_sample()
708 RB_EMPTY_ROOT(&al.map->dso->symbols[MAP__FUNCTION])) { in perf_event__process_sample()
719 top->vmlinux_warned = true; in perf_event__process_sample()
723 if (al.sym == NULL || !al.sym->ignore) { in perf_event__process_sample()
727 sample->callchain) { in perf_event__process_sample()
729 sample->callchain, &parent); in perf_event__process_sample()
741 err = callchain_append(he->callchain, &evsel->hists.callchain_cursor, in perf_event__process_sample()
742 sample->period); in perf_event__process_sample()
747 if (top->sort_has_symbols) in perf_event__process_sample()
748 perf_top__record_precise_ip(top, he, evsel->idx, ip); in perf_event__process_sample()
758 struct perf_session *session = top->session; in perf_top__mmap_read_idx()
764 while ((event = perf_evlist__mmap_read(top->evlist, idx)) != NULL) { in perf_top__mmap_read_idx()
771 evsel = perf_evlist__id2evsel(session->evlist, sample.id); in perf_top__mmap_read_idx()
774 origin = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; in perf_top__mmap_read_idx()
776 if (event->header.type == PERF_RECORD_SAMPLE) in perf_top__mmap_read_idx()
777 ++top->samples; in perf_top__mmap_read_idx()
781 ++top->us_samples; in perf_top__mmap_read_idx()
782 if (top->hide_user_symbols) in perf_top__mmap_read_idx()
787 ++top->kernel_samples; in perf_top__mmap_read_idx()
788 if (top->hide_kernel_symbols) in perf_top__mmap_read_idx()
793 ++top->guest_kernel_samples; in perf_top__mmap_read_idx()
794 machine = perf_session__find_machine(session, event->ip.pid); in perf_top__mmap_read_idx()
797 ++top->guest_us_samples; in perf_top__mmap_read_idx()
808 if (event->header.type == PERF_RECORD_SAMPLE) { in perf_top__mmap_read_idx()
809 perf_event__process_sample(&top->tool, event, evsel, in perf_top__mmap_read_idx()
811 } else if (event->header.type < PERF_RECORD_MAX) { in perf_top__mmap_read_idx()
812 hists__inc_nr_events(&evsel->hists, event->header.type); in perf_top__mmap_read_idx()
813 perf_event__process(&top->tool, event, &sample, machine); in perf_top__mmap_read_idx()
815 ++session->hists.stats.nr_unknown_events; in perf_top__mmap_read_idx()
823 for (i = 0; i < top->evlist->nr_mmaps; i++) in perf_top__mmap_read()
830 struct perf_evlist *evlist = top->evlist; in perf_top__start_counters()
832 first = list_entry(evlist->entries.next, struct perf_evsel, node); in perf_top__start_counters()
834 list_for_each_entry(counter, &evlist->entries, node) { in perf_top__start_counters()
835 struct perf_event_attr *attr = &counter->attr; in perf_top__start_counters()
838 if (top->group && counter != first) in perf_top__start_counters()
839 group_fd = first->fd; in perf_top__start_counters()
841 attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID; in perf_top__start_counters()
843 if (top->freq) { in perf_top__start_counters()
844 attr->sample_type |= PERF_SAMPLE_PERIOD; in perf_top__start_counters()
845 attr->freq = 1; in perf_top__start_counters()
846 attr->sample_freq = top->freq; in perf_top__start_counters()
849 if (evlist->nr_entries > 1) { in perf_top__start_counters()
850 attr->sample_type |= PERF_SAMPLE_ID; in perf_top__start_counters()
851 attr->read_format |= PERF_FORMAT_ID; in perf_top__start_counters()
855 attr->sample_type |= PERF_SAMPLE_CALLCHAIN; in perf_top__start_counters()
857 attr->mmap = 1; in perf_top__start_counters()
858 attr->comm = 1; in perf_top__start_counters()
859 attr->inherit = top->inherit; in perf_top__start_counters()
861 if (top->exclude_guest_missing) in perf_top__start_counters()
862 attr->exclude_guest = attr->exclude_host = 0; in perf_top__start_counters()
864 attr->sample_id_all = top->sample_id_all_avail ? 1 : 0; in perf_top__start_counters()
866 if (perf_evsel__open(counter, top->evlist->cpus, in perf_top__start_counters()
867 top->evlist->threads, top->group, in perf_top__start_counters()
875 if (!top->exclude_guest_missing && in perf_top__start_counters()
876 (attr->exclude_guest || attr->exclude_host)) { in perf_top__start_counters()
879 top->exclude_guest_missing = true; in perf_top__start_counters()
881 } else if (top->sample_id_all_avail) { in perf_top__start_counters()
883 * Old kernel, no attr->sample_id_type_all field in perf_top__start_counters()
885 top->sample_id_all_avail = false; in perf_top__start_counters()
891 * based cpu-clock-tick sw counter, which in perf_top__start_counters()
894 if (attr->type == PERF_TYPE_HARDWARE && in perf_top__start_counters()
895 attr->config == PERF_COUNT_HW_CPU_CYCLES) { in perf_top__start_counters()
898 "trying to fall back to cpu-clock-ticks\n"); in perf_top__start_counters()
900 attr->type = PERF_TYPE_SOFTWARE; in perf_top__start_counters()
901 attr->config = PERF_COUNT_SW_CPU_CLOCK; in perf_top__start_counters()
924 if (perf_evlist__mmap(evlist, top->mmap_pages, false) < 0) { in perf_top__start_counters()
939 if (!top->sort_has_symbols) { in perf_top__setup_sample_type()
941 ui__warning("Selected -g but \"sym\" not present in --sort/-s."); in perf_top__setup_sample_type()
942 return -EINVAL; in perf_top__setup_sample_type()
944 } else if (!top->dont_use_callchains && callchain_param.mode != CHAIN_NONE) { in perf_top__setup_sample_type()
947 return -EINVAL; in perf_top__setup_sample_type()
962 top->session = perf_session__new(NULL, O_WRONLY, false, false, NULL); in __cmd_top()
963 if (top->session == NULL) in __cmd_top()
964 return -ENOMEM; in __cmd_top()
970 if (top->target_tid != -1) in __cmd_top()
971 perf_event__synthesize_thread_map(&top->tool, top->evlist->threads, in __cmd_top()
973 &top->session->host_machine); in __cmd_top()
975 perf_event__synthesize_threads(&top->tool, perf_event__process, in __cmd_top()
976 &top->session->host_machine); in __cmd_top()
978 top->session->evlist = top->evlist; in __cmd_top()
979 perf_session__update_sample_type(top->session); in __cmd_top()
982 poll(top->evlist->pollfd, top->evlist->nr_fds, 100); in __cmd_top()
989 exit(-1); in __cmd_top()
992 if (top->realtime_prio) { in __cmd_top()
995 param.sched_priority = top->realtime_prio; in __cmd_top()
998 exit(-1); in __cmd_top()
1003 u64 hits = top->samples; in __cmd_top()
1007 if (hits == top->samples) in __cmd_top()
1008 ret = poll(top->evlist->pollfd, top->evlist->nr_fds, 100); in __cmd_top()
1012 perf_session__delete(top->session); in __cmd_top()
1013 top->session = NULL; in __cmd_top()
1021 struct perf_top *top = (struct perf_top *)opt->value; in parse_callchain_opt()
1026 * --no-call-graph in parse_callchain_opt()
1029 top->dont_use_callchains = true; in parse_callchain_opt()
1040 return -1; in parse_callchain_opt()
1058 return -1; in parse_callchain_opt()
1067 return -1; in parse_callchain_opt()
1087 return -1; in parse_callchain_opt()
1091 return -1; in parse_callchain_opt()
1104 int status = -ENOMEM; in cmd_top()
1108 .target_pid = -1, in cmd_top()
1109 .target_tid = -1, in cmd_top()
1126 OPT_BOOLEAN('a', "all-cpus", &top.system_wide, in cmd_top()
1127 "system-wide collection from all CPUs"), in cmd_top()
1134 OPT_UINTEGER('m', "mmap-pages", &top.mmap_pages, "number of mmap data pages"), in cmd_top()
1139 OPT_BOOLEAN('D', "dump-symtab", &top.dump_symtab, in cmd_top()
1141 OPT_INTEGER('f', "count-filter", &top.count_filter, in cmd_top()
1147 OPT_STRING(0, "sym-annotate", &top.sym_filter, "symbol name", in cmd_top()
1163 OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples, in cmd_top()
1165 OPT_CALLBACK_DEFAULT('G', "call-graph", &top, "output_type,min_percent, call_order", in cmd_top()
1169 OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, in cmd_top()
1179 OPT_BOOLEAN(0, "asm-raw", &symbol_conf.annotate_asm_raw, in cmd_top()
1181 OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style", in cmd_top()
1182 "Specify disassembler style (e.g. -M intel for intel syntax)"), in cmd_top()
1188 return -ENOMEM; in cmd_top()
1215 if (top.target_pid != -1) in cmd_top()
1222 if (!top.evlist->nr_entries && in cmd_top()
1225 return -ENOMEM; in cmd_top()
1228 symbol_conf.nr_events = top.evlist->nr_entries; in cmd_top()
1245 list_for_each_entry(pos, &top.evlist->entries, node) { in cmd_top()
1247 * Fill in the ones not specifically initialized via -c: in cmd_top()
1249 if (!pos->attr.sample_period) in cmd_top()
1250 pos->attr.sample_period = top.default_interval; in cmd_top()
1253 top.sym_evsel = list_entry(top.evlist->entries.next, struct perf_evsel, node); in cmd_top()
1259 return -1; in cmd_top()
1261 sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout); in cmd_top()
1262 sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout); in cmd_top()
1263 sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout); in cmd_top()