• Howard Chu's avatar
    perf trace: Add --force-btf for debugging · 32780245
    Howard Chu authored
    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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: default avatarHoward Chu <howardchu95@gmail.com>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.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/20240824163322.60796-8-howardchu95@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    32780245
builtin-trace.c 157 KB