perf beauty open: Detach the syscall_arg agnostic bits from the flags formatter

We may want to use this in other contexts, like when formatting the
return of fcntl(fd, F_GETFL).

Make it have the following signature, so that we can set the formatter
for the return argument while processing the arguments of a syscall, as
fcntl, for instance, may return fds, flags, etc, so need different
return value formatters:

	size_t formatter(unsigned long value, char *bf, size_t size);

This gets so detached from 'perf trace' internals that we may well get
all these and move to a tools/lib/syscall_beauty/ library at some point
and use it in other tools/ living utilities.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
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: http://lkml.kernel.org/n/tip-9aw8t22ztvnkuv26l6sw1c18@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 64e4561d
...@@ -52,4 +52,6 @@ size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_ ...@@ -52,4 +52,6 @@ size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_
size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg); size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_STATX_MASK syscall_arg__scnprintf_statx_mask #define SCA_STATX_MASK syscall_arg__scnprintf_statx_mask
size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size);
#endif /* _PERF_TRACE_BEAUTY_H */ #endif /* _PERF_TRACE_BEAUTY_H */
...@@ -14,13 +14,9 @@ ...@@ -14,13 +14,9 @@
#define O_NOATIME 01000000 #define O_NOATIME 01000000
#endif #endif
static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size)
struct syscall_arg *arg)
{ {
int printed = 0, flags = arg->val; int printed = 0;
if (!(flags & O_CREAT))
arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */
if (flags == 0) if (flags == 0)
return scnprintf(bf, size, "RDONLY"); return scnprintf(bf, size, "RDONLY");
...@@ -68,4 +64,15 @@ static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, ...@@ -68,4 +64,15 @@ static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size,
return printed; return printed;
} }
static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, struct syscall_arg *arg)
{
int flags = arg->val;
if (!(flags & O_CREAT))
arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */
return open__scnprintf_flags(flags, bf, size);
}
#define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags #define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags
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