builtin-trace.c (092bd3cd7169085b09e4a5307de95e461d0581d7) builtin-trace.c (591421e151ddf95e43d690a5c9b291d8e1cb8065)
1/*
2 * builtin-trace.c
3 *
4 * Builtin 'trace' command:
5 *
6 * Display a continuously updated trace of any workload, CPU, specific PID,
7 * system wide, etc. Default format is loosely strace like, but any other
8 * event may be specified using --event.

--- 96 unchanged lines hidden (view full) ---

105 bool not_ev_qualifier;
106 bool live;
107 bool full_time;
108 bool sched;
109 bool multiple_threads;
110 bool summary;
111 bool summary_only;
112 bool show_comm;
1/*
2 * builtin-trace.c
3 *
4 * Builtin 'trace' command:
5 *
6 * Display a continuously updated trace of any workload, CPU, specific PID,
7 * system wide, etc. Default format is loosely strace like, but any other
8 * event may be specified using --event.

--- 96 unchanged lines hidden (view full) ---

105 bool not_ev_qualifier;
106 bool live;
107 bool full_time;
108 bool sched;
109 bool multiple_threads;
110 bool summary;
111 bool summary_only;
112 bool show_comm;
113 bool print_sample;
113 bool show_tool_stats;
114 bool trace_syscalls;
115 bool kernel_syscallchains;
116 bool force;
117 bool vfs_getname;
118 int trace_pgfaults;
119 int open_id;
120};

--- 1452 unchanged lines hidden (view full) ---

1573
1574 printed = trace__fprintf_entry_head(trace, trace->current, duration, true, ttrace->entry_time, trace->output);
1575 printed += fprintf(trace->output, "%-70s) ...\n", ttrace->entry_str);
1576 ttrace->entry_pending = false;
1577
1578 return printed;
1579}
1580
114 bool show_tool_stats;
115 bool trace_syscalls;
116 bool kernel_syscallchains;
117 bool force;
118 bool vfs_getname;
119 int trace_pgfaults;
120 int open_id;
121};

--- 1452 unchanged lines hidden (view full) ---

1574
1575 printed = trace__fprintf_entry_head(trace, trace->current, duration, true, ttrace->entry_time, trace->output);
1576 printed += fprintf(trace->output, "%-70s) ...\n", ttrace->entry_str);
1577 ttrace->entry_pending = false;
1578
1579 return printed;
1580}
1581
1582static int trace__fprintf_sample(struct trace *trace, struct perf_evsel *evsel,
1583 struct perf_sample *sample, struct thread *thread)
1584{
1585 int printed = 0;
1586
1587 if (trace->print_sample) {
1588 double ts = (double)sample->time / NSEC_PER_MSEC;
1589
1590 printed += fprintf(trace->output, "%22s %10.3f %s %d/%d [%d]\n",
1591 perf_evsel__name(evsel), ts,
1592 thread__comm_str(thread),
1593 sample->pid, sample->tid, sample->cpu);
1594 }
1595
1596 return printed;
1597}
1598
1581static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
1582 union perf_event *event __maybe_unused,
1583 struct perf_sample *sample)
1584{
1585 char *msg;
1586 void *args;
1587 size_t printed = 0;
1588 struct thread *thread;

--- 4 unchanged lines hidden (view full) ---

1593 if (sc == NULL)
1594 return -1;
1595
1596 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
1597 ttrace = thread__trace(thread, trace->output);
1598 if (ttrace == NULL)
1599 goto out_put;
1600
1599static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
1600 union perf_event *event __maybe_unused,
1601 struct perf_sample *sample)
1602{
1603 char *msg;
1604 void *args;
1605 size_t printed = 0;
1606 struct thread *thread;

--- 4 unchanged lines hidden (view full) ---

1611 if (sc == NULL)
1612 return -1;
1613
1614 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
1615 ttrace = thread__trace(thread, trace->output);
1616 if (ttrace == NULL)
1617 goto out_put;
1618
1619 trace__fprintf_sample(trace, evsel, sample, thread);
1620
1601 args = perf_evsel__sc_tp_ptr(evsel, args, sample);
1602
1603 if (ttrace->entry_str == NULL) {
1604 ttrace->entry_str = malloc(trace__entry_str_size);
1605 if (!ttrace->entry_str)
1606 goto out_put;
1607 }
1608

--- 74 unchanged lines hidden (view full) ---

1683 if (sc == NULL)
1684 return -1;
1685
1686 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
1687 ttrace = thread__trace(thread, trace->output);
1688 if (ttrace == NULL)
1689 goto out_put;
1690
1621 args = perf_evsel__sc_tp_ptr(evsel, args, sample);
1622
1623 if (ttrace->entry_str == NULL) {
1624 ttrace->entry_str = malloc(trace__entry_str_size);
1625 if (!ttrace->entry_str)
1626 goto out_put;
1627 }
1628

--- 74 unchanged lines hidden (view full) ---

1703 if (sc == NULL)
1704 return -1;
1705
1706 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
1707 ttrace = thread__trace(thread, trace->output);
1708 if (ttrace == NULL)
1709 goto out_put;
1710
1711 trace__fprintf_sample(trace, evsel, sample, thread);
1712
1691 if (trace->summary)
1692 thread__update_stats(ttrace, id, sample);
1693
1694 ret = perf_evsel__sc_tp_uint(evsel, ret, sample);
1695
1696 if (id == trace->open_id && ret >= 0 && ttrace->filename.pending_open) {
1697 trace__set_fd_pathname(thread, ret, ttrace->filename.name);
1698 ttrace->filename.pending_open = false;

--- 1330 unchanged lines hidden (view full) ---

3029 "Show the kernel callchains on the syscall exit path"),
3030 OPT_UINTEGER(0, "min-stack", &trace.min_stack,
3031 "Set the minimum stack depth when parsing the callchain, "
3032 "anything below the specified depth will be ignored."),
3033 OPT_UINTEGER(0, "max-stack", &trace.max_stack,
3034 "Set the maximum stack depth when parsing the callchain, "
3035 "anything beyond the specified depth will be ignored. "
3036 "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)),
1713 if (trace->summary)
1714 thread__update_stats(ttrace, id, sample);
1715
1716 ret = perf_evsel__sc_tp_uint(evsel, ret, sample);
1717
1718 if (id == trace->open_id && ret >= 0 && ttrace->filename.pending_open) {
1719 trace__set_fd_pathname(thread, ret, ttrace->filename.name);
1720 ttrace->filename.pending_open = false;

--- 1330 unchanged lines hidden (view full) ---

3051 "Show the kernel callchains on the syscall exit path"),
3052 OPT_UINTEGER(0, "min-stack", &trace.min_stack,
3053 "Set the minimum stack depth when parsing the callchain, "
3054 "anything below the specified depth will be ignored."),
3055 OPT_UINTEGER(0, "max-stack", &trace.max_stack,
3056 "Set the maximum stack depth when parsing the callchain, "
3057 "anything beyond the specified depth will be ignored. "
3058 "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)),
3059 OPT_BOOLEAN(0, "print-sample", &trace.print_sample,
3060 "print the PERF_RECORD_SAMPLE PERF_SAMPLE_ info, for debugging"),
3037 OPT_UINTEGER(0, "proc-map-timeout", &trace.opts.proc_map_timeout,
3038 "per thread proc mmap processing timeout in ms"),
3039 OPT_UINTEGER('D', "delay", &trace.opts.initial_delay,
3040 "ms to wait before starting measurement after program "
3041 "start"),
3042 OPT_END()
3043 };
3044 bool __maybe_unused max_stack_user_set = true;

--- 114 unchanged lines hidden ---
3061 OPT_UINTEGER(0, "proc-map-timeout", &trace.opts.proc_map_timeout,
3062 "per thread proc mmap processing timeout in ms"),
3063 OPT_UINTEGER('D', "delay", &trace.opts.initial_delay,
3064 "ms to wait before starting measurement after program "
3065 "start"),
3066 OPT_END()
3067 };
3068 bool __maybe_unused max_stack_user_set = true;

--- 114 unchanged lines hidden ---