Dump VFP registers and status word when native app crashes.

Bug: 2226399
Caveat: d0/d1 appear to be clobbered by ptrace. It will be tracked by a new bug.
diff --git a/debuggerd/Android.mk b/debuggerd/Android.mk
index b22e1a8..b86f2a5 100644
--- a/debuggerd/Android.mk
+++ b/debuggerd/Android.mk
@@ -14,13 +14,23 @@
 include $(BUILD_EXECUTABLE)
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := crasher.c 
+LOCAL_SRC_FILES := crasher.c
 LOCAL_SRC_FILES += crashglue.S
-LOCAL_MODULE := crasher 
+LOCAL_MODULE := crasher
 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
 LOCAL_MODULE_TAGS := eng
 #LOCAL_FORCE_STATIC_EXECUTABLE := true
 LOCAL_SHARED_LIBRARIES := libcutils libc
 include $(BUILD_EXECUTABLE)
 
+ifeq ($(TARGET_ARCH_VARIANT),armv7-a)
+include $(CLEAR_VARS)
+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 # TARGET_ARCH == arm
diff --git a/debuggerd/debuggerd.c b/debuggerd/debuggerd.c
index 145135f..3757cd5 100644
--- a/debuggerd/debuggerd.c
+++ b/debuggerd/debuggerd.c
@@ -285,6 +285,24 @@
     _LOG(tfd, only_in_tombstone,
          " 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 __VFP_FP__
+    struct user_vfp vfp_regs;
+    int i;
+
+    if(ptrace(PTRACE_GETVFPREGS, pid, 0, &vfp_regs)) {
+        _LOG(tfd, only_in_tombstone,
+             "cannot get registers: %s\n", strerror(errno));
+        return;
+    }
+
+    for (i = 0; i < 32; 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]);
+    }
+    _LOG(tfd, only_in_tombstone, " scr %08lx\n\n", vfp_regs.fpscr);
+#endif
 }
 
 const char *get_signame(int sig)
diff --git a/debuggerd/vfp-crasher.c b/debuggerd/vfp-crasher.c
new file mode 100644
index 0000000..7a19cdd
--- /dev/null
+++ b/debuggerd/vfp-crasher.c
@@ -0,0 +1,7 @@
+int main()
+{
+  extern void crash(void);
+
+  crash();
+  return 0;
+}
diff --git a/debuggerd/vfp.S b/debuggerd/vfp.S
new file mode 100644
index 0000000..2192415
--- /dev/null
+++ b/debuggerd/vfp.S
@@ -0,0 +1,41 @@
+    .text
+    .align 2
+    .global crash
+    .type crash, %function
+crash:
+    fconstd   d0, #0
+    fconstd   d1, #1
+    fconstd   d2, #2
+    fconstd   d3, #3
+    fconstd   d4, #4
+    fconstd   d5, #5
+    fconstd   d6, #6
+    fconstd   d7, #7
+    fconstd   d8, #8
+    fconstd   d9, #9
+    fconstd   d10, #10
+    fconstd   d11, #11
+    fconstd   d12, #12
+    fconstd   d13, #13
+    fconstd   d14, #14
+    fconstd   d15, #15
+    fconstd   d16, #16
+    fconstd   d17, #17
+    fconstd   d18, #18
+    fconstd   d19, #19
+    fconstd   d20, #20
+    fconstd   d21, #21
+    fconstd   d22, #22
+    fconstd   d23, #23
+    fconstd   d24, #24
+    fconstd   d25, #25
+    fconstd   d26, #26
+    fconstd   d27, #27
+    fconstd   d28, #28
+    fconstd   d29, #29
+    fconstd   d30, #30
+    fconstd   d31, #31
+    mov       r0, #0
+    str       r0, [r0]
+    bx        lr
+