1. Kernel态
执行dump_stack就可打印stack信息.
asmlinkage void __div0(void)
{
printk("Division by zero in kernel.\n");
dump_stack(); // dump current task stack
}
2. Java
Exeption e = new Exception("this is a log");
e.printStackTrace();
或
try {
int i = 0;
throw new Exception("2222");
} catch(Exception e) {
e.printStackTrace();
}