Skip to content

Commit

Permalink
Merge branch 'sh/dwarf-unwinder' of git://github.com/mfleming/linux-2…
Browse files Browse the repository at this point in the history
….6 into sh/dwarf-unwinder
  • Loading branch information
Paul Mundt committed Aug 21, 2009
2 parents 4ab8f24 + 5580e90 commit c153a58
Show file tree
Hide file tree
Showing 10 changed files with 252 additions and 105 deletions.
25 changes: 25 additions & 0 deletions arch/sh/include/asm/bug.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef __ASM_SH_BUG_H
#define __ASM_SH_BUG_H

#define TRAPA_UNWINDER_BUG_OPCODE 0xc33b /* trapa #0x3b */
#define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */

#ifdef CONFIG_GENERIC_BUG
Expand Down Expand Up @@ -72,6 +73,30 @@ do { \
unlikely(__ret_warn_on); \
})

#define UNWINDER_BUG() \
do { \
__asm__ __volatile__ ( \
"1:\t.short %O0\n" \
_EMIT_BUG_ENTRY \
: \
: "n" (TRAPA_UNWINDER_BUG_OPCODE), \
"i" (__FILE__), \
"i" (__LINE__), "i" (0), \
"i" (sizeof(struct bug_entry))); \
} while (0)

#define UNWINDER_BUG_ON(x) ({ \
int __ret_unwinder_on = !!(x); \
if (__builtin_constant_p(__ret_unwinder_on)) { \
if (__ret_unwinder_on) \
UNWINDER_BUG(); \
} else { \
if (unlikely(__ret_unwinder_on)) \
UNWINDER_BUG(); \
} \
unlikely(__ret_unwinder_on); \
})

#endif /* CONFIG_GENERIC_BUG */

#include <asm-generic/bug.h>
Expand Down
26 changes: 10 additions & 16 deletions arch/sh/include/asm/dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,7 @@ struct dwarf_frame {

unsigned long pc;

struct dwarf_reg *regs;
unsigned int num_regs; /* how many regs are allocated? */

unsigned int depth; /* what level are we in the callstack? */
struct list_head reg_list;

unsigned long cfa;

Expand All @@ -292,20 +289,15 @@ struct dwarf_frame {
* @flags: Describes how to calculate the value of this register
*/
struct dwarf_reg {
struct list_head link;

unsigned int number;

unsigned long addr;
unsigned long flags;
#define DWARF_REG_OFFSET (1 << 0)
};

/**
* dwarf_stack - a DWARF stack contains a collection of DWARF frames
* @depth: the number of frames in the stack
* @level: an array of DWARF frames, indexed by stack level
*
*/
struct dwarf_stack {
unsigned int depth;
struct dwarf_frame **level;
#define DWARF_VAL_OFFSET (1 << 1)
#define DWARF_UNDEFINED (1 << 2)
};

/*
Expand Down Expand Up @@ -372,13 +364,14 @@ static inline unsigned int DW_CFA_operand(unsigned long insn)

extern struct dwarf_frame *dwarf_unwind_stack(unsigned long,
struct dwarf_frame *);
#endif /* __ASSEMBLY__ */
#endif /* !__ASSEMBLY__ */

#define CFI_STARTPROC .cfi_startproc
#define CFI_ENDPROC .cfi_endproc
#define CFI_DEF_CFA .cfi_def_cfa
#define CFI_REGISTER .cfi_register
#define CFI_REL_OFFSET .cfi_rel_offset
#define CFI_UNDEFINED .cfi_undefined

#else

Expand All @@ -392,6 +385,7 @@ extern struct dwarf_frame *dwarf_unwind_stack(unsigned long,
#define CFI_DEF_CFA CFI_IGNORE
#define CFI_REGISTER CFI_IGNORE
#define CFI_REL_OFFSET CFI_IGNORE
#define CFI_UNDEFINED CFI_IGNORE

#ifndef __ASSEMBLY__
static inline void dwarf_unwinder_init(void)
Expand Down
5 changes: 5 additions & 0 deletions arch/sh/include/asm/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ BUILD_TRAP_HANDLER(breakpoint);
BUILD_TRAP_HANDLER(singlestep);
BUILD_TRAP_HANDLER(fpu_error);
BUILD_TRAP_HANDLER(fpu_state_restore);
BUILD_TRAP_HANDLER(unwinder);

#ifdef CONFIG_BUG
extern void handle_BUG(struct pt_regs *);
#endif

#define arch_align_stack(x) (x)

Expand Down
6 changes: 6 additions & 0 deletions arch/sh/include/asm/unwinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ extern void stack_reader_dump(struct task_struct *, struct pt_regs *,
unsigned long *, const struct stacktrace_ops *,
void *);

/*
* Used by fault handling code to signal to the unwinder code that it
* should switch to a different unwinder.
*/
extern int unwinder_faulted;

#endif /* _LINUX_UNWINDER_H */
2 changes: 2 additions & 0 deletions arch/sh/kernel/cpu/sh3/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ ENTRY(handle_interrupt)
bsr save_regs ! needs original pr value in k3
mov #-1, k2 ! default vector kept in k2

setup_frame_reg

! Setup return address and jump to do_IRQ
mov.l 4f, r9 ! fetch return address
lds r9, pr ! put return address in pr
Expand Down
6 changes: 5 additions & 1 deletion arch/sh/kernel/debugtraps.S
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

#if !defined(CONFIG_SH_STANDARD_BIOS)
#define sh_bios_handler debug_trap_handler
#endif

#if !defined(CONFIG_DWARF_UNWINDER)
#define unwinder_trap_handler debug_trap_handler
#endif

.data
Expand All @@ -35,7 +39,7 @@ ENTRY(debug_trap_table)
.long debug_trap_handler /* 0x38 */
.long debug_trap_handler /* 0x39 */
.long debug_trap_handler /* 0x3a */
.long debug_trap_handler /* 0x3b */
.long unwinder_trap_handler /* 0x3b */
.long breakpoint_trap_handler /* 0x3c */
.long singlestep_trap_handler /* 0x3d */
.long bug_trap_handler /* 0x3e */
Expand Down
Loading

0 comments on commit c153a58

Please sign in to comment.