perf trace: Introduce syscall__augmented_args() method
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 3 Sep 2018 19:07:53 +0000 (16:07 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 3 Sep 2018 19:07:53 +0000 (16:07 -0300)
That will be used by trace__sys_enter when we start combining the
augmented syscalls:sys_enter_FOO + syscalls:sys_exit_FOO.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-iiseo3s0qbf9i3rzn8k597bv@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-trace.c

index c106189f40666a4337b714eb3a6f5d8059ede7bc..12356deb6046502c887fad5c779c9b333a7b6063 100644 (file)
@@ -1677,6 +1677,17 @@ static int trace__fprintf_sample(struct trace *trace, struct perf_evsel *evsel,
        return printed;
 }
 
+static void *syscall__augmented_args(struct syscall *sc, struct perf_sample *sample, int *augmented_args_size)
+{
+       void *augmented_args = NULL;
+
+       *augmented_args_size = sample->raw_size - sc->args_size;
+       if (*augmented_args_size > 0)
+               augmented_args = sample->raw_data + sc->args_size;
+
+       return augmented_args;
+}
+
 static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
                            union perf_event *event __maybe_unused,
                            struct perf_sample *sample)
@@ -1762,10 +1773,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct perf_evsel *evse
                goto out_put;
 
        args = perf_evsel__sc_tp_ptr(evsel, args, sample);
-       augmented_args_size = sample->raw_size - sc->args_size;
-       if (augmented_args_size > 0)
-               augmented_args = sample->raw_data + sc->args_size;
-
+       augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size);
        syscall__scnprintf_args(sc, msg, sizeof(msg), args, augmented_args, augmented_args_size, trace, thread);
        fprintf(trace->output, "%s", msg);
        err = 0;