1 #ifndef _ASM_I386_UNWIND_H
2 #define _ASM_I386_UNWIND_H
5 * Copyright (C) 2002-2006 Novell, Inc.
6 * Jan Beulich <jbeulich@novell.com>
7 * This code is released under version 2 of the GNU GPL.
10 #ifdef CONFIG_STACK_UNWIND
12 #include <linux/sched.h>
13 #include <asm/fixmap.h>
14 #include <asm/ptrace.h>
15 #include <asm/uaccess.h>
17 struct unwind_frame_info
20 struct task_struct
*task
;
23 #define UNW_PC(frame) (frame)->regs.eip
24 #define UNW_SP(frame) (frame)->regs.esp
25 #ifdef CONFIG_FRAME_POINTER
26 #define UNW_FP(frame) (frame)->regs.ebp
27 #define FRAME_RETADDR_OFFSET 4
28 #define FRAME_LINK_OFFSET 0
29 #define STACK_BOTTOM(tsk) STACK_LIMIT((tsk)->thread.esp0)
30 #define STACK_TOP(tsk) ((tsk)->thread.esp0)
32 #define STACK_LIMIT(ptr) (((ptr) - 1) & ~(THREAD_SIZE - 1))
34 #define UNW_REGISTER_INFO \
45 static inline void arch_unw_init_frame_info(struct unwind_frame_info
*info
,
46 /*const*/ struct pt_regs
*regs
)
48 if (user_mode_vm(regs
))
51 memcpy(&info
->regs
, regs
, offsetof(struct pt_regs
, esp
));
52 info
->regs
.esp
= (unsigned long)®s
->esp
;
53 info
->regs
.xss
= __KERNEL_DS
;
57 static inline void arch_unw_init_blocked(struct unwind_frame_info
*info
)
59 memset(&info
->regs
, 0, sizeof(info
->regs
));
60 info
->regs
.eip
= info
->task
->thread
.eip
;
61 info
->regs
.xcs
= __KERNEL_CS
;
62 __get_user(info
->regs
.ebp
, (long *)info
->task
->thread
.esp
);
63 info
->regs
.esp
= info
->task
->thread
.esp
;
64 info
->regs
.xss
= __KERNEL_DS
;
65 info
->regs
.xds
= __USER_DS
;
66 info
->regs
.xes
= __USER_DS
;
69 extern asmlinkage
int arch_unwind_init_running(struct unwind_frame_info
*,
70 asmlinkage
int (*callback
)(struct unwind_frame_info
*,
74 static inline int arch_unw_user_mode(const struct unwind_frame_info
*info
)
76 #if 0 /* This can only work when selector register and EFLAGS saves/restores
77 are properly annotated (and tracked in UNW_REGISTER_INFO). */
78 return user_mode_vm(&info
->regs
);
80 return info
->regs
.eip
< PAGE_OFFSET
81 || (info
->regs
.eip
>= __fix_to_virt(FIX_VDSO
)
82 && info
->regs
.eip
< __fix_to_virt(FIX_VDSO
) + PAGE_SIZE
)
83 || info
->regs
.esp
< PAGE_OFFSET
;
89 #define UNW_PC(frame) ((void)(frame), 0)
90 #define UNW_SP(frame) ((void)(frame), 0)
92 static inline int arch_unw_user_mode(const void *info
)
99 #endif /* _ASM_I386_UNWIND_H */