Improve perf_event_open argument decoding
authorBen Noordhuis <info@bnoordhuis.nl>
Sun, 3 Feb 2013 23:04:57 +0000 (00:04 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 5 Feb 2013 23:15:14 +0000 (23:15 +0000)
* configure.ac (AC_CHECK_HEADERS): Add linux/perf_event.h.
* desc.c [HAVE_LINUX_PERF_EVENT_H]: Include <linux/perf_event.h>.
(perf_event_open_flags): New xlat structure.
(sys_perf_event_open): New function.
* linux/dummy.h (sys_perf_event_open): Remove.
* linux/syscall.h (sys_perf_event_open): New prototype.

Signed-off-by: Ben Noordhuis <info@bnoordhuis.nl>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
configure.ac
desc.c
linux/dummy.h
linux/syscall.h

index f44eaf1aac6c30939d452a8d9d7787b97b3faeaf..80be383e457db58e304635eae1021effd41447f7 100644 (file)
@@ -196,6 +196,7 @@ AC_CHECK_HEADERS(m4_normalize([
        ioctls.h
        libaio.h
        linux/capability.h
+       linux/perf_event.h
        linux/ptrace.h
        linux/utsname.h
        mqueue.h
diff --git a/desc.c b/desc.c
index f0c18903438f94a4624f5f54301763d797571cc8..e75ed4f3bb17ec47b3f7be5ca9a725d32c4a4037 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -37,6 +37,9 @@
 #ifdef HAVE_LIBAIO_H
 # include <libaio.h>
 #endif
+#ifdef HAVE_LINUX_PERF_EVENT_H
+# include  <linux/perf_event.h>
+#endif
 
 #if HAVE_LONG_LONG_OFF_T
 /*
@@ -222,6 +225,19 @@ static const struct xlat whence[] = {
        { 0,            NULL            },
 };
 
+static const struct xlat perf_event_open_flags[] = {
+#ifdef PERF_FLAG_FD_NO_GROUP
+       { PERF_FLAG_FD_NO_GROUP,        "PERF_FLAG_FD_NO_GROUP" },
+#endif
+#ifdef PERF_FLAG_FD_OUTPUT
+       { PERF_FLAG_FD_OUTPUT,          "PERF_FLAG_FD_OUTPUT"   },
+#endif
+#ifdef PERF_FLAG_PID_CGROUP
+       { PERF_FLAG_PID_CGROUP,         "PERF_FLAG_PID_CGROUP"  },
+#endif
+       { 0,                            NULL                    },
+};
+
 #ifndef HAVE_LONG_LONG_OFF_T
 /* fcntl/lockf */
 static void
@@ -1068,3 +1084,18 @@ sys_eventfd2(struct tcb *tcp)
 {
        return do_eventfd(tcp, 1);
 }
+
+int
+sys_perf_event_open(struct tcb *tcp)
+{
+       if (entering(tcp)) {
+               tprintf("%#lx, %d, %d, %d, ",
+                       tcp->u_arg[0],
+                       (int) tcp->u_arg[1],
+                       (int) tcp->u_arg[2],
+                       (int) tcp->u_arg[3]);
+               printflags(perf_event_open_flags, tcp->u_arg[4],
+                          "PERF_FLAG_???");
+       }
+       return 0;
+}
index ce340b9db92a3d8be608b9330da4a40de30bc8b3..182896e38a5de51004b0661153eef52fb3f58957 100644 (file)
@@ -39,7 +39,6 @@
 #define        sys_lookup_dcookie      printargs
 #define        sys_name_to_handle_at   printargs
 #define        sys_open_by_handle_at   printargs
-#define        sys_perf_event_open     printargs
 #define        sys_request_key         printargs
 #define        sys_sync_file_range     printargs
 #define        sys_sysfs               printargs
index 7e0155ec50e512dd22e2ebe7a5f15b715fb52555..81b4c695b2b1bb59ffc3cb6668aadf2073434e83 100644 (file)
@@ -163,6 +163,7 @@ int sys_oldselect();
 int sys_oldstat();
 int sys_open();
 int sys_openat();
+int sys_perf_event_open();
 int sys_personality();
 int sys_pipe();
 int sys_pipe2();