1/* 2 * Copyright (C) 1991, 1992 Linus Torvalds 3 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs 4 */ 5 6#ifndef _ASM_X86_STACKTRACE_H 7#define _ASM_X86_STACKTRACE_H 8 9#include <linux/uaccess.h> 10 11extern int kstack_depth_to_print; 12 13struct 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 30extern 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 36/* 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); 42 void (*address)(void *data, unsigned long address, int reliable); 43 /* On negative return stop dumping */ 44 int (*stack)(void *data, char *name); 45 walk_stack_t walk_stack; 46}; 47 48void dump_trace(struct task_struct *tsk, struct pt_regs *regs, 49 unsigned long *stack, unsigned long bp, 50 const struct stacktrace_ops *ops, void *data); 51 52#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 81static inline unsigned long caller_frame_pointer(void) 82{ 83 struct stack_frame *frame; 84 85 get_bp(frame); 86 87#ifdef CONFIG_FRAME_POINTER 88 frame = frame->next_frame; 89#endif 90 91 return (unsigned long)frame; 92} 93 94#endif /* _ASM_X86_STACKTRACE_H */ 95