Use arch flags instead of TARGET_ARCH_VARIANT, and add support for VFP_D16

Change-Id: I6007ff21076e92b04a17fb030472a9f8842f0315
diff --git a/debuggerd/Android.mk b/debuggerd/Android.mk
index b86f2a5..3c1cf02 100644
--- a/debuggerd/Android.mk
+++ b/debuggerd/Android.mk
@@ -9,6 +9,13 @@
 LOCAL_CFLAGS := -Wall
 LOCAL_MODULE := debuggerd
 
+ifeq ($(ARCH_ARM_HAVE_VFP),true)
+LOCAL_CFLAGS += -DWITH_VFP
+endif # ARCH_ARM_HAVE_VFP
+ifeq ($(ARCH_ARM_HAVE_VFP_D32),true)
+LOCAL_CFLAGS += -DWITH_VFP_D32
+endif # ARCH_ARM_HAVE_VFP_D32
+
 LOCAL_STATIC_LIBRARIES := libcutils libc
 
 include $(BUILD_EXECUTABLE)
@@ -23,14 +30,20 @@
 LOCAL_SHARED_LIBRARIES := libcutils libc
 include $(BUILD_EXECUTABLE)
 
-ifeq ($(TARGET_ARCH_VARIANT),armv7-a)
+ifeq ($(ARCH_ARM_HAVE_VFP),true)
 include $(CLEAR_VARS)
+
+LOCAL_CFLAGS += -DWITH_VFP
+ifeq ($(ARCH_ARM_HAVE_VFP_D32),true)
+LOCAL_CFLAGS += -DWITH_VFP_D32
+endif # ARCH_ARM_HAVE_VFP_D32
+
 LOCAL_SRC_FILES := vfp-crasher.c vfp.S
 LOCAL_MODULE := vfp-crasher
 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
 LOCAL_MODULE_TAGS := eng
 LOCAL_SHARED_LIBRARIES := libcutils libc
 include $(BUILD_EXECUTABLE)
-endif # TARGET_ARCH_VARIANT == armv7-a
+endif # ARCH_ARM_HAVE_VFP == true
 
 endif # TARGET_ARCH == arm
diff --git a/debuggerd/debuggerd.c b/debuggerd/debuggerd.c
index 7b987cf..e850a2e 100644
--- a/debuggerd/debuggerd.c
+++ b/debuggerd/debuggerd.c
@@ -42,6 +42,14 @@
 
 #include "utility.h"
 
+#ifdef WITH_VFP
+#ifdef WITH_VFP_D32
+#define NUM_VFP_REGS 32
+#else
+#define NUM_VFP_REGS 16
+#endif
+#endif
+
 /* Main entry point to get the backtrace from the crashing process */
 extern int unwind_backtrace_with_ptrace(int tfd, pid_t pid, mapinfo *map,
                                         unsigned int sp_list[],
@@ -278,7 +286,7 @@
          " ip %08x  sp %08x  lr %08x  pc %08x  cpsr %08x\n",
          r.ARM_ip, r.ARM_sp, r.ARM_lr, r.ARM_pc, r.ARM_cpsr);
 
-#if __ARM_NEON__
+#ifdef WITH_VFP
     struct user_vfp vfp_regs;
     int i;
 
@@ -288,7 +296,7 @@
         return;
     }
 
-    for (i = 0; i < 32; i += 2) {
+    for (i = 0; i < NUM_VFP_REGS; i += 2) {
         _LOG(tfd, only_in_tombstone,
              " d%-2d %016llx  d%-2d %016llx\n",
               i, vfp_regs.fpregs[i], i+1, vfp_regs.fpregs[i+1]);
diff --git a/debuggerd/vfp.S b/debuggerd/vfp.S
index 2192415..9744f6f 100644
--- a/debuggerd/vfp.S
+++ b/debuggerd/vfp.S
@@ -19,6 +19,7 @@
     fconstd   d13, #13
     fconstd   d14, #14
     fconstd   d15, #15
+#ifdef WITH_VFP_D32
     fconstd   d16, #16
     fconstd   d17, #17
     fconstd   d18, #18
@@ -35,6 +36,7 @@
     fconstd   d29, #29
     fconstd   d30, #30
     fconstd   d31, #31
+#endif
     mov       r0, #0
     str       r0, [r0]
     bx        lr