[PATCH] [Compiler-rt]sanitizer common: fix sanitizer_stoptheworld_linux.cc build error on non-android

Abdoulaye Walsimou Gaye awg at embtoolkit.org
Sun May 12 06:37:13 PDT 2013


1- Fix arm non-android build:
should be:
as SANITIZER_ANDROID is defined (to 0) even on non android build.

2- Fix <sys/user.h> usage:
struct user_regs_struct is only valid on __i386__ and __x86_64__, on __arm__
(other than android) we have struct user_regs.

Signed-off-by: Abdoulaye Walsimou Gaye <awg at embtoolkit.org>
---

This patch is for master/trunk and release-3.3 branch

 .../sanitizer_stoptheworld_linux.cc                |   31 ++++++++++++--------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc b/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc
index fe3d4e3..1c3c952 100644
--- a/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc
+++ b/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc
@@ -24,7 +24,7 @@
 #include <sys/prctl.h> // for PR_* definitions
 #include <sys/ptrace.h> // for PTRACE_* definitions
 #include <sys/types.h> // for pid_t
-#if defined(SANITIZER_ANDROID) && defined(__arm__)
+#if SANITIZER_ANDROID && defined(__arm__)
 # include <linux/user.h>  // for pt_regs
 #else
 # include <sys/user.h>  // for user_regs_struct
@@ -353,12 +353,26 @@ void StopTheWorld(StopTheWorldCallback callback, void *argument) {
 }
 
 // Platform-specific methods from SuspendedThreadsList.
-#if defined(__arm__)
+#if SANITIZER_ANDROID && defined(__arm__)
 typedef pt_regs regs_struct;
-#else
+#define REG_SP regs.ARM_sp
+
+#elif SANITIZER_LINUX && defined(__arm__)
+typedef user_regs regs_struct;
+#define REG_SP regs.uregs[13]
+
+#elif defined(__i386__) || defined(__x86_64__)
 typedef user_regs_struct regs_struct;
+#if defined(__i386__)
+#define REG_SP regs.esp
+#else
+#define REG_SP regs.rsp
 #endif
 
+#else
+#error "Unsupported architecture"
+#endif // SANITIZER_ANDROID && defined(__arm__)
+
 int SuspendedThreadsList::GetRegistersAndSP(uptr index,
                                             uptr *buffer,
                                             uptr *sp) const {
@@ -371,15 +385,8 @@ int SuspendedThreadsList::GetRegistersAndSP(uptr index,
            tid, pterrno);
     return -1;
   }
-#if defined(__arm__)
-  *sp = regs.ARM_sp;
-#elif defined(__i386__)
-  *sp = regs.esp;
-#elif defined(__x86_64__)
-  *sp = regs.rsp;
-#else
-  UNIMPLEMENTED("Unknown architecture");
-#endif
+
+  *sp = REG_SP;
   internal_memcpy(buffer, &regs, sizeof(regs));
   return 0;
 }
-- 
1.7.9.5




More information about the llvm-commits mailing list