[PATCH] Fix StopTheWorld includes on Android.

Sergey Matveev earthdok at google.com
Tue Apr 2 09:01:25 PDT 2013


Hi kcc, eugenis, glider, samsonov,

http://llvm-reviews.chandlerc.com/D612

Files:
  lib/sanitizer_common/sanitizer_stoptheworld_linux.cc

Index: lib/sanitizer_common/sanitizer_stoptheworld_linux.cc
===================================================================
--- lib/sanitizer_common/sanitizer_stoptheworld_linux.cc
+++ lib/sanitizer_common/sanitizer_stoptheworld_linux.cc
@@ -24,7 +24,11 @@
 #include <sys/prctl.h> // for PR_* definitions
 #include <sys/ptrace.h> // for PTRACE_* definitions
 #include <sys/types.h> // for pid_t
-#include <sys/user.h> // for user_regst_struct
+#if defined SANITIZER_ANDROID && defined __arm__
+#include <linux/user.h>
+#else
+#include <sys/user.h>
+#endif
 #include <sys/wait.h> // for signal-related stuff
 
 #include "sanitizer_common.h"
@@ -346,17 +350,25 @@
 }
 
 // Platform-specific methods from SuspendedThreadsList.
+#if defined SANITIZER_ANDROID && defined __arm__
+typedef pt_regs regs_struct;
+#else
+typedef user_regs_struct regs_struct;
+#endif
+
 int SuspendedThreadsList::GetRegistersAndSP(uptr index,
                                             uptr *buffer,
                                             uptr *sp) const {
   pid_t tid = GetThreadID(index);
-  user_regs_struct regs;
+  regs_struct regs;
   if (internal_ptrace(PTRACE_GETREGS, tid, NULL, &regs) != 0) {
     Report("Could not get registers from thread %d (errno %d).\n",
            tid, errno);
     return -1;
   }
-#if __WORDSIZE == 32
+#if defined __arm__
+    *sp = regs.ARM_sp;
+#elif __WORDSIZE == 32
     *sp = regs.esp;
 #else
     *sp = regs.rsp;
@@ -366,7 +378,7 @@
 }
 
 uptr SuspendedThreadsList::RegisterCount() {
-  return sizeof(user_regs_struct) / sizeof(uptr);
+  return sizeof(regs_struct) / sizeof(uptr);
 }
 }  // namespace __sanitizer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D612.1.patch
Type: text/x-patch
Size: 1646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130402/40139945/attachment.bin>


More information about the llvm-commits mailing list