Skip to content

Commit 3278024

Browse files
Sbermacmel
authored andcommitted
perf trace: Add --force-btf for debugging
If --force-btf is enabled, prefer btf_dump general pretty printer to perf trace's customized pretty printers. Mostly for debug purposes. Committer testing: diff before/after shows we need several improvements to be able to compare the changes, first we need to cut off/disable mutable data such as pids and timestamps, then what is left are the buffer addresses passed from userspace, returned from kernel space, maybe we can ask 'perf trace' to go on making those reproducible. That would entail a Pointer Address Translation (PAT) like for networking, that would, for simple, reproducible if not for these details, workloads, that we would then use in our regression tests. Enough digression, this is one such diff: openat(dfd: CWD, filename: "/usr/share/locale/locale.alias", flags: RDONLY|CLOEXEC) = 3 -fstat(fd: 3, statbuf: 0x7fff01f212a0) = 0 -read(fd: 3, buf: 0x5596bab2d630, count: 4096) = 2998 -read(fd: 3, buf: 0x5596bab2d630, count: 4096) = 0 +fstat(fd: 3, statbuf: 0x7ffc163cf0e0) = 0 +read(fd: 3, buf: 0x55b4e0631630, count: 4096) = 2998 +read(fd: 3, buf: 0x55b4e0631630, count: 4096) = 0 close(fd: 3) = 0 openat(dfd: CWD, filename: "/usr/share/locale/en_US.UTF-8/LC_MESSAGES/coreutils.mo") = -1 ENOENT (No such file or directory) openat(dfd: CWD, filename: "/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo") = -1 ENOENT (No such file or directory) @@ -45,7 +45,7 @@ openat(dfd: CWD, filename: "/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo") = -1 ENOENT (No such file or directory) openat(dfd: CWD, filename: "/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo") = -1 ENOENT (No such file or directory) openat(dfd: CWD, filename: "/usr/share/locale/en/LC_MESSAGES/coreutils.mo") = -1 ENOENT (No such file or directory) -{ .tv_sec: 1, .tv_nsec: 0 }, rmtp: 0x7fff01f21990) = 0 +(struct __kernel_timespec){.tv_sec = (__kernel_time64_t)1,}, rmtp: 0x7ffc163cf7d0) = The problem more close to our hands is to make the libbpf BTF pretty printer to have a mode that closely resembles what we're trying to resemble: strace output. Being able to run something with 'perf trace' and with 'strace' and get the exact same output should be of interest of anybody wanting to have strace and 'perf trace' regression tested against each other. That last part is 'perf trace' shot at being something so useful as strace... ;-) Suggested-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Howard Chu <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a68fd6a commit 3278024

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/perf/builtin-trace.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ struct trace {
212212
bool show_string_prefix;
213213
bool force;
214214
bool vfs_getname;
215+
bool force_btf;
215216
int trace_pgfaults;
216217
char *perfconfig_events;
217218
struct {
@@ -2363,7 +2364,9 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
23632364

23642365
default_scnprintf = sc->arg_fmt[arg.idx].scnprintf;
23652366

2366-
if (default_scnprintf == NULL || default_scnprintf == SCA_PTR) {
2367+
if (trace->force_btf ||
2368+
(default_scnprintf == NULL ||
2369+
(default_scnprintf == SCA_PTR && strstr(field->type, "struct")))) {
23672370
btf_printed = trace__btf_scnprintf(trace, &arg, bf + printed,
23682371
size - printed, val, field->type);
23692372
if (btf_printed) {
@@ -5171,6 +5174,8 @@ int cmd_trace(int argc, const char **argv)
51715174
OPT_INTEGER('D', "delay", &trace.opts.target.initial_delay,
51725175
"ms to wait before starting measurement after program "
51735176
"start"),
5177+
OPT_BOOLEAN(0, "force-btf", &trace.force_btf, "Prefer btf_dump general pretty printer"
5178+
"to customized ones"),
51745179
OPTS_EVSWITCH(&trace.evswitch),
51755180
OPT_END()
51765181
};

0 commit comments

Comments
 (0)