perf trace: Move some scnprintf methods from syscall to syscall_arg_fmt

Since all they operate on is on a syscall_arg_fmt instance, so move them
to allow use it from the upcoming tracepoint fprintf routine.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-ynttrs1l75f0x9tk67spd7jd@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 947b843c
...@@ -1715,22 +1715,22 @@ static size_t syscall__scnprintf_name(struct syscall *sc, char *bf, size_t size, ...@@ -1715,22 +1715,22 @@ static size_t syscall__scnprintf_name(struct syscall *sc, char *bf, size_t size,
* as mount 'flags' argument that needs ignoring some magic flag, see comment * as mount 'flags' argument that needs ignoring some magic flag, see comment
* in tools/perf/trace/beauty/mount_flags.c * in tools/perf/trace/beauty/mount_flags.c
*/ */
static unsigned long syscall__mask_val(struct syscall *sc, struct syscall_arg *arg, unsigned long val) static unsigned long syscall_arg_fmt__mask_val(struct syscall_arg_fmt *fmt, struct syscall_arg *arg, unsigned long val)
{ {
if (sc->arg_fmt && sc->arg_fmt[arg->idx].mask_val) if (fmt && fmt->mask_val)
return sc->arg_fmt[arg->idx].mask_val(arg, val); return fmt->mask_val(arg, val);
return val; return val;
} }
static size_t syscall__scnprintf_val(struct syscall *sc, char *bf, size_t size, static size_t syscall_arg_fmt__scnprintf_val(struct syscall_arg_fmt *fmt, char *bf, size_t size,
struct syscall_arg *arg, unsigned long val) struct syscall_arg *arg, unsigned long val)
{ {
if (sc->arg_fmt && sc->arg_fmt[arg->idx].scnprintf) { if (fmt && fmt->scnprintf) {
arg->val = val; arg->val = val;
if (sc->arg_fmt[arg->idx].parm) if (fmt->parm)
arg->parm = sc->arg_fmt[arg->idx].parm; arg->parm = fmt->parm;
return sc->arg_fmt[arg->idx].scnprintf(bf, size, arg); return fmt->scnprintf(bf, size, arg);
} }
return scnprintf(bf, size, "%ld", val); return scnprintf(bf, size, "%ld", val);
} }
...@@ -1776,7 +1776,7 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size, ...@@ -1776,7 +1776,7 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
* Some syscall args need some mask, most don't and * Some syscall args need some mask, most don't and
* return val untouched. * return val untouched.
*/ */
val = syscall__mask_val(sc, &arg, val); val = syscall_arg_fmt__mask_val(&sc->arg_fmt[arg.idx], &arg, val);
/* /*
* Suppress this argument if its value is zero and * Suppress this argument if its value is zero and
...@@ -1797,7 +1797,8 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size, ...@@ -1797,7 +1797,8 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
if (trace->show_arg_names) if (trace->show_arg_names)
printed += scnprintf(bf + printed, size - printed, "%s: ", field->name); printed += scnprintf(bf + printed, size - printed, "%s: ", field->name);
printed += syscall__scnprintf_val(sc, bf + printed, size - printed, &arg, val); printed += syscall_arg_fmt__scnprintf_val(&sc->arg_fmt[arg.idx],
bf + printed, size - printed, &arg, val);
} }
} else if (IS_ERR(sc->tp_format)) { } else if (IS_ERR(sc->tp_format)) {
/* /*
...@@ -1812,7 +1813,7 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size, ...@@ -1812,7 +1813,7 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
if (printed) if (printed)
printed += scnprintf(bf + printed, size - printed, ", "); printed += scnprintf(bf + printed, size - printed, ", ");
printed += syscall__scnprintf_name(sc, bf + printed, size - printed, &arg); printed += syscall__scnprintf_name(sc, bf + printed, size - printed, &arg);
printed += syscall__scnprintf_val(sc, bf + printed, size - printed, &arg, val); printed += syscall_arg_fmt__scnprintf_val(&sc->arg_fmt[arg.idx], bf + printed, size - printed, &arg, val);
next_arg: next_arg:
++arg.idx; ++arg.idx;
bit <<= 1; bit <<= 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment