卖萌的弱渣

I am stupid, I am hungry.

Dump Stack in Linux

dump_stack() is a useful tool to understand call procedure of a function. You can enable it in the kernel source.

Enable dump_stack

Make sure the following flag is y

  • CONFIG_PREEMPT
  • CONFIG_DEBUG_KERNEL
  • CONFIG_KALLSYMS
  • CONFIG_SPINLOCK_SLEEP
  • CONFIG_MAGIC_SYSRQ

Use dump_stack in your code

1
2
printk(KERN_ERR, "%x", parameter);
dump_stack()

After that

You can watch the stack result in dmesg