diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 2a85f5198da00c300377d542e9ce49f588bb235d..7336552c22cf55125c592c5370af85b2a1baf9eb 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1666,6 +1666,44 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel, return err; } +static int trace__fprintf_sys_enter(struct trace *trace, struct perf_evsel *evsel, + struct perf_sample *sample) +{ + struct format_field *field = perf_evsel__field(evsel, "__syscall_nr"); + struct thread_trace *ttrace; + struct thread *thread; + struct syscall *sc; + char msg[1024]; + int id, err = -1; + void *args; + + if (field == NULL) + return -1; + + id = format_field__intval(field, sample, evsel->needs_swap); + sc = trace__syscall_info(trace, evsel, id); + + if (sc == NULL) + return -1; + + thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); + ttrace = thread__trace(thread, trace->output); + /* + * We need to get ttrace just to make sure it is there when syscall__scnprintf_args() + * and the rest of the beautifiers accessing it via struct syscall_arg touches it. + */ + if (ttrace == NULL) + goto out_put; + + args = sample->raw_data + field->offset + sizeof(u64); /* skip __syscall_nr, there is where args are */ + syscall__scnprintf_args(sc, msg, sizeof(msg), args, trace, thread); + fprintf(trace->output, "%s", msg); + err = 0; +out_put: + thread__put(thread); + return err; +} + static int trace__resolve_callchain(struct trace *trace, struct perf_evsel *evsel, struct perf_sample *sample, struct callchain_cursor *cursor) @@ -1964,9 +2002,12 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, if (perf_evsel__is_bpf_output(evsel)) { bpf_output__fprintf(trace, sample); } else if (evsel->tp_format) { - event_format__fprintf(evsel->tp_format, sample->cpu, - sample->raw_data, sample->raw_size, - trace->output); + if (strncmp(evsel->tp_format->name, "sys_enter_", 10) || + trace__fprintf_sys_enter(trace, evsel, sample)) { + event_format__fprintf(evsel->tp_format, sample->cpu, + sample->raw_data, sample->raw_size, + trace->output); + } } fprintf(trace->output, "\n");