2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
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>
19 STACK_TYPE_EXCEPTION_LAST = STACK_TYPE_EXCEPTION + N_EXCEPTION_STACKS-1,
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);
46 #define STACKSLOTS_PER_LINE 8
48 #define STACKSLOTS_PER_LINE 4
51 #ifdef CONFIG_FRAME_POINTER
52 static inline unsigned long *
53 get_frame_pointer(struct task_struct *task, struct pt_regs *regs)
55 struct inactive_task_frame *frame;
58 return (unsigned long *)regs->bp;
61 return __builtin_frame_address(0);
63 frame = (struct inactive_task_frame *)task->thread.sp;
64 return (unsigned long *)READ_ONCE_NOCHECK(frame->bp);
67 static inline unsigned long *
68 get_frame_pointer(struct task_struct *task, struct pt_regs *regs)
72 #endif /* CONFIG_FRAME_POINTER */
74 static inline unsigned long *
75 get_stack_pointer(struct task_struct *task, struct pt_regs *regs)
78 return (unsigned long *)kernel_stack_pointer(regs);
81 return __builtin_frame_address(0);
83 return (unsigned long *)task->thread.sp;
86 void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
87 unsigned long *stack, char *log_lvl);
89 extern unsigned int code_bytes;
91 /* The form of the top of the frame on the stack */
93 struct stack_frame *next_frame;
94 unsigned long return_address;
97 struct stack_frame_ia32 {
102 static inline unsigned long caller_frame_pointer(void)
104 struct stack_frame *frame;
106 frame = __builtin_frame_address(0);
108 #ifdef CONFIG_FRAME_POINTER
109 frame = frame->next_frame;
112 return (unsigned long)frame;
115 #endif /* _ASM_X86_STACKTRACE_H */