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. mysql数据库连接出问题,提示超时 java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.解决办法

    mysql数据库连接出问题,提示超时,后来发现问题在于连接mysql数据库的jar包跟数据库版本不对应导致的,更换jar包一致就解决了.

  2. UGUI之导入图片之前自动设置图片打包的 tag

    之前一直在用的是NGUI,最近不知怎么突然兴趣来潮,想学习一下UGUI,毕竟,现在纵观Unity的市场,完全是UGUI的天下,NGUI已经渐渐退隐江湖,哈哈哈... 先来记录下,在图片资源导入到Uni ...

  3. Python自学:第二章 Python之禅

    >>print import <Python之禅>,提姆·彼得斯著 美胜于丑. 显式优于隐式. 简单胜于复杂. 复杂总比复杂好. 平的比嵌套的好. 稀疏胜于稠密. 可读性计数. ...

  4. ranch 源码分析(三)

    接上ranch 源码分析(二) 上次讲到了ranch_conns_sup和ranch_acceptors_sup这2个ranch的核心模块,我们接着分析 首先查看ranch_conns_sup.erl ...

  5. attr VS prop 区别

    attr 能够增加.获取.删除页面属性.从页面中获取属性值: prop 用来获取.删除元素自带属性.从属性对象中获取属性值. attr 只获取静态属性值,就是页面加载时的最初的属性值: prop 可以 ...

  6. java虚拟机之虚拟机类加载机制

    此处主要需要知道什么是java虚拟机?java虚拟机如何进行类加载的? java语言本身是编译型和解释型的语言,先对本地的java文件进行编译,编译后会在本地生成一个class文件,而这个生成的cla ...

  7. 为什么会出现container、injection技术?发展历史及未来发展趋势

    container 原因: 随着软件开发的发展,相比于早期的集中式应用部署方式,现在的应用基本都是采用分布式的部署方式,一个应用可能包含多种服务或多个模块,因此多种服务可能部署在多种环境中,如虚拟服务 ...

  8. zabbix3.4.7远程命令例子详解

    zabbix可以通过远程发送执行命令或脚本来对部分的服务求故障进行修复 zabbix客户端配置 设置zabbix客户端用户的sudo权限 执行命令visudo: Defaults:zabbix !re ...

  9. linux软件管理 源码包

    源码包安装位置 安装在指定位置当中,一般是 /usr/local/软件名/ ​ 注意: 需要指定安装路劲为了便于卸载,因为源码包的是没有卸载命令的,它的的卸载方式就是把对应安装文件夹删除了. 所以如果 ...

  10. Python—列表操作

    列表 列表的使用: 列表是可变数据类型,因此列表的方法,都是直接修改列表原始值 list = ["panda","chimpanzee","zebra ...