blob: 29e5f7c845b25e4ef3d92f6bc79a7e79c050e942 [file] [log] [blame]
Neil Horman878719e2008-10-23 10:40:06 -04001/*
2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
4 */
5
6#ifndef DUMPSTACK_H
7#define DUMPSTACK_H
8
9#ifdef CONFIG_X86_32
10#define STACKSLOTS_PER_LINE 8
11#define get_bp(bp) asm("movl %%ebp, %0" : "=r" (bp) :)
12#else
13#define STACKSLOTS_PER_LINE 4
14#define get_bp(bp) asm("movq %%rbp, %0" : "=r" (bp) :)
15#endif
16
Neil Horman878719e2008-10-23 10:40:06 -040017extern void
18show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
19 unsigned long *stack, unsigned long bp, char *log_lvl);
20
21extern void
22show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
23 unsigned long *sp, unsigned long bp, char *log_lvl);
24
25extern unsigned int code_bytes;
Neil Horman878719e2008-10-23 10:40:06 -040026
27/* The form of the top of the frame on the stack */
28struct stack_frame {
29 struct stack_frame *next_frame;
30 unsigned long return_address;
31};
Frederic Weisbecker5331d7b2010-03-04 21:15:56 +010032
33static inline unsigned long rewind_frame_pointer(int n)
34{
35 struct stack_frame *frame;
36
37 get_bp(frame);
38
39#ifdef CONFIG_FRAME_POINTER
40 while (n--)
41 frame = frame->next_frame;
Neil Horman878719e2008-10-23 10:40:06 -040042#endif
Frederic Weisbecker5331d7b2010-03-04 21:15:56 +010043
44 return (unsigned long)frame;
45}
46
47#endif /* DUMPSTACK_H */