mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 23:30:53 +07:00
perf trace beauty: Export strarray for use in per-object beautifiers
Like will be done with fcntl(fd, F_GETLEASE, F_RDLCK|F_WRLCK|F_UNLCK) 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: http://lkml.kernel.org/n/tip-3p11bgirtntjfmbixfkz8i2m@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
1f41873c22
commit
0ae79636e3
@ -283,34 +283,21 @@ static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void
|
|||||||
({ struct syscall_tp *fields = evsel->priv; \
|
({ struct syscall_tp *fields = evsel->priv; \
|
||||||
fields->name.pointer(&fields->name, sample); })
|
fields->name.pointer(&fields->name, sample); })
|
||||||
|
|
||||||
struct strarray {
|
size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const char *intfmt, int val)
|
||||||
int offset;
|
{
|
||||||
int nr_entries;
|
int idx = val - sa->offset;
|
||||||
const char **entries;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define DEFINE_STRARRAY(array) struct strarray strarray__##array = { \
|
if (idx < 0 || idx >= sa->nr_entries)
|
||||||
.nr_entries = ARRAY_SIZE(array), \
|
return scnprintf(bf, size, intfmt, val);
|
||||||
.entries = array, \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DEFINE_STRARRAY_OFFSET(array, off) struct strarray strarray__##array = { \
|
return scnprintf(bf, size, "%s", sa->entries[idx]);
|
||||||
.offset = off, \
|
|
||||||
.nr_entries = ARRAY_SIZE(array), \
|
|
||||||
.entries = array, \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t __syscall_arg__scnprintf_strarray(char *bf, size_t size,
|
static size_t __syscall_arg__scnprintf_strarray(char *bf, size_t size,
|
||||||
const char *intfmt,
|
const char *intfmt,
|
||||||
struct syscall_arg *arg)
|
struct syscall_arg *arg)
|
||||||
{
|
{
|
||||||
struct strarray *sa = arg->parm;
|
return strarray__scnprintf(arg->parm, bf, size, intfmt, arg->val);
|
||||||
int idx = arg->val - sa->offset;
|
|
||||||
|
|
||||||
if (idx < 0 || idx >= sa->nr_entries)
|
|
||||||
return scnprintf(bf, size, intfmt, arg->val);
|
|
||||||
|
|
||||||
return scnprintf(bf, size, "%s", sa->entries[idx]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t syscall_arg__scnprintf_strarray(char *bf, size_t size,
|
static size_t syscall_arg__scnprintf_strarray(char *bf, size_t size,
|
||||||
|
@ -1,8 +1,28 @@
|
|||||||
#ifndef _PERF_TRACE_BEAUTY_H
|
#ifndef _PERF_TRACE_BEAUTY_H
|
||||||
#define _PERF_TRACE_BEAUTY_H
|
#define _PERF_TRACE_BEAUTY_H
|
||||||
|
|
||||||
|
#include <linux/kernel.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
|
struct strarray {
|
||||||
|
int offset;
|
||||||
|
int nr_entries;
|
||||||
|
const char **entries;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define DEFINE_STRARRAY(array) struct strarray strarray__##array = { \
|
||||||
|
.nr_entries = ARRAY_SIZE(array), \
|
||||||
|
.entries = array, \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEFINE_STRARRAY_OFFSET(array, off) struct strarray strarray__##array = { \
|
||||||
|
.offset = off, \
|
||||||
|
.nr_entries = ARRAY_SIZE(array), \
|
||||||
|
.entries = array, \
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const char *intfmt, int val);
|
||||||
|
|
||||||
struct trace;
|
struct trace;
|
||||||
struct thread;
|
struct thread;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user