Module Name: src Committed By: joerg Date: Wed Apr 2 22:34:29 UTC 2014
Modified Files: src/share/mk: bsd.own.mk src/sys/lib/libunwind: Registers.hpp libunwind.cxx unwind_registers.S Log Message: Support SH3 in our unwinder. To generate a diff of this commit: cvs rdiff -u -r1.792 -r1.793 src/share/mk/bsd.own.mk cvs rdiff -u -r1.7 -r1.8 src/sys/lib/libunwind/Registers.hpp \ src/sys/lib/libunwind/unwind_registers.S cvs rdiff -u -r1.6 -r1.7 src/sys/lib/libunwind/libunwind.cxx Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/mk/bsd.own.mk diff -u src/share/mk/bsd.own.mk:1.792 src/share/mk/bsd.own.mk:1.793 --- src/share/mk/bsd.own.mk:1.792 Tue Mar 25 09:52:55 2014 +++ src/share/mk/bsd.own.mk Wed Apr 2 22:34:29 2014 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.own.mk,v 1.792 2014/03/25 09:52:55 ozaki-r Exp $ +# $NetBSD: bsd.own.mk,v 1.793 2014/04/02 22:34:29 joerg Exp $ # This needs to be before bsd.init.mk .if defined(BSD_MK_COMPAT_FILE) @@ -101,6 +101,8 @@ HAVE_LIBGCC?= yes _LIBC_UNWIND_SUPPORT.i386= yes _LIBC_UNWIND_SUPPORT.m68k= yes _LIBC_UNWIND_SUPPORT.powerpc= yes +_LIBC_UNWIND_SUPPORT.sh3el= yes +_LIBC_UNWIND_SUPPORT.sh3eb= yes _LIBC_UNWIND_SUPPORT.vax= yes _LIBC_UNWIND_SUPPORT.x86_64= yes .if ${MKLLVM:Uno} == "yes" && ${_LIBC_UNWIND_SUPPORT.${MACHINE_ARCH}:Uno} == "yes" Index: src/sys/lib/libunwind/Registers.hpp diff -u src/sys/lib/libunwind/Registers.hpp:1.7 src/sys/lib/libunwind/Registers.hpp:1.8 --- src/sys/lib/libunwind/Registers.hpp:1.7 Tue Mar 25 00:00:55 2014 +++ src/sys/lib/libunwind/Registers.hpp Wed Apr 2 22:34:29 2014 @@ -454,6 +454,70 @@ private: fpreg_t fpreg[8]; }; +enum { + DWARF_SH3_R0 = 0, + DWARF_SH3_R15 = 15, + DWARF_SH3_PC = 16, + DWARF_SH3_PR = 17, + + REGNO_SH3_R0 = 0, + REGNO_SH3_R15 = 15, + REGNO_SH3_PC = 16, + REGNO_SH3_PR = 17, +}; + +class Registers_SH3 { +public: + enum { + LAST_REGISTER = REGNO_SH3_PR, + LAST_RESTORE_REG = REGNO_SH3_PR, + RETURN_REG = REGNO_SH3_PR, + }; + + __dso_hidden Registers_SH3(); + + static int dwarf2regno(int num) { + if (num >= DWARF_SH3_R0 && num <= DWARF_SH3_R15) + return REGNO_SH3_R0 + (num - DWARF_SH3_R0); + if (num == DWARF_SH3_PC) + return REGNO_SH3_PC; + if (num == DWARF_SH3_PR) + return REGNO_SH3_PR; + return LAST_REGISTER + 1; + } + + bool validRegister(int num) const { + return num >= 0 && num <= REGNO_SH3_PR; + } + + uint64_t getRegister(int num) const { + assert(validRegister(num)); + return reg[num]; + } + + void setRegister(int num, uint64_t value) { + assert(validRegister(num)); + reg[num] = value; + } + + uint64_t getIP() const { return reg[REGNO_SH3_PC]; } + + void setIP(uint64_t value) { reg[REGNO_SH3_PC] = value; } + + uint64_t getSP() const { return reg[REGNO_SH3_R15]; } + + void setSP(uint64_t value) { reg[REGNO_SH3_R15] = value; } + + bool validFloatVectorRegister(int num) const { return false; } + + void copyFloatVectorRegister(int num, uint64_t addr_) {} + + __dso_hidden void jumpto() const __dead; + +private: + uint32_t reg[REGNO_SH3_PR + 1]; +}; + } // namespace _Unwind #endif // __REGISTERS_HPP__ Index: src/sys/lib/libunwind/unwind_registers.S diff -u src/sys/lib/libunwind/unwind_registers.S:1.7 src/sys/lib/libunwind/unwind_registers.S:1.8 --- src/sys/lib/libunwind/unwind_registers.S:1.7 Tue Mar 25 00:00:55 2014 +++ src/sys/lib/libunwind/unwind_registers.S Wed Apr 2 22:34:29 2014 @@ -364,3 +364,60 @@ ENTRY(_ZNK7_Unwind14Registers_M68K6jumpt rts END(_ZNK7_Unwind14Registers_M68K6jumptoEv) #endif + +#if defined(__sh3__) + .hidden _ZN7_Unwind13Registers_SH3C1Ev +ENTRY(_ZN7_Unwind13Registers_SH3C1Ev) + add #64, r4 + mov.l r8, @-r15 + sts.l pr, @-r15 + mov.l @r15+, r8 + mov.l r8, @r4 + mov.l @r15+, r8 + + mov.l r15, @-r4 + mov.l r14, @-r4 + mov.l r13, @-r4 + mov.l r12, @-r4 + mov.l r11, @-r4 + mov.l r10, @-r4 + mov.l r9, @-r4 + mov.l r8, @-r4 + mov.l r7, @-r4 + mov.l r6, @-r4 + mov.l r5, @-r4 + add #-4, r4 + mov.l r3, @-r4 + mov.l r2, @-r4 + mov.l r1, @-r4 + mov.l r0, @-r4 + rts + mov.l r4, @(16,r4) +SET_ENTRY_SIZE(_ZN7_Unwind13Registers_SH3C1Ev) + + .hidden _ZNK7_Unwind13Registers_SH36jumptoEv +ENTRY(_ZNK7_Unwind13Registers_SH36jumptoEv) + mov r4, r0 + add #4, r0 + mov.l @r0+, r1 + mov.l @r0+, r2 + mov.l @r0+, r3 + mov.l @r0+, r4 + mov.l @r0+, r5 + mov.l @r0+, r6 + mov.l @r0+, r7 + mov.l @r0+, r8 + mov.l @r0+, r9 + mov.l @r0+, r10 + mov.l @r0+, r11 + mov.l @r0+, r12 + mov.l @r0+, r13 + mov.l @(12, r0), r14 + lds r14, pr + mov.l @r0+, r14 + mov.l @r0+, r15 + mov.l @r0, r0 + jmp @r0 + nop +SET_ENTRY_SIZE(_ZNK7_Unwind13Registers_SH36jumptoEv) +#endif Index: src/sys/lib/libunwind/libunwind.cxx diff -u src/sys/lib/libunwind/libunwind.cxx:1.6 src/sys/lib/libunwind/libunwind.cxx:1.7 --- src/sys/lib/libunwind/libunwind.cxx:1.6 Mon Mar 24 21:25:03 2014 +++ src/sys/lib/libunwind/libunwind.cxx Wed Apr 2 22:34:29 2014 @@ -29,6 +29,8 @@ typedef Registers_arm32 ThisUnwindRegist typedef Registers_vax ThisUnwindRegisters; #elif __m68k__ typedef Registers_M68K ThisUnwindRegisters; +#elif __sh3__ +typedef Registers_SH3 ThisUnwindRegisters; #else #error Unsupported architecture #endif