blob: 2b16a2ad23dc6b9647028c0808f8f45b094e74ac [file] [log] [blame]
Frederic Weisbeckerc9cf4db2010-05-19 21:35:17 +02001/*
2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
4 */
5
H. Peter Anvin1965aae2008-10-22 22:26:29 -07006#ifndef _ASM_X86_STACKTRACE_H
7#define _ASM_X86_STACKTRACE_H
Andi Kleenc0b766f2006-09-26 10:52:34 +02008
Frederic Weisbeckerc9cf4db2010-05-19 21:35:17 +02009#include <linux/uaccess.h>
10
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010011extern int kstack_depth_to_print;
12
Frederic Weisbecker61c19172009-12-17 05:40:33 +010013struct thread_info;
14struct stacktrace_ops;
15
16typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17 unsigned long *stack,
18 unsigned long bp,
19 const struct stacktrace_ops *ops,
20 void *data,
21 unsigned long *end,
22 int *graph);
23
24extern unsigned long
25print_context_stack(struct thread_info *tinfo,
26 unsigned long *stack, unsigned long bp,
27 const struct stacktrace_ops *ops, void *data,
28 unsigned long *end, int *graph);
29
Frederic Weisbecker06d65bd2009-12-17 05:40:34 +010030extern unsigned long
31print_context_stack_bp(struct thread_info *tinfo,
32 unsigned long *stack, unsigned long bp,
33 const struct stacktrace_ops *ops, void *data,
34 unsigned long *end, int *graph);
35
Andi Kleenc0b766f2006-09-26 10:52:34 +020036/* Generic stack tracer with callbacks */
37
38struct stacktrace_ops {
39 void (*warning)(void *data, char *msg);
40 /* msg must contain %s for the symbol */
41 void (*warning_symbol)(void *data, char *msg, unsigned long symbol);
Arjan van de Venbc850d62008-01-30 13:33:07 +010042 void (*address)(void *data, unsigned long address, int reliable);
Andi Kleenc0b766f2006-09-26 10:52:34 +020043 /* On negative return stop dumping */
44 int (*stack)(void *data, char *name);
Frederic Weisbecker61c19172009-12-17 05:40:33 +010045 walk_stack_t walk_stack;
Andi Kleenc0b766f2006-09-26 10:52:34 +020046};
47
Arjan van de Venbc850d62008-01-30 13:33:07 +010048void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
49 unsigned long *stack, unsigned long bp,
Jan Beulich9689ba82007-10-17 18:04:37 +020050 const struct stacktrace_ops *ops, void *data);
Andi Kleenc0b766f2006-09-26 10:52:34 +020051
Frederic Weisbeckerc9cf4db2010-05-19 21:35:17 +020052#ifdef CONFIG_X86_32
53#define STACKSLOTS_PER_LINE 8
54#define get_bp(bp) asm("movl %%ebp, %0" : "=r" (bp) :)
55#else
56#define STACKSLOTS_PER_LINE 4
57#define get_bp(bp) asm("movq %%rbp, %0" : "=r" (bp) :)
58#endif
59
60extern void
61show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
62 unsigned long *stack, unsigned long bp, char *log_lvl);
63
64extern void
65show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
66 unsigned long *sp, unsigned long bp, char *log_lvl);
67
68extern unsigned int code_bytes;
69
70/* The form of the top of the frame on the stack */
71struct stack_frame {
72 struct stack_frame *next_frame;
73 unsigned long return_address;
74};
75
76struct stack_frame_ia32 {
77 u32 next_frame;
78 u32 return_address;
79};
80
Frederic Weisbeckerb0f82b82010-05-20 07:47:21 +020081static inline unsigned long caller_frame_pointer(void)
Frederic Weisbeckerc9cf4db2010-05-19 21:35:17 +020082{
83 struct stack_frame *frame;
84
85 get_bp(frame);
86
87#ifdef CONFIG_FRAME_POINTER
Frederic Weisbeckerb0f82b82010-05-20 07:47:21 +020088 frame = frame->next_frame;
Frederic Weisbeckerc9cf4db2010-05-19 21:35:17 +020089#endif
90
91 return (unsigned long)frame;
92}
93
H. Peter Anvin1965aae2008-10-22 22:26:29 -070094#endif /* _ASM_X86_STACKTRACE_H */