[compiler-rt] r195434 - [sanitizer] Restore perf_event_attr handling.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Fri Nov 22 01:32:39 PST 2013


Author: eugenis
Date: Fri Nov 22 03:32:39 2013
New Revision: 195434

URL: http://llvm.org/viewvc/llvm-project?rev=195434&view=rev
Log:
[sanitizer] Restore perf_event_attr handling.

This time in a forward/backward compatible way.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc?rev=195434&r1=195433&r2=195434&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc Fri Nov 22 03:32:39 2013
@@ -2709,11 +2709,13 @@ PRE_SYSCALL(syncfs)(long fd) {}
 
 POST_SYSCALL(syncfs)(long res, long fd) {}
 
-PRE_SYSCALL(perf_event_open)(void *attr_uptr, long pid, long cpu, long group_fd,
-                             long flags) {}
+PRE_SYSCALL(perf_event_open)(__sanitizer_perf_event_attr *attr_uptr, long pid,
+                             long cpu, long group_fd, long flags) {
+  if (attr_uptr) PRE_READ(attr_uptr, attr_uptr->size);
+}
 
-POST_SYSCALL(perf_event_open)(long res, void *attr_uptr, long pid, long cpu,
-                              long group_fd, long flags) {}
+POST_SYSCALL(perf_event_open)(long res, __sanitizer_perf_event_attr *attr_uptr,
+                              long pid, long cpu, long group_fd, long flags) {}
 
 PRE_SYSCALL(mmap_pgoff)(long addr, long len, long prot, long flags, long fd,
                         long pgoff) {}

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_linux.cc?rev=195434&r1=195433&r2=195434&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_linux.cc Fri Nov 22 03:32:39 2013
@@ -52,6 +52,13 @@ COMPILER_CHECK(struct_kernel_stat64_sz =
 
 COMPILER_CHECK(struct_io_event_sz == sizeof(struct io_event));
 
+#if !SANITIZER_ANDROID
+COMPILER_CHECK(sizeof(struct __sanitizer_perf_event_attr) <=
+               sizeof(struct perf_event_attr));
+CHECK_SIZE_AND_OFFSET(perf_event_attr, type);
+CHECK_SIZE_AND_OFFSET(perf_event_attr, size);
+#endif
+
 COMPILER_CHECK(iocb_cmd_pread == IOCB_CMD_PREAD);
 COMPILER_CHECK(iocb_cmd_pwrite == IOCB_CMD_PWRITE);
 

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h?rev=195434&r1=195433&r2=195434&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h Fri Nov 22 03:32:39 2013
@@ -59,6 +59,11 @@ namespace __sanitizer {
   const unsigned struct_kernel_stat64_sz = 96;
 #endif
   const unsigned struct_io_event_sz = 32;
+  struct __sanitizer_perf_event_attr {
+    unsigned type;
+    unsigned size;
+    // More fields that vary with the kernel version.
+  };
 
   extern unsigned struct_utimbuf_sz;
   extern unsigned struct_new_utsname_sz;





More information about the llvm-commits mailing list