From 21ad2c19ea575b4485121e9f824609fe6e4f3be9 Mon Sep 17 00:00:00 2001 From: Tommi Rantala Date: Wed, 15 Aug 2012 09:29:34 +0300 Subject: [PATCH] Implement _UCD_access_reg() for ARM Implement the Linux version of _UCD_access_reg() for ARM. We can sidestep the register number remapping, as the libunwind register numbers match one-to-one to the ELF core file register numbers. --- src/coredump/_UCD_access_reg_linux.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/coredump/_UCD_access_reg_linux.c b/src/coredump/_UCD_access_reg_linux.c index 9026ec63..c48f5c9b 100644 --- a/src/coredump/_UCD_access_reg_linux.c +++ b/src/coredump/_UCD_access_reg_linux.c @@ -1,4 +1,5 @@ /* libunwind - a platform-independent unwind library + Copyright (C) 2012 Tommi Rantala This file is part of libunwind. @@ -30,12 +31,18 @@ _UCD_access_reg (unw_addr_space_t as, unw_regnum_t regnum, unw_word_t *valp, int write, void *arg) { + struct UCD_info *ui = arg; + if (write) { Debug(0, "write is not supported\n"); return -UNW_EINVAL; } +#if defined(UNW_TARGET_ARM) + if (regnum < 0 || regnum >= 16) + goto badreg; +#else #if defined(UNW_TARGET_X86) static const uint8_t remap_regs[] = { @@ -69,13 +76,11 @@ _UCD_access_reg (unw_addr_space_t as, #error Port me #endif - struct UCD_info *ui = arg; if (regnum < 0 || regnum >= (unw_regnum_t)ARRAY_SIZE(remap_regs)) - { - Debug(0, "bad regnum:%d\n", regnum); - return -UNW_EINVAL; - } + goto badreg; + regnum = remap_regs[regnum]; +#endif /* pr_reg is a long[] array, but it contains struct user_regs_struct's * image. @@ -87,4 +92,8 @@ _UCD_access_reg (unw_addr_space_t as, *valp = ui->prstatus->pr_reg[regnum]; return 0; + +badreg: + Debug(0, "bad regnum:%d\n", regnum); + return -UNW_EINVAL; }