Saturday, February 07, 2009

x86 32bit call backtrace

需include

driver可以用dump_stack() 這個func來back trace
不過還沒有試過,能不能work還未知

底下是x86 32bit的實作
http://lxr.linux.no/linux+v2.6.27.2/arch/x86/kernel/traps_32.c#L288
288void dump_stack(void)
289{
290 unsigned long bp = 0;
291 unsigned long stack;
292
293#ifdef CONFIG_FRAME_POINTER
294 if (!bp)
295 asm("movl %%ebp, %0" : "=r" (bp):);
296#endif
297
298 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
299 current->pid, current->comm, print_tainted(),
300 init_utsname()->release,
301 (int)strcspn(init_utsname()->version, " "),
302 init_utsname()->version);
303
304 show_trace(current, NULL, &stack, bp);
305}
306
307EXPORT_SYMBOL(dump_stack);

No comments: