mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-17 05:45:20 +00:00
perf trace: Introduce trace__btf_scnprintf()
To have a central place that will look at the BTF type and call the right scnprintf routine or return zero, meaning BTF pretty printing isn't available or not implemented for a specific type. Signed-off-by: Howard Chu <howardchu95@gmail.com> Tested-by: Howard Chu <howardchu95@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20240624181345.124764-8-howardchu95@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
d66763fed3
commit
62284329b1
@ -981,18 +981,28 @@ static size_t btf_enum_scnprintf(const struct btf_type *type, struct btf *btf, c
|
|||||||
static size_t trace__btf_enum_scnprintf(struct trace *trace, struct syscall_arg_fmt *arg_fmt, char *bf,
|
static size_t trace__btf_enum_scnprintf(struct trace *trace, struct syscall_arg_fmt *arg_fmt, char *bf,
|
||||||
size_t size, int val, char *type)
|
size_t size, int val, char *type)
|
||||||
{
|
{
|
||||||
if (trace->btf == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (syscall_arg_fmt__cache_btf_enum(arg_fmt, trace->btf, type) < 0)
|
if (syscall_arg_fmt__cache_btf_enum(arg_fmt, trace->btf, type) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return btf_enum_scnprintf(arg_fmt->type, trace->btf, bf, size, val);
|
return btf_enum_scnprintf(arg_fmt->type, trace->btf, bf, size, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static size_t trace__btf_scnprintf(struct trace *trace, struct syscall_arg_fmt *arg_fmt, char *bf,
|
||||||
|
size_t size, int val, char *type)
|
||||||
|
{
|
||||||
|
if (trace->btf == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (arg_fmt->is_enum)
|
||||||
|
return trace__btf_enum_scnprintf(trace, arg_fmt, bf, size, val, type);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#else // HAVE_LIBBPF_SUPPORT
|
#else // HAVE_LIBBPF_SUPPORT
|
||||||
static size_t trace__btf_enum_scnprintf(struct trace *trace __maybe_unused, struct syscall_arg_fmt *arg_fmt __maybe_unused,
|
static size_t trace__btf_scnprintf(struct trace *trace __maybe_unused, struct syscall_arg_fmt *arg_fmt __maybe_unused,
|
||||||
char *bf __maybe_unused, size_t size __maybe_unused, int val __maybe_unused,
|
char *bf __maybe_unused, size_t size __maybe_unused, int val __maybe_unused,
|
||||||
char *type __maybe_unused)
|
char *type __maybe_unused)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2183,7 +2193,7 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
|
|||||||
unsigned char *args, void *augmented_args, int augmented_args_size,
|
unsigned char *args, void *augmented_args, int augmented_args_size,
|
||||||
struct trace *trace, struct thread *thread)
|
struct trace *trace, struct thread *thread)
|
||||||
{
|
{
|
||||||
size_t printed = 0;
|
size_t printed = 0, btf_printed;
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
u8 bit = 1;
|
u8 bit = 1;
|
||||||
struct syscall_arg arg = {
|
struct syscall_arg arg = {
|
||||||
@ -2237,13 +2247,11 @@ 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);
|
||||||
|
|
||||||
if (sc->arg_fmt[arg.idx].is_enum) {
|
btf_printed = trace__btf_scnprintf(trace, &sc->arg_fmt[arg.idx], bf + printed,
|
||||||
size_t p = trace__btf_enum_scnprintf(trace, &sc->arg_fmt[arg.idx], bf + printed,
|
size - printed, val, field->type);
|
||||||
size - printed, val, field->type);
|
if (btf_printed) {
|
||||||
if (p) {
|
printed += btf_printed;
|
||||||
printed += p;
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printed += syscall_arg_fmt__scnprintf_val(&sc->arg_fmt[arg.idx],
|
printed += syscall_arg_fmt__scnprintf_val(&sc->arg_fmt[arg.idx],
|
||||||
@ -2892,7 +2900,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
|
|||||||
size_t size = sizeof(bf);
|
size_t size = sizeof(bf);
|
||||||
struct tep_format_field *field = evsel->tp_format->format.fields;
|
struct tep_format_field *field = evsel->tp_format->format.fields;
|
||||||
struct syscall_arg_fmt *arg = __evsel__syscall_arg_fmt(evsel);
|
struct syscall_arg_fmt *arg = __evsel__syscall_arg_fmt(evsel);
|
||||||
size_t printed = 0;
|
size_t printed = 0, btf_printed;
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
u8 bit = 1;
|
u8 bit = 1;
|
||||||
struct syscall_arg syscall_arg = {
|
struct syscall_arg syscall_arg = {
|
||||||
@ -2942,13 +2950,10 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
|
|||||||
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);
|
||||||
|
|
||||||
if (arg->is_enum) {
|
btf_printed = trace__btf_scnprintf(trace, arg, bf + printed, size - printed, val, field->type);
|
||||||
size_t p = trace__btf_enum_scnprintf(trace, arg, bf + printed,
|
if (btf_printed) {
|
||||||
size - printed, val, field->type);
|
printed += btf_printed;
|
||||||
if (p) {
|
continue;
|
||||||
printed += p;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printed += syscall_arg_fmt__scnprintf_val(arg, bf + printed, size - printed, &syscall_arg, val);
|
printed += syscall_arg_fmt__scnprintf_val(arg, bf + printed, size - printed, &syscall_arg, val);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user