diff options
author | Dan Streetman <ddstreet@ieee.org> | 2014-06-04 19:11:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-04 19:54:17 -0400 |
commit | 6e099f557d9c6797c3ee3ee7b5c8cebe543ec1cc (patch) | |
tree | e96a0d9a951dbc494543cf563345c2f6115222f2 /Documentation/CodingStyle | |
parent | 6d9bcb621b0b0a20604cbdb298c4487e44dd0da2 (diff) |
Documentation: expand/clarify debug documentation
The pr_debug() and related debug print macros all differ from the normal
pr_XXX() macros, in that the normal ones print unconditionally, while
the debug macros are compiled out unless DEBUG is defined or
CONFIG_DYNAMIC_DEBUG is set. This isn't obvious, and the only way to
find this out is either to review the actual printk.h code or to read
CodingStyle, and the message there doesn't highlight the fact.
Change Documentation/CodingStyle to clearly indicate that pr_debug() and
related debug printing macros behave differently than all other pr_XXX()
macros, and attempt to clarify when and where the different debug
printing methods might be used.
Add short comment to printk.h above the pr_XXX() macros indicating that
while these macros print unconditionally, pr_debug() does not.
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
Cc: Joe Perches <joe@perches.com>
Cc: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation/CodingStyle')
-rw-r--r-- | Documentation/CodingStyle | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle index 7fe0546c504a..6b6bef31e956 100644 --- a/Documentation/CodingStyle +++ b/Documentation/CodingStyle | |||
@@ -660,15 +660,23 @@ There are a number of driver model diagnostic macros in <linux/device.h> | |||
660 | which you should use to make sure messages are matched to the right device | 660 | which you should use to make sure messages are matched to the right device |
661 | and driver, and are tagged with the right level: dev_err(), dev_warn(), | 661 | and driver, and are tagged with the right level: dev_err(), dev_warn(), |
662 | dev_info(), and so forth. For messages that aren't associated with a | 662 | dev_info(), and so forth. For messages that aren't associated with a |
663 | particular device, <linux/printk.h> defines pr_debug() and pr_info(). | 663 | particular device, <linux/printk.h> defines pr_notice(), pr_info(), |
664 | pr_warn(), pr_err(), etc. | ||
664 | 665 | ||
665 | Coming up with good debugging messages can be quite a challenge; and once | 666 | Coming up with good debugging messages can be quite a challenge; and once |
666 | you have them, they can be a huge help for remote troubleshooting. Such | 667 | you have them, they can be a huge help for remote troubleshooting. However |
667 | messages should be compiled out when the DEBUG symbol is not defined (that | 668 | debug message printing is handled differently than printing other non-debug |
668 | is, by default they are not included). When you use dev_dbg() or pr_debug(), | 669 | messages. While the other pr_XXX() functions print unconditionally, |
669 | that's automatic. Many subsystems have Kconfig options to turn on -DDEBUG. | 670 | pr_debug() does not; it is compiled out by default, unless either DEBUG is |
670 | A related convention uses VERBOSE_DEBUG to add dev_vdbg() messages to the | 671 | defined or CONFIG_DYNAMIC_DEBUG is set. That is true for dev_dbg() also, |
671 | ones already enabled by DEBUG. | 672 | and a related convention uses VERBOSE_DEBUG to add dev_vdbg() messages to |
673 | the ones already enabled by DEBUG. | ||
674 | |||
675 | Many subsystems have Kconfig debug options to turn on -DDEBUG in the | ||
676 | corresponding Makefile; in other cases specific files #define DEBUG. And | ||
677 | when a debug message should be unconditionally printed, such as if it is | ||
678 | already inside a debug-related #ifdef secton, printk(KERN_DEBUG ...) can be | ||
679 | used. | ||
672 | 680 | ||
673 | 681 | ||
674 | Chapter 14: Allocating memory | 682 | Chapter 14: Allocating memory |