Enabling Stack Dumping in Linux Kernel

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   


Contents

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.

  1. Kernel hacking -> Kernel debugging
  2. 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.

E2e.jpg For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Enabling Stack Dumping in Linux Kernel here.
Hyperlink blue.png Links
ARM Microcontroller MCU ARM Processor Digital Media Processor Digital Signal Processing Microcontroller MCU Multi Core Processor
Ultra Low Power DSP 8 bit Microcontroller MCU 16 bit Microcontroller MCU 32 bit Microcontroller MCU

Leave a Comment
Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox