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. 力扣(LeetCode)482. 密钥格式化

    给定一个密钥字符串S,只包含字母,数字以及 '-'(破折号).N 个 '-' 将字符串分成了 N+1 组.给定一个数字 K,重新格式化字符串,除了第一个分组以外,每个分组要包含 K 个字##符,第一个 ...

  2. linux存储管理之磁盘阵列

    磁盘阵列 RAID ====================================================================================RAID:廉 ...

  3. 在 .NET项目中使用 Redis(2018.10.16)

    1. 打开NuGet管理器搜索redis,安装:“StackExchange.Redis” 2. 配置 Web.config 文件 <connectionStrings> <add ...

  4. Python ORM框架之SQLAlchemy

    前言: Django的ORM虽然强大,但是毕竟局限在Django,而SQLAlchemy是Python中的ORM框架: SQLAlchemy的作用是:类/对象--->SQL语句--->通过 ...

  5. Guava:好用的java类库 学习小记

    基础功能 google guava中定义的String操作 在google guava中为字符串操作提供了很大的便利,有老牌的判断字符串是否为空字符串或者为null,用指定字符填充字符串,以及拆分合并 ...

  6. Linux .vimrc 设置项

    Linux 下,.vimrc 有两个.一个是全局使用的(/etc/vimrc),另一个是个人使用的(~/.vimrc). 大部分的情况下,我们只需要设置自己目录下的.vimrc 即可. # vim ~ ...

  7. bsxfun.h multiple threads backup

    https://code.google.com/p/deep-learning-faces/source/browse/trunk/cuda_ut/include/bsxfun.h?r=7&s ...

  8. cerebro 配置

    cerebro 是 elastic search 的 监控平台 # Authentication auth = { type: ldap settings: { url = "ldap:// ...

  9. springCloud配置本地配中心SpringCloudConfig

    多环境配置 在一般开发过程中如果调试都在本地进行,则可以设置一个多环境配置,在本地与线上配置间来回切换. springcloud默认会访问的配置文件名是application.properties, ...

  10. 【转载】在线yml与properties文件转换工具

    http://www.toyaml.com/index.html