perf trace augmented_syscalls: Augment bind's 'myaddr' sockaddr arg
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 28 Aug 2018 20:03:53 +0000 (17:03 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 30 Aug 2018 18:52:20 +0000 (15:52 -0300)
One more, to reuse the augmented_sockaddr_syscall_enter() macro
introduced from the augmentation of connect's sockaddr arg, also to get
a subset of the struct arg augmentations done using the manual method,
before switching to something automatic, using tracefs's format file or,
even better, BTF containing the syscall args structs.

  # perf trace -e tools/perf/examples/bpf/augmented_syscalls.c
     0.000 sshd/11479 bind(fd: 3<socket:[170336]>, umyaddr: { .family: NETLINK }, addrlen: 12)
     1.752 sshd/11479 bind(fd: 3<socket:[170336]>, umyaddr: { .family: INET, port: 22, addr: 0.0.0.0 }, addrlen: 16)
     1.924 sshd/11479 bind(fd: 4<socket:[170338]>, umyaddr: { .family: INET6, port: 22, addr: :: }, addrlen: 28)
  ^C#

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-a2drqpahpmc7uwb3n3gj2plu@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-trace.c
tools/perf/examples/bpf/augmented_syscalls.c

index ab2ed30b8dcc2e45e39a831316ceceae9e266695..537bb30895dfbdf3740de07dc18c461a08a06964 100644 (file)
@@ -621,6 +621,8 @@ static struct syscall_fmt {
 } syscall_fmts[] = {
        { .name     = "access",
          .arg = { [1] = { .scnprintf = SCA_ACCMODE,  /* mode */ }, }, },
+       { .name     = "bind",
+         .arg = { [1] = { .scnprintf = SCA_SOCKADDR, /* umyaddr */ }, }, },
        { .name     = "bpf",
          .arg = { [0] = STRARRAY(cmd, bpf_cmd), }, },
        { .name     = "brk",        .hexret = true,
index 5f417e528419cfdf2b0aa5bdd5b2d2fd6a82b408..71edb7ad86980a4965d8f9bd683d2e79b3de1d81 100644 (file)
@@ -122,6 +122,16 @@ int syscall_enter(syscall)(struct syscall_enter_##syscall##_args *args)                            \
 
 struct sockaddr;
 
+struct syscall_enter_bind_args {
+       unsigned long long common_tp_fields;
+       long               syscall_nr;
+       long               fd;
+       struct sockaddr    *addr_ptr;
+       unsigned long      addrlen;
+};
+
+augmented_sockaddr_syscall_enter(bind);
+
 struct syscall_enter_connect_args {
        unsigned long long common_tp_fields;
        long               syscall_nr;