[PATCH] Improve perf_event_open argument decoding

Ben Noordhuis info at bnoordhuis.nl
Sun Feb 3 23:04:57 UTC 2013


* configure.ac: Add <linux/perf_event.h> check.
* desc.c: Add sys_perf_event_open

Signed-off-by: Ben Noordhuis <info at bnoordhuis.nl>
---
 configure.ac    |    1 +
 desc.c          |   32 ++++++++++++++++++++++++++++++++
 linux/dummy.h   |    1 -
 linux/syscall.h |    1 +
 4 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index f44eaf1..80be383 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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 f0c1890..f4b49d4 100644
--- 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,19 @@ 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;
+}
diff --git a/linux/dummy.h b/linux/dummy.h
index ce340b9..182896e 100644
--- a/linux/dummy.h
+++ b/linux/dummy.h
@@ -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
diff --git a/linux/syscall.h b/linux/syscall.h
index 7e0155e..81b4c69 100644
--- a/linux/syscall.h
+++ b/linux/syscall.h
@@ -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();
-- 
1.7.9.5





More information about the Strace-devel mailing list