[compiler-rt] r226827 - [sanitizer] Intercept sched_getparam.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Thu Jan 22 06:03:07 PST 2015
Author: eugenis
Date: Thu Jan 22 08:03:07 2015
New Revision: 226827
URL: http://llvm.org/viewvc/llvm-project?rev=226827&view=rev
Log:
[sanitizer] Intercept sched_getparam.
Added:
compiler-rt/trunk/test/sanitizer_common/TestCases/sched_getparam.cc (with props)
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=226827&r1=226826&r2=226827&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Thu Jan 22 08:03:07 2015
@@ -2592,6 +2592,19 @@ INTERCEPTOR(int, sched_getaffinity, int
#define INIT_SCHED_GETAFFINITY
#endif
+#if SANITIZER_INTERCEPT_SCHED_GETPARAM
+INTERCEPTOR(int, sched_getparam, int pid, void *param) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, sched_getparam, pid, param);
+ int res = REAL(sched_getparam)(pid, param);
+ if (!res) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, param, struct_sched_param_sz);
+ return res;
+}
+#define INIT_SCHED_GETPARAM COMMON_INTERCEPT_FUNCTION(sched_getparam);
+#else
+#define INIT_SCHED_GETPARAM
+#endif
+
#if SANITIZER_INTERCEPT_STRERROR
INTERCEPTOR(char *, strerror, int errnum) {
void *ctx;
@@ -4851,6 +4864,7 @@ static void InitializeCommonInterceptors
INIT_CANONICALIZE_FILE_NAME;
INIT_CONFSTR;
INIT_SCHED_GETAFFINITY;
+ INIT_SCHED_GETPARAM;
INIT_STRERROR;
INIT_STRERROR_R;
INIT_XPG_STRERROR_R;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h?rev=226827&r1=226826&r2=226827&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Thu Jan 22 08:03:07 2015
@@ -142,6 +142,7 @@
#define SANITIZER_INTERCEPT_CONFSTR \
SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
#define SANITIZER_INTERCEPT_SCHED_GETAFFINITY SI_LINUX_NOT_ANDROID
+#define SANITIZER_INTERCEPT_SCHED_GETPARAM SI_LINUX_NOT_ANDROID
#define SANITIZER_INTERCEPT_STRERROR SI_NOT_WINDOWS
#define SANITIZER_INTERCEPT_STRERROR_R SI_NOT_WINDOWS
#define SANITIZER_INTERCEPT_XPG_STRERROR_R SI_LINUX_NOT_ANDROID
Added: compiler-rt/trunk/test/sanitizer_common/TestCases/sched_getparam.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/sched_getparam.cc?rev=226827&view=auto
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/sched_getparam.cc (added)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/sched_getparam.cc Thu Jan 22 08:03:07 2015
@@ -0,0 +1,13 @@
+// RUN: %clangxx -O0 %s -o %t && %run %t
+
+#include <assert.h>
+#include <sched.h>
+#include <stdio.h>
+
+int main(void) {
+ struct sched_param param;
+ int res = sched_getparam(0, ¶m);
+ assert(res == 0);
+ if (param.sched_priority == 42) printf(".\n");
+ return 0;
+}
Propchange: compiler-rt/trunk/test/sanitizer_common/TestCases/sched_getparam.cc
------------------------------------------------------------------------------
svn:eol-style = LF
More information about the llvm-commits
mailing list