Merge branches 'fixes', 'pgt-next' and 'versatile' into devel
[deliverable/linux.git] / arch / x86 / include / asm / stacktrace.h
CommitLineData
c9cf4dbb
FW
1/*
2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
4 */
5
1965aae3
PA
6#ifndef _ASM_X86_STACKTRACE_H
7#define _ASM_X86_STACKTRACE_H
c0b766f1 8
c9cf4dbb 9#include <linux/uaccess.h>
9c0729dc 10#include <linux/ptrace.h>
c9cf4dbb 11
0741f4d2
CE
12extern int kstack_depth_to_print;
13
61c1917f
FW
14struct thread_info;
15struct stacktrace_ops;
16
17typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
18 unsigned long *stack,
19 unsigned long bp,
20 const struct stacktrace_ops *ops,
21 void *data,
22 unsigned long *end,
23 int *graph);
24
25extern unsigned long
26print_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);
30
06d65bda
FW
31extern unsigned long
32print_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);
36
c0b766f1
AK
37/* Generic stack tracer with callbacks */
38
39struct 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);
bc850d6b 43 void (*address)(void *data, unsigned long address, int reliable);
c0b766f1
AK
44 /* On negative return stop dumping */
45 int (*stack)(void *data, char *name);
61c1917f 46 walk_stack_t walk_stack;
c0b766f1
AK
47};
48
bc850d6b 49void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
9c0729dc 50 unsigned long *stack,
9689ba8a 51 const struct stacktrace_ops *ops, void *data);
c0b766f1 52
c9cf4dbb
FW
53#ifdef CONFIG_X86_32
54#define STACKSLOTS_PER_LINE 8
55#define get_bp(bp) asm("movl %%ebp, %0" : "=r" (bp) :)
56#else
57#define STACKSLOTS_PER_LINE 4
58#define get_bp(bp) asm("movq %%rbp, %0" : "=r" (bp) :)
59#endif
60
9c0729dc
SSP
61#ifdef CONFIG_FRAME_POINTER
62static inline unsigned long
63stack_frame(struct task_struct *task, struct pt_regs *regs)
64{
65 unsigned long bp;
66
67 if (regs)
68 return regs->bp;
69
70 if (task == current) {
71 /* Grab bp right from our regs */
72 get_bp(bp);
73 return bp;
74 }
75
76 /* bp is the last reg pushed by switch_to */
77 return *(unsigned long *)task->thread.sp;
78}
79#else
80static inline unsigned long
81stack_frame(struct task_struct *task, struct pt_regs *regs)
82{
83 return 0;
84}
85#endif
86
c9cf4dbb
FW
87extern void
88show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
9c0729dc 89 unsigned long *stack, char *log_lvl);
c9cf4dbb
FW
90
91extern void
92show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
9c0729dc 93 unsigned long *sp, char *log_lvl);
c9cf4dbb
FW
94
95extern unsigned int code_bytes;
96
97/* The form of the top of the frame on the stack */
98struct stack_frame {
99 struct stack_frame *next_frame;
100 unsigned long return_address;
101};
102
103struct stack_frame_ia32 {
104 u32 next_frame;
105 u32 return_address;
106};
107
b0f82b81 108static inline unsigned long caller_frame_pointer(void)
c9cf4dbb
FW
109{
110 struct stack_frame *frame;
111
112 get_bp(frame);
113
114#ifdef CONFIG_FRAME_POINTER
b0f82b81 115 frame = frame->next_frame;
c9cf4dbb
FW
116#endif
117
118 return (unsigned long)frame;
119}
120
1965aae3 121#endif /* _ASM_X86_STACKTRACE_H */
This page took 0.471069 seconds and 5 git commands to generate.