Lines Matching refs:trace
54 struct trace { struct
274 struct trace *trace; member
973 struct trace *trace) in thread__fd_path() argument
984 if (!trace->live) in thread__fd_path()
986 ++trace->stats.proc_getname; in thread__fd_path()
999 const char *path = thread__fd_path(arg->thread, fd, arg->trace); in syscall_arg__scnprintf_fd()
1034 if (!arg->trace->vfs_getname) in syscall_arg__scnprintf_filename()
1041 static bool trace__filter_duration(struct trace *trace, double t) in trace__filter_duration() argument
1043 return t < (trace->duration_filter * NSEC_PER_MSEC); in trace__filter_duration()
1046 static size_t __trace__fprintf_tstamp(struct trace *trace, u64 tstamp, FILE *fp) in __trace__fprintf_tstamp() argument
1048 double ts = (double)(tstamp - trace->base_time) / NSEC_PER_MSEC; in __trace__fprintf_tstamp()
1059 static size_t trace__fprintf_tstamp(struct trace *trace, u64 tstamp, FILE *fp) in trace__fprintf_tstamp() argument
1062 return __trace__fprintf_tstamp(trace, tstamp, fp); in trace__fprintf_tstamp()
1076 static size_t trace__fprintf_entry_head(struct trace *trace, struct thread *thread, in trace__fprintf_entry_head() argument
1079 size_t printed = trace__fprintf_tstamp(trace, tstamp, fp); in trace__fprintf_entry_head()
1082 if (trace->multiple_threads) { in trace__fprintf_entry_head()
1083 if (trace->show_comm) in trace__fprintf_entry_head()
1091 static int trace__process_event(struct trace *trace, struct machine *machine, in trace__process_event() argument
1098 color_fprintf(trace->output, PERF_COLOR_RED, in trace__process_event()
1115 struct trace *trace = container_of(tool, struct trace, tool); in trace__tool_process() local
1116 return trace__process_event(trace, machine, event, sample); in trace__tool_process()
1137 static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist) in trace__symbols_init() argument
1144 trace->host = machine__new_host(); in trace__symbols_init()
1145 if (trace->host == NULL) in trace__symbols_init()
1148 if (trace_event__register_resolver(trace->host, trace__machine__resolve_kernel_addr) < 0) in trace__symbols_init()
1151 err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target, in trace__symbols_init()
1153 trace->opts.proc_map_timeout); in trace__symbols_init()
1206 static int trace__read_syscall_info(struct trace *trace, int id) in trace__read_syscall_info() argument
1210 const char *name = syscalltbl__name(trace->sctbl, id); in trace__read_syscall_info()
1215 if (id > trace->syscalls.max) { in trace__read_syscall_info()
1216 struct syscall *nsyscalls = realloc(trace->syscalls.table, (id + 1) * sizeof(*sc)); in trace__read_syscall_info()
1221 if (trace->syscalls.max != -1) { in trace__read_syscall_info()
1222 memset(nsyscalls + trace->syscalls.max + 1, 0, in trace__read_syscall_info()
1223 (id - trace->syscalls.max) * sizeof(*sc)); in trace__read_syscall_info()
1228 trace->syscalls.table = nsyscalls; in trace__read_syscall_info()
1229 trace->syscalls.max = id; in trace__read_syscall_info()
1232 sc = trace->syscalls.table + id; in trace__read_syscall_info()
1265 static int trace__validate_ev_qualifier(struct trace *trace) in trace__validate_ev_qualifier() argument
1270 trace->ev_qualifier_ids.nr = strlist__nr_entries(trace->ev_qualifier); in trace__validate_ev_qualifier()
1271 trace->ev_qualifier_ids.entries = malloc(trace->ev_qualifier_ids.nr * in trace__validate_ev_qualifier()
1272 sizeof(trace->ev_qualifier_ids.entries[0])); in trace__validate_ev_qualifier()
1274 if (trace->ev_qualifier_ids.entries == NULL) { in trace__validate_ev_qualifier()
1276 trace->output); in trace__validate_ev_qualifier()
1283 strlist__for_each_entry(pos, trace->ev_qualifier) { in trace__validate_ev_qualifier()
1285 int id = syscalltbl__id(trace->sctbl, sc); in trace__validate_ev_qualifier()
1289 fputs("Error:\tInvalid syscall ", trace->output); in trace__validate_ev_qualifier()
1292 fputs(", ", trace->output); in trace__validate_ev_qualifier()
1295 fputs(sc, trace->output); in trace__validate_ev_qualifier()
1298 trace->ev_qualifier_ids.entries[i++] = id; in trace__validate_ev_qualifier()
1303 "\nHint:\tand: 'man syscalls'\n", trace->output); in trace__validate_ev_qualifier()
1304 zfree(&trace->ev_qualifier_ids.entries); in trace__validate_ev_qualifier()
1305 trace->ev_qualifier_ids.nr = 0; in trace__validate_ev_qualifier()
1321 unsigned char *args, struct trace *trace, in syscall__scnprintf_args() argument
1334 .trace = trace, in syscall__scnprintf_args()
1393 typedef int (*tracepoint_handler)(struct trace *trace, struct perf_evsel *evsel,
1397 static struct syscall *trace__syscall_info(struct trace *trace, in trace__syscall_info() argument
1415 fprintf(trace->output, "Invalid syscall %d id, skipping (%s, %" PRIu64 ") ...\n", in trace__syscall_info()
1421 if ((id > trace->syscalls.max || trace->syscalls.table[id].name == NULL) && in trace__syscall_info()
1422 trace__read_syscall_info(trace, id)) in trace__syscall_info()
1425 if ((id > trace->syscalls.max || trace->syscalls.table[id].name == NULL)) in trace__syscall_info()
1428 return &trace->syscalls.table[id]; in trace__syscall_info()
1432 fprintf(trace->output, "Problems reading syscall %d", id); in trace__syscall_info()
1433 if (id <= trace->syscalls.max && trace->syscalls.table[id].name != NULL) in trace__syscall_info()
1434 fprintf(trace->output, "(%s)", trace->syscalls.table[id].name); in trace__syscall_info()
1435 fputs(" information\n", trace->output); in trace__syscall_info()
1466 static int trace__printf_interrupted_entry(struct trace *trace, struct perf_sample *sample) in trace__printf_interrupted_entry() argument
1472 if (trace->current == NULL) in trace__printf_interrupted_entry()
1475 ttrace = thread__priv(trace->current); in trace__printf_interrupted_entry()
1482 …printed = trace__fprintf_entry_head(trace, trace->current, duration, true, ttrace->entry_time, tr… in trace__printf_interrupted_entry()
1483 printed += fprintf(trace->output, "%-70s) ...\n", ttrace->entry_str); in trace__printf_interrupted_entry()
1489 static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel, in trace__sys_enter() argument
1498 struct syscall *sc = trace__syscall_info(trace, evsel, id); in trace__sys_enter()
1504 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); in trace__sys_enter()
1505 ttrace = thread__trace(thread, trace->output); in trace__sys_enter()
1517 if (!(trace->duration_filter || trace->summary_only || trace->min_stack)) in trace__sys_enter()
1518 trace__printf_interrupted_entry(trace, sample); in trace__sys_enter()
1525 args, trace, thread); in trace__sys_enter()
1528 if (!(trace->duration_filter || trace->summary_only || trace->min_stack)) { in trace__sys_enter()
1529 trace__fprintf_entry_head(trace, thread, 0, false, ttrace->entry_time, trace->output); in trace__sys_enter()
1530 fprintf(trace->output, "%-70s)\n", ttrace->entry_str); in trace__sys_enter()
1538 if (trace->current != thread) { in trace__sys_enter()
1539 thread__put(trace->current); in trace__sys_enter()
1540 trace->current = thread__get(thread); in trace__sys_enter()
1548 static int trace__resolve_callchain(struct trace *trace, struct perf_evsel *evsel, in trace__resolve_callchain() argument
1554 if (machine__resolve(trace->host, &al, sample) < 0 || in trace__resolve_callchain()
1555 thread__resolve_callchain(al.thread, cursor, evsel, sample, NULL, NULL, trace->max_stack)) in trace__resolve_callchain()
1561 static int trace__fprintf_callchain(struct trace *trace, struct perf_sample *sample) in trace__fprintf_callchain() argument
1568 return sample__fprintf_callchain(sample, 38, print_opts, &callchain_cursor, trace->output); in trace__fprintf_callchain()
1571 static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel, in trace__sys_exit() argument
1580 struct syscall *sc = trace__syscall_info(trace, evsel, id); in trace__sys_exit()
1586 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); in trace__sys_exit()
1587 ttrace = thread__trace(thread, trace->output); in trace__sys_exit()
1591 if (trace->summary) in trace__sys_exit()
1596 if (id == trace->open_id && ret >= 0 && ttrace->filename.pending_open) { in trace__sys_exit()
1599 ++trace->stats.vfs_getname; in trace__sys_exit()
1606 if (trace__filter_duration(trace, duration)) in trace__sys_exit()
1609 } else if (trace->duration_filter) in trace__sys_exit()
1613 callchain_ret = trace__resolve_callchain(trace, evsel, sample, &callchain_cursor); in trace__sys_exit()
1615 if (callchain_cursor.nr < trace->min_stack) in trace__sys_exit()
1621 if (trace->summary_only) in trace__sys_exit()
1624 …trace__fprintf_entry_head(trace, thread, duration, duration_calculated, ttrace->entry_time, trace-… in trace__sys_exit()
1627 fprintf(trace->output, "%-70s", ttrace->entry_str); in trace__sys_exit()
1629 fprintf(trace->output, " ... ["); in trace__sys_exit()
1630 color_fprintf(trace->output, PERF_COLOR_YELLOW, "continued"); in trace__sys_exit()
1631 fprintf(trace->output, "]: %s()", sc->name); in trace__sys_exit()
1636 fprintf(trace->output, ") = %ld", ret); in trace__sys_exit()
1642 fprintf(trace->output, ") = -1 %s %s", e, emsg); in trace__sys_exit()
1644 fprintf(trace->output, ") = 0 Timeout"); in trace__sys_exit()
1646 fprintf(trace->output, ") = %#lx", ret); in trace__sys_exit()
1648 struct thread *child = machine__find_thread(trace->host, ret, ret); in trace__sys_exit()
1651 fprintf(trace->output, ") = %ld", ret); in trace__sys_exit()
1653 fprintf(trace->output, " (%s)", thread__comm_str(child)); in trace__sys_exit()
1659 fputc('\n', trace->output); in trace__sys_exit()
1662 trace__fprintf_callchain(trace, sample); in trace__sys_exit()
1673 static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel, in trace__vfs_getname() argument
1677 struct thread *thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); in trace__vfs_getname()
1730 static int trace__sched_stat_runtime(struct trace *trace, struct perf_evsel *evsel, in trace__sched_stat_runtime() argument
1736 struct thread *thread = machine__findnew_thread(trace->host, in trace__sched_stat_runtime()
1739 struct thread_trace *ttrace = thread__trace(thread, trace->output); in trace__sched_stat_runtime()
1745 trace->runtime_ms += runtime_ms; in trace__sched_stat_runtime()
1750 fprintf(trace->output, "%s: comm=%s,pid=%u,runtime=%" PRIu64 ",vruntime=%" PRIu64 ")\n", in trace__sched_stat_runtime()
1784 static void bpf_output__fprintf(struct trace *trace, in bpf_output__fprintf() argument
1788 bpf_output__printer, trace->output); in bpf_output__fprintf()
1791 static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, in trace__event_handler() argument
1798 callchain_ret = trace__resolve_callchain(trace, evsel, sample, &callchain_cursor); in trace__event_handler()
1800 if (callchain_cursor.nr < trace->min_stack) in trace__event_handler()
1806 trace__printf_interrupted_entry(trace, sample); in trace__event_handler()
1807 trace__fprintf_tstamp(trace, sample->time, trace->output); in trace__event_handler()
1809 if (trace->trace_syscalls) in trace__event_handler()
1810 fprintf(trace->output, "( ): "); in trace__event_handler()
1812 fprintf(trace->output, "%s:", evsel->name); in trace__event_handler()
1815 bpf_output__fprintf(trace, sample); in trace__event_handler()
1819 trace->output); in trace__event_handler()
1822 fprintf(trace->output, ")\n"); in trace__event_handler()
1825 trace__fprintf_callchain(trace, sample); in trace__event_handler()
1849 static int trace__pgfault(struct trace *trace, in trace__pgfault() argument
1861 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); in trace__pgfault()
1864 callchain_ret = trace__resolve_callchain(trace, evsel, sample, &callchain_cursor); in trace__pgfault()
1866 if (callchain_cursor.nr < trace->min_stack) in trace__pgfault()
1872 ttrace = thread__trace(thread, trace->output); in trace__pgfault()
1881 if (trace->summary_only) in trace__pgfault()
1887 trace__fprintf_entry_head(trace, thread, 0, true, sample->time, trace->output); in trace__pgfault()
1889 fprintf(trace->output, "%sfault [", in trace__pgfault()
1893 print_location(trace->output, sample, &al, false, true); in trace__pgfault()
1895 fprintf(trace->output, "] => "); in trace__pgfault()
1910 print_location(trace->output, sample, &al, true, false); in trace__pgfault()
1912 fprintf(trace->output, " (%c%c)\n", map_type, al.level); in trace__pgfault()
1915 trace__fprintf_callchain(trace, sample); in trace__pgfault()
1925 static bool skip_sample(struct trace *trace, struct perf_sample *sample) in skip_sample() argument
1927 if ((trace->pid_list && intlist__find(trace->pid_list, sample->pid)) || in skip_sample()
1928 (trace->tid_list && intlist__find(trace->tid_list, sample->tid))) in skip_sample()
1931 if (trace->pid_list || trace->tid_list) in skip_sample()
1937 static void trace__set_base_time(struct trace *trace, in trace__set_base_time() argument
1949 if (trace->base_time == 0 && !trace->full_time && in trace__set_base_time()
1951 trace->base_time = sample->time; in trace__set_base_time()
1960 struct trace *trace = container_of(tool, struct trace, tool); in trace__process_sample() local
1965 if (skip_sample(trace, sample)) in trace__process_sample()
1968 trace__set_base_time(trace, evsel, sample); in trace__process_sample()
1971 ++trace->nr_events; in trace__process_sample()
1972 handler(trace, evsel, event, sample); in trace__process_sample()
1978 static int parse_target_str(struct trace *trace) in parse_target_str() argument
1980 if (trace->opts.target.pid) { in parse_target_str()
1981 trace->pid_list = intlist__new(trace->opts.target.pid); in parse_target_str()
1982 if (trace->pid_list == NULL) { in parse_target_str()
1988 if (trace->opts.target.tid) { in parse_target_str()
1989 trace->tid_list = intlist__new(trace->opts.target.tid); in parse_target_str()
1990 if (trace->tid_list == NULL) { in parse_target_str()
1999 static int trace__record(struct trace *trace, int argc, const char **argv) in trace__record() argument
2029 if (trace->trace_syscalls) { in trace__record()
2044 if (trace->trace_pgfaults & TRACE_PFMAJ) in trace__record()
2048 if (trace->trace_pgfaults & TRACE_PFMIN) in trace__record()
2058 static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp);
2097 static void trace__handle_event(struct trace *trace, union perf_event *event, struct perf_sample *s… in trace__handle_event() argument
2103 trace__process_event(trace, trace->host, event, sample); in trace__handle_event()
2107 evsel = perf_evlist__id2evsel(trace->evlist, sample->id); in trace__handle_event()
2109 fprintf(trace->output, "Unknown tp ID %" PRIu64 ", skipping...\n", sample->id); in trace__handle_event()
2113 trace__set_base_time(trace, evsel, sample); in trace__handle_event()
2117 …fprintf(trace->output, "%s sample with no payload for tid: %d, cpu %d, raw_size=%d, skipping...\n", in trace__handle_event()
2122 handler(trace, evsel, event, sample); in trace__handle_event()
2126 static int trace__add_syscall_newtp(struct trace *trace) in trace__add_syscall_newtp() argument
2129 struct perf_evlist *evlist = trace->evlist; in trace__add_syscall_newtp()
2149 if (callchain_param.enabled && !trace->kernel_syscallchains) { in trace__add_syscall_newtp()
2158 trace->syscalls.events.sys_enter = sys_enter; in trace__add_syscall_newtp()
2159 trace->syscalls.events.sys_exit = sys_exit; in trace__add_syscall_newtp()
2172 static int trace__set_ev_qualifier_filter(struct trace *trace) in trace__set_ev_qualifier_filter() argument
2176 char *filter = asprintf_expr_inout_ints("id", !trace->not_ev_qualifier, in trace__set_ev_qualifier_filter()
2177 trace->ev_qualifier_ids.nr, in trace__set_ev_qualifier_filter()
2178 trace->ev_qualifier_ids.entries); in trace__set_ev_qualifier_filter()
2183 if (!perf_evsel__append_tp_filter(trace->syscalls.events.sys_enter, in trace__set_ev_qualifier_filter()
2185 sys_exit = trace->syscalls.events.sys_exit; in trace__set_ev_qualifier_filter()
2197 static int trace__run(struct trace *trace, int argc, const char **argv) in trace__run() argument
2199 struct perf_evlist *evlist = trace->evlist; in trace__run()
2206 trace->live = true; in trace__run()
2208 if (trace->trace_syscalls && trace__add_syscall_newtp(trace)) in trace__run()
2211 if (trace->trace_syscalls) in trace__run()
2212 trace->vfs_getname = perf_evlist__add_vfs_getname(evlist); in trace__run()
2214 if ((trace->trace_pgfaults & TRACE_PFMAJ)) { in trace__run()
2221 if ((trace->trace_pgfaults & TRACE_PFMIN)) { in trace__run()
2228 if (trace->sched && in trace__run()
2233 err = perf_evlist__create_maps(evlist, &trace->opts.target); in trace__run()
2235 fprintf(trace->output, "Problems parsing the target to trace, check your options!\n"); in trace__run()
2239 err = trace__symbols_init(trace, evlist); in trace__run()
2241 fprintf(trace->output, "Problems initializing symbol libraries!\n"); in trace__run()
2245 perf_evlist__config(evlist, &trace->opts, NULL); in trace__run()
2250 if (trace->syscalls.events.sys_exit) { in trace__run()
2251 perf_evsel__config_callchain(trace->syscalls.events.sys_exit, in trace__run()
2252 &trace->opts, &callchain_param); in trace__run()
2257 perf_evsel__config_callchain(pgfault_maj, &trace->opts, &callchain_param); in trace__run()
2262 perf_evsel__config_callchain(pgfault_min, &trace->opts, &callchain_param); in trace__run()
2289 err = perf_evlist__prepare_workload(evlist, &trace->opts.target, in trace__run()
2292 fprintf(trace->output, "Couldn't run the workload!\n"); in trace__run()
2317 if (trace->filter_pids.nr > 0) in trace__run()
2318 err = perf_evlist__set_filter_pids(evlist, trace->filter_pids.nr, trace->filter_pids.entries); in trace__run()
2325 if (trace->ev_qualifier_ids.nr > 0) { in trace__run()
2326 err = trace__set_ev_qualifier_filter(trace); in trace__run()
2331 trace->syscalls.events.sys_exit->filter); in trace__run()
2338 err = perf_evlist__mmap(evlist, trace->opts.mmap_pages, false); in trace__run()
2342 if (!target__none(&trace->opts.target)) in trace__run()
2348 trace->multiple_threads = thread_map__pid(evlist->threads, 0) == -1 || in trace__run()
2352 before = trace->nr_events; in trace__run()
2360 ++trace->nr_events; in trace__run()
2364 fprintf(trace->output, "Can't parse sample, err = %d, skipping...\n", err); in trace__run()
2368 trace__handle_event(trace, event, &sample); in trace__run()
2382 if (trace->nr_events == before) { in trace__run()
2396 thread__zput(trace->current); in trace__run()
2401 if (trace->summary) in trace__run()
2402 trace__fprintf_thread_summary(trace, trace->output); in trace__run()
2404 if (trace->show_tool_stats) { in trace__run()
2405 fprintf(trace->output, "Stats:\n " in trace__run()
2408 trace->stats.vfs_getname, in trace__run()
2409 trace->stats.proc_getname); in trace__run()
2415 trace->evlist = NULL; in trace__run()
2416 trace->live = false; in trace__run()
2437 fprintf(trace->output, "%s\n", errbuf); in trace__run()
2441 fprintf(trace->output, in trace__run()
2448 fprintf(trace->output, "Not enough memory to run!\n"); in trace__run()
2452 fprintf(trace->output, "errno=%d,%s\n", errno, strerror(errno)); in trace__run()
2456 static int trace__replay(struct trace *trace) in trace__replay() argument
2464 .force = trace->force, in trace__replay()
2470 trace->tool.sample = trace__process_sample; in trace__replay()
2471 trace->tool.mmap = perf_event__process_mmap; in trace__replay()
2472 trace->tool.mmap2 = perf_event__process_mmap2; in trace__replay()
2473 trace->tool.comm = perf_event__process_comm; in trace__replay()
2474 trace->tool.exit = perf_event__process_exit; in trace__replay()
2475 trace->tool.fork = perf_event__process_fork; in trace__replay()
2476 trace->tool.attr = perf_event__process_attr; in trace__replay()
2477 trace->tool.tracing_data = perf_event__process_tracing_data; in trace__replay()
2478 trace->tool.build_id = perf_event__process_build_id; in trace__replay()
2480 trace->tool.ordered_events = true; in trace__replay()
2481 trace->tool.ordering_requires_timestamps = true; in trace__replay()
2484 trace->multiple_threads = true; in trace__replay()
2486 session = perf_session__new(&file, false, &trace->tool); in trace__replay()
2493 trace->host = &session->machines.host; in trace__replay()
2533 err = parse_target_str(trace); in trace__replay()
2543 else if (trace->summary) in trace__replay()
2544 trace__fprintf_thread_summary(trace, trace->output); in trace__replay()
2576 struct trace *trace, FILE *fp) in thread__dump_stats() argument
2604 sc = &trace->syscalls.table[syscall_stats_entry->syscall]; in thread__dump_stats()
2618 static size_t trace__fprintf_thread(FILE *fp, struct thread *thread, struct trace *trace) in trace__fprintf_thread() argument
2627 ratio = (double)ttrace->nr_events / trace->nr_events * 100.0; in trace__fprintf_thread()
2636 if (trace->sched) in trace__fprintf_thread()
2641 printed += thread__dump_stats(ttrace, trace, fp); in trace__fprintf_thread()
2658 static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp) in trace__fprintf_thread_summary() argument
2660 DECLARE_RESORT_RB_MACHINE_THREADS(threads, trace->host); in trace__fprintf_thread_summary()
2670 printed += trace__fprintf_thread(fp, threads_entry->thread, trace); in trace__fprintf_thread_summary()
2680 struct trace *trace = opt->value; in trace__set_duration() local
2682 trace->duration_filter = atof(str); in trace__set_duration()
2691 struct trace *trace = opt->value; in trace__set_filter_pids() local
2701 i = trace->filter_pids.nr = intlist__nr_entries(list) + 1; in trace__set_filter_pids()
2702 trace->filter_pids.entries = calloc(i, sizeof(pid_t)); in trace__set_filter_pids()
2704 if (trace->filter_pids.entries == NULL) in trace__set_filter_pids()
2707 trace->filter_pids.entries[0] = getpid(); in trace__set_filter_pids()
2709 for (i = 1; i < trace->filter_pids.nr; ++i) in trace__set_filter_pids()
2710 trace->filter_pids.entries[i] = intlist__entry(list, i - 1)->i; in trace__set_filter_pids()
2718 static int trace__open_output(struct trace *trace, const char *filename) in trace__open_output() argument
2730 trace->output = fopen(filename, "w"); in trace__open_output()
2732 return trace->output == NULL ? -errno : 0; in trace__open_output()
2769 struct trace trace = { in cmd_trace() local
2793 OPT_CALLBACK(0, "event", &trace.evlist, "event", in cmd_trace()
2796 OPT_BOOLEAN(0, "comm", &trace.show_comm, in cmd_trace()
2798 OPT_BOOLEAN(0, "tool_stats", &trace.show_tool_stats, "show tool stats"), in cmd_trace()
2802 OPT_STRING('p', "pid", &trace.opts.target.pid, "pid", in cmd_trace()
2804 OPT_STRING('t', "tid", &trace.opts.target.tid, "tid", in cmd_trace()
2806 OPT_CALLBACK(0, "filter-pids", &trace, "CSV list of pids", in cmd_trace()
2808 OPT_BOOLEAN('a', "all-cpus", &trace.opts.target.system_wide, in cmd_trace()
2810 OPT_STRING('C', "cpu", &trace.opts.target.cpu_list, "cpu", in cmd_trace()
2812 OPT_BOOLEAN(0, "no-inherit", &trace.opts.no_inherit, in cmd_trace()
2814 OPT_CALLBACK('m', "mmap-pages", &trace.opts.mmap_pages, "pages", in cmd_trace()
2817 OPT_STRING('u', "uid", &trace.opts.target.uid_str, "user", in cmd_trace()
2819 OPT_CALLBACK(0, "duration", &trace, "float", in cmd_trace()
2822 OPT_BOOLEAN(0, "sched", &trace.sched, "show blocking scheduler events"), in cmd_trace()
2824 OPT_BOOLEAN('T', "time", &trace.full_time, in cmd_trace()
2826 OPT_BOOLEAN('s', "summary", &trace.summary_only, in cmd_trace()
2828 OPT_BOOLEAN('S', "with-summary", &trace.summary, in cmd_trace()
2830 OPT_CALLBACK_DEFAULT('F', "pf", &trace.trace_pgfaults, "all|maj|min", in cmd_trace()
2832 OPT_BOOLEAN(0, "syscalls", &trace.trace_syscalls, "Trace syscalls"), in cmd_trace()
2833 OPT_BOOLEAN('f', "force", &trace.force, "don't complain, do it"), in cmd_trace()
2834 OPT_CALLBACK(0, "call-graph", &trace.opts, in cmd_trace()
2837 OPT_BOOLEAN(0, "kernel-syscall-graph", &trace.kernel_syscallchains, in cmd_trace()
2839 OPT_UINTEGER(0, "min-stack", &trace.min_stack, in cmd_trace()
2842 OPT_UINTEGER(0, "max-stack", &trace.max_stack, in cmd_trace()
2846 OPT_UINTEGER(0, "proc-map-timeout", &trace.opts.proc_map_timeout, in cmd_trace()
2859 trace.evlist = perf_evlist__new(); in cmd_trace()
2860 trace.sctbl = syscalltbl__new(); in cmd_trace()
2862 if (trace.evlist == NULL || trace.sctbl == NULL) { in cmd_trace()
2871 err = bpf__setup_stdout(trace.evlist); in cmd_trace()
2873 bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf)); in cmd_trace()
2880 if (trace.trace_pgfaults) { in cmd_trace()
2881 trace.opts.sample_address = true; in cmd_trace()
2882 trace.opts.sample_time = true; in cmd_trace()
2885 if (trace.opts.mmap_pages == UINT_MAX) in cmd_trace()
2888 if (trace.max_stack == UINT_MAX) { in cmd_trace()
2889 trace.max_stack = input_name ? PERF_MAX_STACK_DEPTH : sysctl_perf_event_max_stack; in cmd_trace()
2894 if ((trace.min_stack || max_stack_user_set) && !callchain_param.enabled && trace.trace_syscalls) in cmd_trace()
2895 record_opts__parse_callchain(&trace.opts, &callchain_param, "dwarf", false); in cmd_trace()
2900 trace.opts.mmap_pages = perf_event_mlock_kb_in_pages() * 4; in cmd_trace()
2905 if (trace.evlist->nr_entries > 0) in cmd_trace()
2906 evlist__set_evsel_handler(trace.evlist, trace__event_handler); in cmd_trace()
2909 return trace__record(&trace, argc-1, &argv[1]); in cmd_trace()
2912 if (trace.summary_only) in cmd_trace()
2913 trace.summary = trace.summary_only; in cmd_trace()
2915 if (!trace.trace_syscalls && !trace.trace_pgfaults && in cmd_trace()
2916 trace.evlist->nr_entries == 0 /* Was --events used? */) { in cmd_trace()
2921 if (!trace.trace_syscalls && ev_qualifier_str) { in cmd_trace()
2927 err = trace__open_output(&trace, output_name); in cmd_trace()
2934 trace.open_id = syscalltbl__id(trace.sctbl, "open"); in cmd_trace()
2942 trace.not_ev_qualifier = *s == '!'; in cmd_trace()
2943 if (trace.not_ev_qualifier) in cmd_trace()
2945 trace.ev_qualifier = strlist__new(s, &slist_config); in cmd_trace()
2946 if (trace.ev_qualifier == NULL) { in cmd_trace()
2948 trace.output); in cmd_trace()
2953 err = trace__validate_ev_qualifier(&trace); in cmd_trace()
2958 err = target__validate(&trace.opts.target); in cmd_trace()
2960 target__strerror(&trace.opts.target, err, bf, sizeof(bf)); in cmd_trace()
2961 fprintf(trace.output, "%s", bf); in cmd_trace()
2965 err = target__parse_uid(&trace.opts.target); in cmd_trace()
2967 target__strerror(&trace.opts.target, err, bf, sizeof(bf)); in cmd_trace()
2968 fprintf(trace.output, "%s", bf); in cmd_trace()
2972 if (!argc && target__none(&trace.opts.target)) in cmd_trace()
2973 trace.opts.target.system_wide = true; in cmd_trace()
2976 err = trace__replay(&trace); in cmd_trace()
2978 err = trace__run(&trace, argc, argv); in cmd_trace()
2982 fclose(trace.output); in cmd_trace()