linux kernel driver debug
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
e.g.
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.
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的更多相关文章
- 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 ...
- Fedora安装VirtualBox时出现错误Kernel driver not installed (rc=-1908)的解决办法
新建虚拟机后启动时出现如下错误: Kernel driver not installed (rc=-1908) The VirtualBox Linux kernel driver (vboxdrv) ...
- VirtualBox,Kernel driver not installed (rc=-1908)
http://hi.baidu.com/spt_form/item/316d6207b47b8ee03499020a VirtualBox,Kernel driver not installed (r ...
- 参考论坛:Mali kernel driver TX011-SW-99002-r5p1-00rel0 for firefly
最近手头有一块firefly_rk3288_reload的开发板,想实现在linux 下用openGL ES来做视频显示. 找到opengGL相关移植,参考论坛(http://bbs.t-firefl ...
- ubuntu中使用virtualbox遇到Kernel driver not installed (rc=-1908)错误
百度之后得到解决,再此做个笔记 错误提示 Kernel driver not installed (rc=-1908) The VirtualBox Linux kernel driver (vbox ...
- freeIPMI README && issue about OpenIPMI kernel driver
http://www.gnu.org/software/freeipmi/README FreeIPMI - Copyright (C) 2003-2013 FreeIPMI Core Team Fr ...
- Linux Kernel - Debug Guide (Linux内核调试指南 )
http://blog.csdn.net/blizmax6/article/details/6747601 linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级 ...
- Linux kernel AACRAID Driver Compat IOCTL 本地安全绕过漏洞
漏洞名称: Linux kernel AACRAID Driver Compat IOCTL 本地安全绕过漏洞 CNNVD编号: CNNVD-201311-390 发布时间: 2013-11-29 更 ...
- Linux kernel support docker storage driver aufs
How to make docker use aufs in CentOS 7? - Server Faulthttps://serverfault.com/questions/650208/how- ...
随机推荐
- zabbix-3.4.14源码安装
此次介绍一下,zabbix的源码安装,因为zabbix的依赖很多,所以源码安装有很多依赖需要安装 首先,下载zabbix源码包 wget https://nchc.dl.sourceforge.net ...
- Springboot解决资源文件404,503等特殊报错,无法访问
Springboot解决资源文件404,503等特殊报错 原文链接:https://www.cnblogs.com/blog5277/p/9324609.html 原文作者:博客园--曲高终和寡 ** ...
- JDK下载-安装-配置
1.JDK的下载 jdk1.8版本 下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-213 ...
- 雷林鹏分享:jQuery EasyUI 数据网格 - 列运算
jQuery EasyUI 数据网格 - 列运算 在本教程中,您将学习如何在可编辑的数据网格(datagrid)中包含一个运算的列.一个运算列通常包含一些从一个或多个其他列运算的值. 首先,创建一个可 ...
- [spring源码] 小白级别的源码解析ioc(二)
之前一篇,整体描述了一下 Spring的整体概况和 jar包的介绍. 现在开始进入具体的源码解析,从本篇开始,先介绍spring的ioc容器.之前也看过一些介绍spring源码的, 有的是只讲整体的接 ...
- Attempting to use uninitialized value
ckpt = tf.train.get_checkpoint_state(FLAGS.model) if ckpt: saver.restore(sess, tf.train.latest_check ...
- 显卡、GPU和CUDA简介
http://blog.csdn.net/wu_nan_nan/article/details/45603299 声明: 本文部分内容来自网络.由于知识有限,有错误的地方还请指正.本帖为自己学习过程的 ...
- Python—迭代器与生成器
迭代器与生成器 生成器(generator) 先来了解一下列表生成器: list = [i*2 for i in range(10)] print(list)>>>>[0, 2 ...
- Mac下安装Apache
没错,这一篇又是因为头头给我安排的任务得出来的总结. 本身Mac是有自带的Apache,但是对并发量有限制,这个可以在系统的配置参数里面看,所以本人决定重新安装一个,来,请按照下面的流程来走: 一.下 ...
- 在windows下安装nvm并管理nodejs版本
不得不说,nodejs的nvm工具跟python下的mkvirtualenv 工具很像.作为立志成为伪全栈的我来说,玩玩nodejs是必不可少的.nodejs 有很多种的安装方式,下面我用nvm的方式 ...