First bad bad pass.
[cascardo/kernel/notes/.git] / 05.debug / 1.printk / text
1 printk(KERN_XXX "message");
2 Notar a falta de vírgula. A macro expande para <X>, onde X é um número.
3 Isso é interpretado por klogd (ou libc - man klogctl).
4
5 Da mesma manpage, também em include/linux/kernel.h:
6        #define KERN_EMERG    "<0>"  /* system is unusable               */
7        #define KERN_ALERT    "<1>"  /* action must be taken immediately */
8        #define KERN_CRIT     "<2>"  /* critical conditions              */
9        #define KERN_ERR      "<3>"  /* error conditions                 */
10        #define KERN_WARNING  "<4>"  /* warning conditions               */
11        #define KERN_NOTICE   "<5>"  /* normal but significant condition */
12        #define KERN_INFO     "<6>"  /* informational                    */
13        #define KERN_DEBUG    "<7>"  /* debug-level messages             */
14
15 printk_once - macro que imprime apenas uma vez
16 printk_ratelimit - if (printk_ratelimit()) { } - limite por função
17 imprime no máximo 10 vezes em 5 segundos, parâmetros configuráveis
18 /proc/sys/kernel/printk_ratelimit{,_burst}
19
20 printk_ratelimited(fmt, ...) - valores padrões apenas
21
22 --
23
24 Ainda em include/linux/kernel.h
25
26 pr_emerg
27 pr_alert
28 pr_crit
29 pr_err
30 pr_warning
31 pr_notice
32 pr_info
33 pr_devel -- apenas se macro DEBUG definida
34 pr_debug -- apenas se macro DEBUG definida, ou com dynamic_debug
35
36 --
37
38 #include <linux/device.h>
39 dev_printk(level, device, fmt, ...);
40 dev_emerg(device, fmt, ...);
41 dev_alert
42 dev_crit
43 dev_err
44 dev_warn
45 dev_notice
46 dev_info
47 dev_dbg -- apenas se macro DEBUG definida, ou com dynamic_debug
48
49 --
50
51 dynamic_debug - precisa de DEBUG_FS
52 ver em lib/Kconfig.debug e Documentation/dynamic-debug-howto.txt
53
54 --
55
56 Definição de DEBUG condicionada ao Kconfig.
57 drivers/usb/core/Kconfig
58 drivers/usb/core/Makefile
59
60 ifeq ($(CONFIG_USB_DEBUG),y)
61 EXTRA_CFLAGS += -DDEBUG
62 endif
63
64 Se aplica apenas ao makefile em que é definido.