Please note that User Registration has been temporarily disabled due to a recent increase in automated registrations. If anyone needs an account, please request one here: RequestAccount. Thanks for your patience!--Wmat (talk)
Please email User:Wmat if you experience any issues with the Request Account form.

Difference between revisions of "Debugging by printing"

From eLinux.org
Jump to: navigation, search
m (inserted missing 'of')
Line 5: Line 5:
 
Probably the simplest way to get some information from the kernel is '''debugging by printing''', especially using the kernels equivalent of ''printf'', the [[printk]] function.
 
Probably the simplest way to get some information from the kernel is '''debugging by printing''', especially using the kernels equivalent of ''printf'', the [[printk]] function.
  
The main advantage debugging with printk is that no sophisticated setup is needed and printk can be called from almost anywhere at any time.
+
The main advantage of debugging with printk is that no sophisticated setup is needed and printk can be called from almost anywhere at any time.
 
Printk can be called while holding a lock, from interrupt and process context and does not need any special preparation. It is just there and just works.
 
Printk can be called while holding a lock, from interrupt and process context and does not need any special preparation. It is just there and just works.
  

Revision as of 22:02, 15 June 2011


Note: This article is currently only a draft and is a part of a series of articles I'm going to publish the next few months - if you want to contribute to it, please feel free to. However it would be nice if you could coordinate your efforts with me


Probably the simplest way to get some information from the kernel is debugging by printing, especially using the kernels equivalent of printf, the printk function.

The main advantage of debugging with printk is that no sophisticated setup is needed and printk can be called from almost anywhere at any time. Printk can be called while holding a lock, from interrupt and process context and does not need any special preparation. It is just there and just works.

The only real exception is early in the boot process where no console is available yet, but there is special function named 'early_printk' just for this special case, which is available if CONFIG_EARLY_PRINTK is set.


What this article will be about - ideas

  • printk format
  • Debug/log levels - dmesg -n /proc/sys/kernel/printk
  • printk_ratelimited
  • dynamic debug, pr_debug and dev_dbg
  • pr_warn and family - see printk.h for details
  • early_printk
  • printascii, printch and printhex (on ARM only?)
  • /dev/kmsg
  • Examples - maybe use example module.


References


External links