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>
12 extern int kstack_depth_to_print
;
15 struct stacktrace_ops
;
17 typedef unsigned long (*walk_stack_t
)(struct thread_info
*tinfo
,
20 const struct stacktrace_ops
*ops
,
26 print_context_stack(struct thread_info
*tinfo
,
27 unsigned long *stack
, unsigned long bp
,
28 const struct stacktrace_ops
*ops
, void *data
,
29 unsigned long *end
, int *graph
);
32 print_context_stack_bp(struct thread_info
*tinfo
,
33 unsigned long *stack
, unsigned long bp
,
34 const struct stacktrace_ops
*ops
, void *data
,
35 unsigned long *end
, int *graph
);
37 /* Generic stack tracer with callbacks */
39 struct stacktrace_ops
{
40 void (*warning
)(void *data
, char *msg
);
41 /* msg must contain %s for the symbol */
42 void (*warning_symbol
)(void *data
, char *msg
, unsigned long symbol
);
43 void (*address
)(void *data
, unsigned long address
, int reliable
);
44 /* On negative return stop dumping */
45 int (*stack
)(void *data
, char *name
);
46 walk_stack_t walk_stack
;
49 void dump_trace(struct task_struct
*tsk
, struct pt_regs
*regs
,
50 unsigned long *stack
, unsigned long bp
,
51 const struct stacktrace_ops
*ops
, void *data
);
54 #define STACKSLOTS_PER_LINE 8
55 #define get_bp(bp) asm("movl %%ebp, %0" : "=r" (bp) :)
57 #define STACKSLOTS_PER_LINE 4
58 #define get_bp(bp) asm("movq %%rbp, %0" : "=r" (bp) :)
61 #ifdef CONFIG_FRAME_POINTER
62 static inline unsigned long
63 stack_frame(struct task_struct
*task
, struct pt_regs
*regs
)
70 if (task
== current
) {
71 /* Grab bp right from our regs */
76 /* bp is the last reg pushed by switch_to */
77 return *(unsigned long *)task
->thread
.sp
;
80 static inline unsigned long
81 stack_frame(struct task_struct
*task
, struct pt_regs
*regs
)
88 show_trace_log_lvl(struct task_struct
*task
, struct pt_regs
*regs
,
89 unsigned long *stack
, unsigned long bp
, char *log_lvl
);
92 show_stack_log_lvl(struct task_struct
*task
, struct pt_regs
*regs
,
93 unsigned long *sp
, unsigned long bp
, char *log_lvl
);
95 extern unsigned int code_bytes
;
97 /* The form of the top of the frame on the stack */
99 struct stack_frame
*next_frame
;
100 unsigned long return_address
;
103 struct stack_frame_ia32
{
108 static inline unsigned long caller_frame_pointer(void)
110 struct stack_frame
*frame
;
114 #ifdef CONFIG_FRAME_POINTER
115 frame
= frame
->next_frame
;
118 return (unsigned long)frame
;
121 #endif /* _ASM_X86_STACKTRACE_H */