Enabling Stack Dumping in Linux Kernel

Purpose

It can often be useful when debugging the kernel to be able to print the stack (and call trace) in the Linux kernel. While you could force a kernel panic to make this happen that is often less than desirable. Instead you would want to use the dump_stack() function which will give you a call trace. This function is not enabled in the default kernel and must be enabled. This article will cover how to enable and use the dump_stack() function.

Enabling in Kernel Config

To enable the dump_stack() function in the kernel config the following options must be set. You can use make menuconfig or make xconfig to do this.

    Kernel hacking -> Kernel debugging
    Kernel hacking -> Verbose kernel error 

messages

Enabling these two options will change the dump_stack() function from a do nothing function to dumping the stack.

You need to rebuild your Linux kernel image after enabling these options.

Using dump_stack()

Using the dump_stack() function is as easy as calling dump_stack() wherever you wish to print out the stack. This will cause a stack trace to be printed at that point.

Conclusion

This is a useful way to print out the stack while leaving the kernel unharmed.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值