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- ...
随机推荐
- js没有函数重载
上面这道题,要求判断输出的y和z分别为什么 一开始,我选择了2,4 后来发现答案是4,4 意识到js中没有函数重载!!!即使声明了两个同名函数,结果也是后面的函数覆盖了前一个函数. 而且函数声明会提升 ...
- 《Visual C# 从入门到精通》第三章使用判断语句——读书笔记
第3章 使用判断语句 3.1 使用布尔操作符 布尔操作符是求值为true或false的操作符. C#提供了几个非常有用的布尔操作符,其中最简单的是NOT(求反)操作符,它用感叹号(!)表示.!操作符求 ...
- (20)gevent协程
协程: 也叫纤程,协程是线程的一种实现,指的是一条线程能够在多任务之间来回切换的一 种实现,对于CPU.操作系统来说,协程并不存在 任务之间的切换会花费时间.目前电脑配置一般线程开到200会阻塞卡顿 ...
- RabbitMQ(5)FanoutExchange
Fanout 就是我们熟悉的广播模式或者订阅模式,给Fanout交换机发送消息,绑定了这个交换机的所有队列都收到这个消息. 生产者工程: package com.example.demo.rabbit ...
- Linux出现wrong ELF class: ELFCLASS64
安装软件时出现问题 ×.so.×:wrong ELF class: ELFCLASS64 ,大致的意思是软件是32位的,需要32位的 ×.so.×动态链接库,而系统是64位的所提供的该 动态链接库 ...
- 在table表格中实现圆角效果
在table中设置border-radius发现不起作用,网上查找了一番,原因是border-collapse:collapse和border-radius不兼容. 设计图效果 代码实现效果: < ...
- JavaScript基础四
1.13 Js中的面向对象 1.13.1 创建对象的几种常用方式 1.使用Object或对象字面量创建对象 2.工厂模式创建对象 3.构造函数模式创建对象 4.原型模式创建对象 1.使用Object或 ...
- 页面检测网络外网连接- 网页基础模块(JavaScript)
方法一 html 添加图片标签 加载外站图片 <img id="connect-test" style="display:none;" onload=&q ...
- 基于c#的windows基础设计(学习日记2)【关于多态】
这次的多态很简单,没什么知识点 . 直接贴代码了: public abstract class Animal //建立一个抽象类 { private bool m_sex; private strin ...
- 枚举Enum 的常用方法
一.枚举介绍 通常定义常量方法和枚举定义常量方法区别 public class State { public static final int ON = 1; public static final ...