Merge tag 'pm-4.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
[linux/fpc-iii.git] / arch / x86 / include / asm / stacktrace.h
blob2e41c50ddf47f414c8f2e4b0a99965ceafffb4bf
1 /*
2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
4 */
6 #ifndef _ASM_X86_STACKTRACE_H
7 #define _ASM_X86_STACKTRACE_H
9 #include <linux/uaccess.h>
10 #include <linux/ptrace.h>
11 #include <asm/switch_to.h>
13 enum stack_type {
14 STACK_TYPE_UNKNOWN,
15 STACK_TYPE_TASK,
16 STACK_TYPE_IRQ,
17 STACK_TYPE_SOFTIRQ,
18 STACK_TYPE_EXCEPTION,
19 STACK_TYPE_EXCEPTION_LAST = STACK_TYPE_EXCEPTION + N_EXCEPTION_STACKS-1,
22 struct stack_info {
23 enum stack_type type;
24 unsigned long *begin, *end, *next_sp;
27 bool in_task_stack(unsigned long *stack, struct task_struct *task,
28 struct stack_info *info);
30 int get_stack_info(unsigned long *stack, struct task_struct *task,
31 struct stack_info *info, unsigned long *visit_mask);
33 const char *stack_type_name(enum stack_type type);
35 static inline bool on_stack(struct stack_info *info, void *addr, size_t len)
37 void *begin = info->begin;
38 void *end = info->end;
40 return (info->type != STACK_TYPE_UNKNOWN &&
41 addr >= begin && addr < end &&
42 addr + len > begin && addr + len <= end);
45 #ifdef CONFIG_X86_32
46 #define STACKSLOTS_PER_LINE 8
47 #else
48 #define STACKSLOTS_PER_LINE 4
49 #endif
51 #ifdef CONFIG_FRAME_POINTER
52 static inline unsigned long *
53 get_frame_pointer(struct task_struct *task, struct pt_regs *regs)
55 if (regs)
56 return (unsigned long *)regs->bp;
58 if (task == current)
59 return __builtin_frame_address(0);
61 return &((struct inactive_task_frame *)task->thread.sp)->bp;
63 #else
64 static inline unsigned long *
65 get_frame_pointer(struct task_struct *task, struct pt_regs *regs)
67 return NULL;
69 #endif /* CONFIG_FRAME_POINTER */
71 static inline unsigned long *
72 get_stack_pointer(struct task_struct *task, struct pt_regs *regs)
74 if (regs)
75 return (unsigned long *)kernel_stack_pointer(regs);
77 if (task == current)
78 return __builtin_frame_address(0);
80 return (unsigned long *)task->thread.sp;
83 void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
84 unsigned long *stack, char *log_lvl);
86 extern unsigned int code_bytes;
88 /* The form of the top of the frame on the stack */
89 struct stack_frame {
90 struct stack_frame *next_frame;
91 unsigned long return_address;
94 struct stack_frame_ia32 {
95 u32 next_frame;
96 u32 return_address;
99 static inline unsigned long caller_frame_pointer(void)
101 struct stack_frame *frame;
103 frame = __builtin_frame_address(0);
105 #ifdef CONFIG_FRAME_POINTER
106 frame = frame->next_frame;
107 #endif
109 return (unsigned long)frame;
112 #endif /* _ASM_X86_STACKTRACE_H */