Debugging and tracing

From Vertubleu

Jump to: navigation, search

Comprehensive data here: http://www.elinux.org/Kernel_Debugging_Tips#Changing_the_size_of_the_printk_buffer

(includes how to re-size the dmesg buffer)

Contents

loglevel

Detailed information here: loglevel

(how to know of your printk message will go to the console or not)

Dynamic printk

Linux doc: Documentation/dynamic-debug-howto.txt

(supported from kernel 2.6.30 or 31)

debugfs activation

dynamic printk requires the support of debugfs (kernel hacking) and dynamic printk (kernel hacking).

To mount debugfs:

mkdir /mnt/debugfs
mount –t debugfs none /mnt/debugfs

Trace usage in the kernel

Trace points can be defined this way:

dev_dbg(&ssi_ch->dev->device, LOG_NAME "Read cancel on not "
                       "enable logical channel %d CCR REG 0x%08X\n", lch, reg);

With more generic terms:

dev_dbg(struct device, string to trace, … );

For this example, the following line appears in the <debugfs>/dynamic_debug/control file :

drivers/hsi/hsi_driver_dma.c:290 [omap_hsi]hsi_driver_cancel_read_dma - "OMAP HSI: Read cancel on not enable logical channel %d CCR REG 0x%08X\012"

Where:

  • omap_hsi : the device name
  • hsi_driver_cancel_read_dma: the function name (here, LOG_NAME was set to ‘ OMAP HSI : ‘)

Another function is available using the same model for non-device handling modules: pr_debug. For a driver that handles a device, the dev_dbg function shall be used.

If the 'DEBUG' flag is defined, all the dev_dbg and pr_debug are active unconditionnaly.

An example to active some trace points:

echo -n "module <module name> +p" > /mnt/debugfs/dynamic_debug/control

Detailed how-to and examples are in Documentation/dynamic-debug-howto.txt


ftrace

See following articles for a complete description of how to use it:

Intro: http://lwn.net/Articles/322666/

Part 1: http://lwn.net/Articles/365835/

Part 2: http://lwn.net/Articles/366796/

Function tracer: http://lwn.net/Articles/370423/

Function graph on ARM: http://elinux.org/Ftrace_Function_Graph_ARM

kprobes support (x86 in 2.6.33): http://lwn.net/Articles/343766/

Perf

description: http://lwn.net/Articles/373842/

tracepoints http://lwn.net/Articles/346470/

LTTng

The main site: http://www.lttng.org/

A related thesis: http://lwn.net/Articles/370992/

Personal tools