perf trace: Pretty print buffer data
Define TRACE_AUG_MAX_BUF in trace_augment.h data, which is the maximum
buffer size we can augment. BPF will include this header too.
Print buffer in a way that's different than just printing a string, we
print all the control characters in \digits (such as \0 for null, and
\10 for newline, LF).
For character that has a bigger value than 127, we print the digits
instead of the character itself as well.
Committer notes:
Simplified the buffer scnprintf to avoid using multiple buffers as
discussed in the patch review thread.
We can't really all 'buf' args to SCA_BUF as we're collecting so far
just on the sys_enter path, so we would be printing the previous 'read'
arg buffer contents, not what the kernel puts there.
So instead of:
static int syscall_fmt__cmp(const void *name, const void *fmtp)
@@ -1987,8 +1989,6 @@ syscall_arg_fmt__init_array(struct syscall_arg_fmt *arg, struct tep_format_field
- else if (strstr(field->type, "char *") && strstr(field->name, "buf"))
- arg->scnprintf = SCA_BUF;
Do:
static const struct syscall_fmt syscall_fmts[] = {
+ { .name = "write", .errpid = true,
+ .arg = { [1] = { .scnprintf = SCA_BUF /* buf */, from_user = true, }, }, },
Signed-off-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/20240815013626.935097-8-howardchu95@gmail.com
Link: https://lore.kernel.org/r/20240824163322.60796-6-howardchu95@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-08-25 00:33:19 +08:00
|
|
|
#ifndef TRACE_AUGMENT_H
|
|
|
|
#define TRACE_AUGMENT_H
|
|
|
|
|
2025-06-23 15:57:21 -07:00
|
|
|
#include <linux/compiler.h>
|
|
|
|
|
|
|
|
struct bpf_program;
|
|
|
|
struct evlist;
|
|
|
|
|
|
|
|
#ifdef HAVE_BPF_SKEL
|
|
|
|
|
|
|
|
int augmented_syscalls__prepare(void);
|
|
|
|
int augmented_syscalls__create_bpf_output(struct evlist *evlist);
|
|
|
|
void augmented_syscalls__setup_bpf_output(void);
|
|
|
|
int augmented_syscalls__set_filter_pids(unsigned int nr, pid_t *pids);
|
|
|
|
int augmented_syscalls__get_map_fds(int *enter_fd, int *exit_fd, int *beauty_fd);
|
|
|
|
struct bpf_program *augmented_syscalls__find_by_title(const char *name);
|
|
|
|
struct bpf_program *augmented_syscalls__unaugmented(void);
|
|
|
|
void augmented_syscalls__cleanup(void);
|
|
|
|
|
|
|
|
#else /* !HAVE_BPF_SKEL */
|
|
|
|
|
|
|
|
static inline int augmented_syscalls__prepare(void)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int augmented_syscalls__create_bpf_output(struct evlist *evlist __maybe_unused)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void augmented_syscalls__setup_bpf_output(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int augmented_syscalls__set_filter_pids(unsigned int nr __maybe_unused,
|
|
|
|
pid_t *pids __maybe_unused)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int augmented_syscalls__get_map_fds(int *enter_fd __maybe_unused,
|
|
|
|
int *exit_fd __maybe_unused,
|
|
|
|
int *beauty_fd __maybe_unused)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct bpf_program *
|
|
|
|
augmented_syscalls__find_by_title(const char *name __maybe_unused)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct bpf_program *augmented_syscalls__unaugmented(void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void augmented_syscalls__cleanup(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_BPF_SKEL */
|
perf trace: Pretty print buffer data
Define TRACE_AUG_MAX_BUF in trace_augment.h data, which is the maximum
buffer size we can augment. BPF will include this header too.
Print buffer in a way that's different than just printing a string, we
print all the control characters in \digits (such as \0 for null, and
\10 for newline, LF).
For character that has a bigger value than 127, we print the digits
instead of the character itself as well.
Committer notes:
Simplified the buffer scnprintf to avoid using multiple buffers as
discussed in the patch review thread.
We can't really all 'buf' args to SCA_BUF as we're collecting so far
just on the sys_enter path, so we would be printing the previous 'read'
arg buffer contents, not what the kernel puts there.
So instead of:
static int syscall_fmt__cmp(const void *name, const void *fmtp)
@@ -1987,8 +1989,6 @@ syscall_arg_fmt__init_array(struct syscall_arg_fmt *arg, struct tep_format_field
- else if (strstr(field->type, "char *") && strstr(field->name, "buf"))
- arg->scnprintf = SCA_BUF;
Do:
static const struct syscall_fmt syscall_fmts[] = {
+ { .name = "write", .errpid = true,
+ .arg = { [1] = { .scnprintf = SCA_BUF /* buf */, from_user = true, }, }, },
Signed-off-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/20240815013626.935097-8-howardchu95@gmail.com
Link: https://lore.kernel.org/r/20240824163322.60796-6-howardchu95@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-08-25 00:33:19 +08:00
|
|
|
|
|
|
|
#endif
|