perf trace: Resolve prctl's 'option' arg strings to numbers
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 11 Feb 2020 18:54:08 +0000 (15:54 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 11 Feb 2020 19:41:50 +0000 (16:41 -0300)
  # perf trace -e syscalls:sys_enter_prctl --filter="option==SET_NAME"
     0.000 Socket Thread/3860 syscalls:sys_enter_prctl(option: SET_NAME, arg2: 0x7fc50b9733e8)
     0.053 SSL Cert #78/3860 syscalls:sys_enter_prctl(option: SET_NAME, arg2: 0x7fc50b9733e8)
^C  #

If one uses '-v' with 'perf trace', we can see the filter it puts in
place:

  New filter for syscalls:sys_enter_prctl: (option==0xf) && (common_pid != 3859 && common_pid != 2757)

We still need to allow using plain '-e prctl' and have this turn into
creating a 'syscalls:sys_enter_prctl' event so that the filter can be
applied only to it as right now '-e prctl' ends up using the
'raw_syscalls:sys_enter/sys_exit'.

The end goal is to have something like:

  # perf trace -e prctl/option==SET_NAME/

And have that use tracepoint filters or eBPF ones.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-trace.c

index 46a72ecac427f33a16d0d7d0ff7d713a306b8464..01d542007c8b1210b9fbf348bfb8ccafb849c645 100644 (file)
@@ -1065,7 +1065,9 @@ static struct syscall_fmt syscall_fmts[] = {
        { .name     = "poll", .timeout = true, },
        { .name     = "ppoll", .timeout = true, },
        { .name     = "prctl",
-         .arg = { [0] = { .scnprintf = SCA_PRCTL_OPTION, /* option */ },
+         .arg = { [0] = { .scnprintf = SCA_PRCTL_OPTION, /* option */
+                          .strtoul   = STUL_STRARRAY,
+                          .parm      = &strarray__prctl_options, },
                   [1] = { .scnprintf = SCA_PRCTL_ARG2, /* arg2 */ },
                   [2] = { .scnprintf = SCA_PRCTL_ARG3, /* arg3 */ }, }, },
        { .name     = "pread", .alias = "pread64", },