Apply Android-specific patches to Valgrind 3.8.1
Tested with GCC 4.6 and things are working as expected.
Change-Id: Icfd035acff5d1443edb6edf4043ab2a3f1c408a4
diff --git a/Android.mk b/Android.mk
index e69de29..07a98cf 100644
--- a/Android.mk
+++ b/Android.mk
@@ -0,0 +1,25 @@
+# Copyright (C) 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+# other build targets can be added once we are actively using them:
+# dynamic_annotations, tsan, unittest
+subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
+ main \
+ ))
+
+include $(subdirs)
+
+
diff --git a/main/config.h b/main/config.h
index 73ee55e..5f78be8 100644
--- a/main/config.h
+++ b/main/config.h
@@ -32,7 +32,7 @@
/* #undef GLIBC_2_10 */
/* Define to 1 if you're using glibc 2.11.x */
-#define GLIBC_2_11 1
+/* #dundef GLIBC_2_11 1 */
/* Define to 1 if you're using glibc 2.12.x */
/* #undef GLIBC_2_12 */
@@ -84,11 +84,11 @@
/* Define to 1 if gcc supports __sync_bool_compare_and_swap() and
__sync_add_and_fetch() for the primary target */
-#define HAVE_BUILTIN_ATOMIC 1
+/* #undef HAVE_BUILTIN_ATOMIC */
/* Define to 1 if g++ supports __sync_bool_compare_and_swap() and
__sync_add_and_fetch() */
-#define HAVE_BUILTIN_ATOMIC_CXX 1
+/* #undef HAVE_BUILTIN_ATOMIC_CXX */
/* Define to 1 if you have the `clock_gettime' function. */
#define HAVE_CLOCK_GETTIME 1
@@ -97,7 +97,7 @@
#define HAVE_CLOCK_MONOTONIC 1
/* Define to 1 if you have the <endian.h> header file. */
-#define HAVE_ENDIAN_H 1
+/* #undef HAVE_ENDIAN_H */
/* Define to 1 if you have the `epoll_create' function. */
#define HAVE_EPOLL_CREATE 1
@@ -160,7 +160,7 @@
/* #undef HAVE_PROCESS_VM_WRITEV */
/* Define to 1 if you have the `pthread_barrier_init' function. */
-#define HAVE_PTHREAD_BARRIER_INIT 1
+/* #undef HAVE_PTHREAD_BARRIER_INIT */
/* Define to 1 if you have the `pthread_condattr_setclock' function. */
#define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
@@ -169,7 +169,7 @@
/* #undef HAVE_PTHREAD_CREATE_GLIBC_2_0 */
/* Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant. */
-#define HAVE_PTHREAD_MUTEX_ADAPTIVE_NP 1
+/* #undef HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
/* Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant. */
#define HAVE_PTHREAD_MUTEX_ERRORCHECK_NP 1
@@ -181,7 +181,7 @@
#define HAVE_PTHREAD_MUTEX_TIMEDLOCK 1
/* Define to 1 if pthread_mutex_t has a member __data.__kind. */
-#define HAVE_PTHREAD_MUTEX_T__DATA__KIND 1
+/* #undef HAVE_PTHREAD_MUTEX_T__DATA__KIND */
/* Define to 1 if pthread_mutex_t has a member called __m_kind. */
/* #undef HAVE_PTHREAD_MUTEX_T__M_KIND */
@@ -200,7 +200,7 @@
#define HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK 1
/* Define to 1 if you have the `pthread_spin_lock' function. */
-#define HAVE_PTHREAD_SPIN_LOCK 1
+/* #undef HAVE_PTHREAD_SPIN_LOCK */
/* Define to 1 if you have the `pthread_yield' function. */
#define HAVE_PTHREAD_YIELD 1
@@ -344,7 +344,7 @@
#define VERSION "3.8.1"
/* Temporary files directory */
-#define VG_TMPDIR "/tmp"
+#define VG_TMPDIR "/data/local/tmp"
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef gid_t */
diff --git a/main/coregrind/m_coredump/coredump-elf.c b/main/coregrind/m_coredump/coredump-elf.c
index 42a1965..066eaf3 100644
--- a/main/coregrind/m_coredump/coredump-elf.c
+++ b/main/coregrind/m_coredump/coredump-elf.c
@@ -136,17 +136,6 @@
phdr->p_align = VKI_PAGE_SIZE;
}
-#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
-/* Android's libc doesn't provide a definition for this. Hence: */
-typedef
- struct {
- Elf32_Word n_namesz;
- Elf32_Word n_descsz;
- Elf32_Word n_type;
- }
- Elf32_Nhdr;
-#endif
-
struct note {
struct note *next;
ESZ(Nhdr) note;
diff --git a/main/coregrind/m_debuginfo/readelf.c b/main/coregrind/m_debuginfo/readelf.c
index d78dc7a..f5a94b4 100644
--- a/main/coregrind/m_debuginfo/readelf.c
+++ b/main/coregrind/m_debuginfo/readelf.c
@@ -1249,7 +1249,13 @@
VG_(sprintf)(debugpath, "%s/.debug/%s", objdir, debugname);
if ((addr = open_debug_file(debugpath, NULL, crc, rel_ok, &size)) == 0) {
VG_(sprintf)(debugpath, "/usr/lib/debug%s/%s", objdir, debugname);
- addr = open_debug_file(debugpath, NULL, crc, rel_ok, &size);
+ if ((addr = open_debug_file(debugpath, NULL, crc, rel_ok, &size)) == 0) {
+#if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android)
+ VG_(sprintf)(debugpath, "/data/local/symbols%s/%s", objdir,
+ debugname);
+ addr = open_debug_file(debugpath, NULL, crc, rel_ok, &size);
+#endif
+ }
}
}