#author("2020-11-12T10:00:23+09:00","default:honma","honma")
#author("2020-11-12T10:10:31+09:00","default:honma","honma")
* デバッグ出力 [#cfe76e7a]

Documentation/process/coding-style.rst からの抜粋。

 13) Printing kernel messages
 ----------------------------
 
 Kernel developers like to be seen as literate. Do mind the spelling
 of kernel messages to make a good impression. Do not use crippled
 words like ``dont``; use ``do not`` or ``don't`` instead.  Make the messages
 concise, clear, and unambiguous.

カーネル開発者は、読み書きができると見なされることを好みます。
良い印象を与えるために、カーネルメッセージのスペルに注意してください。
`` dont``のような不自由な言葉を使用しないでください;代わりに``do not``または``don't``を使用してください。
メッセージを簡潔、明らか、明確にします。

 Kernel messages do not have to be terminated with a period.

カーネルメッセージはピリオドで終了する必要はありません。

 Printing numbers in parentheses (%d) adds no value and should be avoided.

括弧(%d)で数字を印刷しても価値はないため、避ける必要があります。

 There are a number of driver model diagnostic macros in <linux/device.h>
 which you should use to make sure messages are matched to the right device
 and driver, and are tagged with the right level:  dev_err(), dev_warn(),
 dev_info(), and so forth.  For messages that aren't associated with a
 particular device, <linux/printk.h> defines pr_notice(), pr_info(),
 pr_warn(), pr_err(), etc.

<linux/device.h>には、メッセージが適切なデバイスとドライバーに一致し、適切なレベルでタグ付けされていることを確認するために使用する必要のあるドライバーモデル診断マクロがいくつかあります:dev_err()、dev_warn()、 dev_info()など。
~<linux/device.h>には、メッセージが適切なデバイスとドライバーに一致し、適切なレベルでタグ付けされていることを確認するために使用する必要のあるドライバーモデル診断マクロがいくつかあります:dev_err()、dev_warn()、 dev_info()など。
特定のデバイスに関連付けられていないメッセージの場合、<linux/printk.h>はpr_notice()、pr_info()、pr_warn()、pr_err() など。

 Coming up with good debugging messages can be quite a challenge; and once
 you have them, they can be a huge help for remote troubleshooting.  However
 debug message printing is handled differently than printing other non-debug
 messages.  While the other pr_XXX() functions print unconditionally,
 pr_debug() does not; it is compiled out by default, unless either DEBUG is
 defined or CONFIG_DYNAMIC_DEBUG is set.  That is true for dev_dbg() also,
 and a related convention uses VERBOSE_DEBUG to add dev_vdbg() messages to
 the ones already enabled by DEBUG.

優れたデバッグメッセージを思い付くのは非常に難しい場合があります。それらを入手したら、リモートトラブルシューティングに非常に役立ちます。
ただし、デバッグメッセージの出力は、他の非デバッグメッセージの出力とは異なる方法で処理されます。
他のpr_XXX()関数は無条件に出力しますが、pr_debug()は出力しません。 DEBUGが定義されているか、CONFIG_DYNAMIC_DEBUGが設定されていない限り、デフォルトでコンパイルされます。
これはdev_dbg()にも当てはまり、関連する規則ではVERBOSE_DEBUGを使用して、DEBUGによって既に有効になっているメッセージにdev_vdbg()メッセージを追加します。

 Many subsystems have Kconfig debug options to turn on -DDEBUG in the
 corresponding Makefile; in other cases specific files #define DEBUG.  And
 when a debug message should be unconditionally printed, such as if it is
 already inside a debug-related #ifdef section, printk(KERN_DEBUG ...) can be
 used.

多くのサブシステムには、対応するMakefileで-DDEBUGをオンにするKconfigデバッグオプションがあります。その他の場合、特定のファイル#define DEBUG です。
また、デバッグ関連の#ifdefセクション内に既にある場合など、デバッグメッセージを無条件に出力する必要がある場合は、printk(KERN_DEBUG ...)を使用できます。

#htmlinsert(amazon_pc.html);



トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS