xref: /linux/arch/um/include/asm/stacktrace.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_UML_STACKTRACE_H
3 #define _ASM_UML_STACKTRACE_H
4 
5 #include <linux/uaccess.h>
6 #include <linux/ptrace.h>
7 
8 struct stack_frame {
9 	struct stack_frame *next_frame;
10 	unsigned long return_address;
11 };
12 
13 struct stacktrace_ops {
14 	void (*address)(void *data, unsigned long address, int reliable);
15 };
16 
17 #ifdef CONFIG_FRAME_POINTER
18 static inline unsigned long
get_frame_pointer(struct task_struct * task,struct pt_regs * segv_regs)19 get_frame_pointer(struct task_struct *task, struct pt_regs *segv_regs)
20 {
21 	if (!task || task == current)
22 		return segv_regs ? PT_REGS_BP(segv_regs) : current_bp();
23 	return KSTK_EBP(task);
24 }
25 #else
26 static inline unsigned long
get_frame_pointer(struct task_struct * task,struct pt_regs * segv_regs)27 get_frame_pointer(struct task_struct *task, struct pt_regs *segv_regs)
28 {
29 	return 0;
30 }
31 #endif
32 
33 static inline unsigned long
get_stack_pointer(struct task_struct * task,struct pt_regs * segv_regs)34 *get_stack_pointer(struct task_struct *task, struct pt_regs *segv_regs)
35 {
36 	if (!task || task == current)
37 		return segv_regs ? (unsigned long *)PT_REGS_SP(segv_regs) : current_sp();
38 	return (unsigned long *)KSTK_ESP(task);
39 }
40 
41 void dump_trace(struct task_struct *tsk, const struct stacktrace_ops *ops, void *data);
42 
43 #endif /* _ASM_UML_STACKTRACE_H */
44