Add m68k support to our unwinder.

This commit is contained in:
joerg 2014-03-24 21:25:03 +00:00
parent fc1afab118
commit 0378fc4757
4 changed files with 94 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.own.mk,v 1.790 2014/03/18 13:10:27 joerg Exp $
# $NetBSD: bsd.own.mk,v 1.791 2014/03/24 21:25:03 joerg Exp $
# This needs to be before bsd.init.mk
.if defined(BSD_MK_COMPAT_FILE)
@ -99,6 +99,7 @@ HAVE_LIBGCC?= yes
.endif
_LIBC_UNWIND_SUPPORT.i386= yes
_LIBC_UNWIND_SUPPORT.m68k= yes
_LIBC_UNWIND_SUPPORT.powerpc= yes
_LIBC_UNWIND_SUPPORT.vax= yes
_LIBC_UNWIND_SUPPORT.x86_64= yes

View File

@ -372,6 +372,75 @@ private:
uint32_t reg[REGNO_VAX_PSW + 1];
};
enum {
DWARF_M68K_A0 = 0,
DWARF_M68K_A7 = 7,
DWARF_M68K_D0 = 8,
DWARF_M68K_D7 = 15,
DWARF_M68K_PC = 24,
REGNO_M68K_A0 = 0,
REGNO_M68K_A7 = 7,
REGNO_M68K_D0 = 8,
REGNO_M68K_D7 = 15,
REGNO_M68K_PC = 16,
};
class Registers_M68K {
public:
enum {
LAST_REGISTER = REGNO_M68K_PC,
LAST_RESTORE_REG = REGNO_M68K_PC,
RETURN_REG = REGNO_M68K_PC,
};
__dso_hidden Registers_M68K();
static int dwarf2regno(int num) {
if (num >= DWARF_M68K_A0 && num <= DWARF_M68K_A7)
return REGNO_M68K_A0 + (num - DWARF_M68K_A0);
if (num >= DWARF_M68K_D0 && num <= DWARF_M68K_D7)
return REGNO_M68K_D0 + (num - DWARF_M68K_D0);
if (num == DWARF_M68K_PC)
return REGNO_M68K_PC;
return LAST_REGISTER + 1;
}
bool validRegister(int num) const {
return num >= 0 && num <= LAST_RESTORE_REG;
}
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_M68K_PC]; }
void setIP(uint64_t value) { reg[REGNO_M68K_PC] = value; }
uint64_t getSP() const { return reg[REGNO_M68K_A7]; }
void setSP(uint64_t value) { reg[REGNO_M68K_A7] = 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_M68K_PC + 1];
};
} // namespace _Unwind
#endif // __REGISTERS_HPP__

View File

@ -27,6 +27,8 @@ typedef Registers_ppc32 ThisUnwindRegisters;
typedef Registers_arm32 ThisUnwindRegisters;
#elif __vax__
typedef Registers_vax ThisUnwindRegisters;
#elif __m68k__
typedef Registers_M68K ThisUnwindRegisters;
#else
#error Unsupported architecture
#endif

View File

@ -339,6 +339,26 @@ ENTRY(_ZNK7_Unwind13Registers_vax6jumptoEv, 0)
movl 0(%r0), %r0
/* XXX restore PSW */
rsb
END(_ZNK7_Unwind13Registers_vax6jumptoEv)
#endif
#if defined(__m68k__)
ENTRY(_ZN7_Unwind14Registers_M68KC1Ev)
move.l 4(%sp), %a0
movem.l %d0-%d7/%a0-%a7, (%a0)
move.l 0(%sp), %a1
move.l %a1, 64(%a0)
addq.l #4, 60(%a0)
rts
END(_ZN7_Unwind14Registers_M68KC1Ev)
ENTRY(_ZNK7_Unwind14Registers_M68K6jumptoEv)
move.l 4(%sp), %a0
subq.l #4, 60(%a0)
move.l 64(%a0), %a1
move.l 60(%a0), %a2
move.l %a1, (%a2)
movem.l (%a0), %d0-%d7/%a0-%a7
rts
END(_ZNK7_Unwind14Registers_M68K6jumptoEv)
#endif