Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lib/libunwind Use the return address register from the C...



details:   https://anonhg.NetBSD.org/src/rev/e0fd8f9b29e5
branches:  trunk
changeset: 328983:e0fd8f9b29e5
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sat Apr 26 23:17:38 2014 +0000

description:
Use the return address register from the CIE. Based on patch from Nick
Kledzik.

diffstat:

 sys/lib/libunwind/DwarfInstructions.hpp |   5 +----
 sys/lib/libunwind/DwarfParser.hpp       |   3 ++-
 sys/lib/libunwind/Registers.hpp         |  13 -------------
 3 files changed, 3 insertions(+), 18 deletions(-)

diffs (149 lines):

diff -r 22232a6fbe90 -r e0fd8f9b29e5 sys/lib/libunwind/DwarfInstructions.hpp
--- a/sys/lib/libunwind/DwarfInstructions.hpp   Sat Apr 26 22:38:09 2014 +0000
+++ b/sys/lib/libunwind/DwarfInstructions.hpp   Sat Apr 26 23:17:38 2014 +0000
@@ -48,9 +48,6 @@
                           const typename CFI_Parser<A, R>::RegisterLocation &);
 
   static int lastRestoreReg(const R &) { return R::LAST_RESTORE_REG; }
-  static bool isReturnAddressRegister(int regno, const R &) {
-    return regno == R::RETURN_REG;
-  }
 
   static pint_t getCFA(A &addressSpace,
                        const typename CFI_Parser<A, R>::PrologInfo &prolog,
@@ -139,7 +136,7 @@
   for (int i = 0; i <= lastRestoreReg(newRegisters); ++i) {
     if (prolog.savedRegisters[i].location == CFI_Parser<A, R>::kRegisterUnused)
       continue;
-    if (isReturnAddressRegister(i, registers))
+    if (i == (int)cieInfo.returnAddressRegister)
       returnAddress = getSavedRegister(addressSpace, registers, cfa,
                                        prolog.savedRegisters[i]);
     else if (registers.validRegister(i))
diff -r 22232a6fbe90 -r e0fd8f9b29e5 sys/lib/libunwind/DwarfParser.hpp
--- a/sys/lib/libunwind/DwarfParser.hpp Sat Apr 26 22:38:09 2014 +0000
+++ b/sys/lib/libunwind/DwarfParser.hpp Sat Apr 26 23:17:38 2014 +0000
@@ -43,6 +43,7 @@
     uint8_t personalityOffsetInCIE;
     bool isSignalFrame;
     bool fdesHaveAugmentationData;
+    uint8_t returnAddressRegister;
   };
 
   /// Information about an FDE (Frame Description Entry)
@@ -238,7 +239,7 @@
   // Parse data alignment factor
   cieInfo->dataAlignFactor = addressSpace.getSLEB128(p, cieContentEnd);
   // Parse return address register
-  addressSpace.getULEB128(p, cieContentEnd);
+  cieInfo->returnAddressRegister = (uint8_t)addressSpace.getULEB128(p, cieContentEnd);
   // Parse augmentation data based on augmentation string.
   if (addressSpace.get8(strStart) == 'z') {
     // parse augmentation data length
diff -r 22232a6fbe90 -r e0fd8f9b29e5 sys/lib/libunwind/Registers.hpp
--- a/sys/lib/libunwind/Registers.hpp   Sat Apr 26 22:38:09 2014 +0000
+++ b/sys/lib/libunwind/Registers.hpp   Sat Apr 26 23:17:38 2014 +0000
@@ -34,7 +34,6 @@
   enum {
     LAST_REGISTER = REGNO_X86_EIP,
     LAST_RESTORE_REG = REGNO_X86_EIP,
-    RETURN_REG = REGNO_X86_EIP,
     RETURN_OFFSET = 0,
   };
 
@@ -100,7 +99,6 @@
   enum {
     LAST_REGISTER = REGNO_X86_64_RIP,
     LAST_RESTORE_REG = REGNO_X86_64_RIP,
-    RETURN_REG = REGNO_X86_64_RIP,
     RETURN_OFFSET = 0,
   };
 
@@ -169,7 +167,6 @@
   enum {
     LAST_REGISTER = REGNO_PPC32_V31,
     LAST_RESTORE_REG = REGNO_PPC32_V31,
-    RETURN_REG = REGNO_PPC32_LR,
     RETURN_OFFSET = 0,
   };
 
@@ -258,7 +255,6 @@
   enum {
     LAST_REGISTER = REGNO_ARM32_D31,
     LAST_RESTORE_REG = REGNO_ARM32_SPSR,
-    RETURN_REG = REGNO_ARM32_SPSR,
     RETURN_OFFSET = 0,
   };
 
@@ -328,7 +324,6 @@
   enum {
     LAST_REGISTER = REGNO_VAX_PSW,
     LAST_RESTORE_REG = REGNO_VAX_PSW,
-    RETURN_REG = REGNO_VAX_R15,
     RETURN_OFFSET = 0,
   };
 
@@ -400,7 +395,6 @@
   enum {
     LAST_REGISTER = REGNO_M68K_FP7,
     LAST_RESTORE_REG = REGNO_M68K_FP7,
-    RETURN_REG = REGNO_M68K_PC,
     RETURN_OFFSET = 0,
   };
 
@@ -477,7 +471,6 @@
   enum {
     LAST_REGISTER = REGNO_SH3_PR,
     LAST_RESTORE_REG = REGNO_SH3_PR,
-    RETURN_REG = REGNO_SH3_PR,
     RETURN_OFFSET = 0,
   };
 
@@ -542,7 +535,6 @@
   enum {
     LAST_REGISTER = REGNO_SPARC64_PC,
     LAST_RESTORE_REG = REGNO_SPARC64_PC,
-    RETURN_REG = REGNO_SPARC64_R15,
     RETURN_OFFSET = 8,
   };
   typedef uint64_t reg_t;
@@ -606,7 +598,6 @@
   enum {
     LAST_REGISTER = REGNO_SPARC_PC,
     LAST_RESTORE_REG = REGNO_SPARC_PC,
-    RETURN_REG = REGNO_SPARC_R15,
     RETURN_OFFSET = 8,
   };
   typedef uint32_t reg_t;
@@ -672,7 +663,6 @@
   enum {
     LAST_REGISTER = REGNO_ALPHA_F30,
     LAST_RESTORE_REG = REGNO_ALPHA_F30,
-    RETURN_REG = REGNO_ALPHA_R26,
     RETURN_OFFSET = 0,
   };
   typedef uint32_t reg_t;
@@ -740,7 +730,6 @@
   enum {
     LAST_REGISTER = REGNO_HPPA_FR31H,
     LAST_RESTORE_REG = REGNO_HPPA_FR31H,
-    RETURN_REG = REGNO_HPPA_R2,
     RETURN_OFFSET = -3, // strictly speaking, this is a mask
   };
 
@@ -812,7 +801,6 @@
   enum {
     LAST_REGISTER = REGNO_MIPS_F31,
     LAST_RESTORE_REG = REGNO_MIPS_F31,
-    RETURN_REG = REGNO_MIPS_R31,
     RETURN_OFFSET = 0,
   };
 
@@ -884,7 +872,6 @@
   enum {
     LAST_REGISTER = REGNO_MIPS64_F31,
     LAST_RESTORE_REG = REGNO_MIPS64_F31,
-    RETURN_REG = REGNO_MIPS64_R31,
     RETURN_OFFSET = 0,
   };
 



Home | Main Index | Thread Index | Old Index