stacktrace.c
来自「linux 内核源代码」· C语言 代码 · 共 36 行
C
36 行
#include <linux/sched.h>#include <linux/stacktrace.h>#include <linux/thread_info.h>#include <asm/ptrace.h>void save_stack_trace(struct stack_trace *trace){ unsigned long ksp, fp, thread_base; struct thread_info *tp = task_thread_info(current); flushw_all(); __asm__ __volatile__( "mov %%fp, %0" : "=r" (ksp) ); fp = ksp + STACK_BIAS; thread_base = (unsigned long) tp; do { struct reg_window *rw; /* Bogus frame pointer? */ if (fp < (thread_base + sizeof(struct thread_info)) || fp >= (thread_base + THREAD_SIZE)) break; rw = (struct reg_window *) fp; if (trace->skip > 0) trace->skip--; else trace->entries[trace->nr_entries++] = rw->ins[7]; fp = rw->ins[6] + STACK_BIAS; } while (trace->nr_entries < trace->max_entries);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?