Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bdcff7d6 authored by Ben Cheng's avatar Ben Cheng
Browse files

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.
parent b202c54a
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -23,4 +23,14 @@ LOCAL_MODULE_TAGS := eng
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
+18 −0
Original line number Diff line number Diff line
@@ -285,6 +285,24 @@ void dump_registers(int tfd, int pid, bool at_fault)
    _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)
+7 −0
Original line number Diff line number Diff line
int main()
{
  extern void crash(void);

  crash();
  return 0;
}

debuggerd/vfp.S

0 → 100644
+41 −0
Original line number Diff line number Diff line
    .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