• Arnaldo Carvalho de Melo's avatar
    perf trace: Allow choosing how to augment the tracepoint arguments · f11b2803
    Arnaldo Carvalho de Melo authored
    So far we used the libtraceevent printing routines when showing
    tracepoint arguments, but since 'perf trace' has a lot of beautifiers
    for syscall arguments, and since some of those can be used to augment
    tracepoint arguments, add a routine to make use of those beautifiers
    and allow the user to choose which one to use.
    
    The default now is to use the same beautifiers used for the strace-like
    sys_enter+sys_exit lines, but the user can choose the libtraceevent ones
    by either using the:
    
        perf trace --libtraceevent_print
    
    command line option, or by setting:
    
      # cat ~/.perfconfig
      [trace]
    	tracepoint_beautifiers = libtraceevent
    
    For instance, here are some examples:
    
      # perf trace -e sched:*switch,*sleep,sched:*wakeup,exit*,sched:*exit sleep 1
           0.000 sched:sched_wakeup(comm: "perf", pid: 5273 (perf), prio: 120, success: 1, target_cpu: 6)
           0.621 nanosleep(rqtp: 0x7ffdd06d1140, rmtp: NULL) ...
           0.628 sched:sched_switch(prev_comm: "sleep", prev_pid: 5273 (sleep), prev_prio: 120, prev_state: 1, next_comm: "swapper/6", next_pid: 0, next_prio: 120)
        1000.879 sched:sched_wakeup(comm: "sleep", pid: 5273 (sleep), prio: 120, success: 1, target_cpu: 6)
           0.621  ... [continued]: nanosleep())          = 0
        1001.026 exit_group(error_code: 0)               = ?
        1001.216 sched:sched_process_exit(comm: "sleep", pid: 5273 (sleep), prio: 120)
      #
    
    And then using libtraceevent, as before:
    
      # perf trace --libtraceevent_print -e sched:*switch,*sleep,sched:*wakeup,exit*,sched:*exit sleep 1
           0.000 sched:sched_wakeup(comm=perf pid=5288 prio=120 target_cpu=001)
           0.739 nanosleep(rqtp: 0x7ffeba6c2f40, rmtp: NULL) ...
           0.747 sched:sched_switch(prev_comm=sleep prev_pid=5288 prev_prio=120 prev_state=S ==> next_comm=swapper/1 next_pid=0 next_prio=120)
        1000.902 sched:sched_wakeup(comm=sleep pid=5288 prio=120 target_cpu=001)
           0.739  ... [continued]: nanosleep())          = 0
        1001.012 exit_group(error_code: 0)               = ?
      #
    
    The new default allocates an array of 'struct syscall_arg_fmt' for the
    tracepoint arguments and, just like with syscall arguments, tries to
    find suitable syscall_arg__scnprintf_NAME() routines to augment those
    tracepoint arguments based on their type (as in the tracefs "format"
    file), or even in their name + type, for instance arguntents with names
    ending in "fd" with type "int" get the fd scnprintf beautifier attached,
    etc.
    
    Soon this will take advantage of the kernel BTF information to augment
    enumerations based on the tracefs "format" type info.
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Link: https://lkml.kernel.org/n/tip-o8qdluotkcb3b1x2gjqrejcl@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    f11b2803
builtin-trace.c 133 KB