1. print

printk(): never

pr_debug(): always good

dev_dbg(): prefered when you have a struct device object

netdev_dbg(): prefered when you have a struct netdevice object

[something]_dbg(): prefered when you have a that something object

see the implementation in source code:

/* If you are writing a driver, please use dev_dbg instead */
#if defined(CONFIG_DYNAMIC_DEBUG)
/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
#define pr_debug(fmt, ...) \
dynamic_pr_debug(fmt, ##__VA_ARGS__)
#elif defined(DEBUG)
#define pr_debug(fmt, ...) \
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#else
#define pr_debug(fmt, ...) \
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#endif

It shows the CONFIG_DYNAMIC_DEBUG/DEBUG option can be used to enable or disable the print.

dynamic debug:

Benefits:
Almost no overhead when log code is not enabled.
Turn on/off debug log at runtime.
No need to recompile the kernel.

Control interface: uboot boot argus, debugfs

# mount -t debugfs none /sys/kernel/debug/
# cd /sys/kernel/debug/dynamic_debug/
# echo “file xxx.c +p” > control
# echo “file svcsock.c line 1603 +p” > control
# echo “file drivers/usb/core/* +p” > control
# echo “file xxx.c -p” > control

retrive the log information

dmesg

dmesg -C clear

dmesg -c show and then clear.

tail /var/log/syslog-f dynamic to show the log information in case the syslogd is running.

The debug log default size is 64K, you can configure it by menuconfig, note that the size is calculted by 2^n.

dmesg -n 5
Set console logging filter to KERN_WARNING or more severe.
dmesg -l warn
Only print the logs of KERN_WARNING in the kernel ring buffer.

Another option is dynamic debug by configuring the debugfs

enable it in kernel : CONFIG_DYNAMIC_DEBUG=y menuconfig

using pr_debug(), dev_dbg() ... in driver source code

echo “<matches> <ops><flags>” > <debugfs>/dynamic_debug/control

e.g.

echo “file xxx.c+p” > <debugfs>/dynamic_debug/control
 

2. using file system proc/ memory large file or sequence file

3. using ioctrl to get/set specific data

Below shall enable the kernel debug. CONFIG_DEBUG_INFO =y

4. gdb list command to idenfiy the line of oops

e.g.

(gdb ) list *(cppi41_dma_probe+0x2c4)
 

5. addr2line command to identify the line of oops

e.g.  addr2line -fe vmlinux ce000678

6. objdump -dS .o

-d: display assembler conetents of executable sections

-S intermix source code with disassembly

linux kernel driver debug的更多相关文章

  1. CentOS VirtualBox启动虚拟及报错:VirtualBox error: Kernel driver not installed (rc=1908)

    VirtualBox error: Kernel driver not installed (rc=1908) Hi all, Let me first say that this is my fin ...

  2. Fedora安装VirtualBox时出现错误Kernel driver not installed (rc=-1908)的解决办法

    新建虚拟机后启动时出现如下错误: Kernel driver not installed (rc=-1908) The VirtualBox Linux kernel driver (vboxdrv) ...

  3. VirtualBox,Kernel driver not installed (rc=-1908)

    http://hi.baidu.com/spt_form/item/316d6207b47b8ee03499020a VirtualBox,Kernel driver not installed (r ...

  4. 参考论坛:Mali kernel driver TX011-SW-99002-r5p1-00rel0 for firefly

    最近手头有一块firefly_rk3288_reload的开发板,想实现在linux 下用openGL ES来做视频显示. 找到opengGL相关移植,参考论坛(http://bbs.t-firefl ...

  5. ubuntu中使用virtualbox遇到Kernel driver not installed (rc=-1908)错误

    百度之后得到解决,再此做个笔记 错误提示 Kernel driver not installed (rc=-1908) The VirtualBox Linux kernel driver (vbox ...

  6. freeIPMI README && issue about OpenIPMI kernel driver

    http://www.gnu.org/software/freeipmi/README FreeIPMI - Copyright (C) 2003-2013 FreeIPMI Core Team Fr ...

  7. Linux Kernel - Debug Guide (Linux内核调试指南 )

    http://blog.csdn.net/blizmax6/article/details/6747601 linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级 ...

  8. Linux kernel AACRAID Driver Compat IOCTL 本地安全绕过漏洞

    漏洞名称: Linux kernel AACRAID Driver Compat IOCTL 本地安全绕过漏洞 CNNVD编号: CNNVD-201311-390 发布时间: 2013-11-29 更 ...

  9. Linux kernel support docker storage driver aufs

    How to make docker use aufs in CentOS 7? - Server Faulthttps://serverfault.com/questions/650208/how- ...

随机推荐

  1. abstract class和interface的异同

    含有abstract修饰符的class即为抽象类,abstract 类不能创建的实例对象.含有abstract方法的类必须定义为abstract class,abstract class类中的方法不必 ...

  2. Web版记账本开发记录(七)

    经过不懈的努力,虽然开发出来的还有瑕疵,但今后我会继续努力的.

  3. ThinkPHP5.0源码学习之注册错误和异常处理机制

    在base.php文件中,用一句代码\think\Error::register();实现错误和异常处理机制的注册. // 注册错误和异常处理机制 \think\Error::register(); ...

  4. python----常用模块(hashlib加密,Base64,json)

    一.hashlib模块 1.1 hashlib模块,主要用于加密相关的操作,在python3的版本里,代替了md5和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, S ...

  5. C++使用: C++中map的基本操作和用法

    在阅读SSD代码中发现作者使用了C++中的map方法,因此搜索该关联式容器的使用方法,在这里一并总结. 一.Map 簡介 Map是STL的一個容器,它提供一對一的hash. 第一個可以稱為關鍵字(ke ...

  6. mysql查询出相同数据出现的次数,统计相同值的数量

    1.可以使用count SELECT count(name='A' OR NULL) FROM table 2.用sum SELECT sum(if( = 'A', 1, 0)) FROM table ...

  7. TreeTagger

    大家都知道TreeTagger是一个用于词性标注和词型还原的工具,它的返回结果由三部分组成:目标词汇,词性,原形.那该工具是怎样判断目标词汇的词性的呢?又是怎样得到目标词汇的原形的呢?本文就是从这两个 ...

  8. 19_04_02校内训练[deadline]

    题意 给出一个二分图,左边为A集合,右边为B集合,要求把A集合中每一个点染为黑白两色中的一种,B集合中的颜色已定.染色后对于原本相邻且颜色相同的点,建立新的二分图,即得到了两个新的二分图,它们是独立的 ...

  9. webApp总结

    有关Meta 基本Meta <!-- 设置缩放 --> <meta name="viewport" content="width=device-widt ...

  10. HTTP的缓存策略

    etag 与 if-match https://www.cnblogs.com/huangzhilong/p/4999207.html https://juejin.im/post/5c136bd16 ...