新年第一天更博。这么勤劳我一定是小仙女`_>`

前几天调试时候,因为处理速度问题,师父给的建议是把应用中不重要的打印删掉。内核中也不要直接用printk,可以把想查看的数据通过debugfs来查看。

debugfs的用法和sysfs的用法相似。***在注册制好后,路径在/sys/kernel/debug路径下。


使用方法:

添加头文件<linux/debugfs.h>

1)注册debugfs:struct dentry* debugfs_create_dir(const char *name, struct dentry *parent);

         注册通常放在module_init加载的函数中。通过这一步的注册,在路径/sys/kernel/debug下面会出现我们注册的模块。

           name是创建的目录名字,parent是该目录的父目录。如果填NULL,则直接出现在debugfs的根目录。

         使用这种方法,可以创建subdir。

         需要注册全局变量static struct dentry *spi_429_debugfs;和全局的数字变量(最好注册到dev设备结构体中)。

2)因为要查看实际进中断次数,所以我注册的是数字接口的,数字的操作比较简单。通过函数:

  struct dentry *debugfs_create_u8(const char *name, mode_t mode, struct dentry *parent, u8 *value);
  struct dentry *debugfs_create_u16(const char *name, mode_t mode, struct dentry *parent, u16 *value);
  struct dentry *debugfs_create_u32(const char *name, mode_t mode, struct dentry *parent, u32 *value);
  struct dentry *debugfs_create_u64(const char *name, mode_t mode, struct dentry *parent, u64 *value);
  struct dentry *debugfs_create_bool(const char *name, mode_t mode, struct dentry *parent, u32 *value);
  struct dentry *debugfs_create_blob(const char *name, mode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob);
将要查看的数据注册。在使用的地方改变它的值,该值就可以在cd /sys/kernel/debug/myname cat *看到。

3)读数据

4)写数据

5)卸载模块:在module_exit注册的函数中,加入

  void debugfs_remove(struct dentry *dentry);即可

读数写数还没用,偷个懒

调试内核打印debugfs的更多相关文章

  1. 反汇编调试内核驱动 Oops提示【转】

    以下部分内容转自:https://blog.csdn.net/jiatingqiang/article/details/7481497 反汇编调试内核驱动 arm-none-linux-gnueabi ...

  2. linux内核打印数据到串口控制台,printk数据不打印问题

    linux内核打印数据到串口控制台问题 原文来源:http://i.cnblogs.com/EditPosts.aspx?opt=1 1.查看当前控制台的打印级别 cat /proc/sys/kern ...

  3. paip. 调试技术打印堆栈 uapi print stack java php python 总结.

    paip. 调试技术打印堆栈 uapi print stack java php python 总结. 作者Attilax  艾龙,  EMAIL:1466519819@qq.com 来源:attil ...

  4. linux内核打印"BUG: scheduling while atomic

    linux内核打印"BUG: scheduling while atomic"和"bad: scheduling from the idle thread"错误 ...

  5. xp+WinDBG+VMware调试内核

    呵呵,搞点突兀的标题而已.其实说的还是如何使用WinDBG和VMware来搭建调试内核的环境而已,这些网上已经有数不清的教程了,不过我喜欢自己亲手写一下.第一,把这个过程写一遍能加深印象,就算以后忘记 ...

  6. Linux内核分析-使用gdb跟踪调试内核从start_kernel到init进程启动

    姓名:江军 ID:fuchen1994 实验日期:2016.3.13 实验指导 使用实验楼的虚拟机打开shell cd LinuxKernel/ qemu -kernel linux-3.18.6/a ...

  7. linux内核打印级别

    1.printk()是一个内核的一个记录日志的机制,经常用来记录信息或者警告.printk可以指定输出日志的优先级,在include/linux/kern_levels.h中有相应的宏定义 #defi ...

  8. 【转】 C# DEBUG 调试信息打印及输出详解

    [转] C# DEBUG 调试信息打印及输出详解 1.debug只在[debug模式下才执行](运行按钮后面的下拉框可选) 2.debug提供了许多调试指令,如断言          System.D ...

  9. Android 中调试手段 打印函数调用栈信息

    下面来简单介绍下 android 中的一种调试方法. 在 android 的 app 开发与调试中,经常需要用到打 Log 的方式来查看函数调用点. 这里介绍一种方法来打印当前栈中的函数调用关系 St ...

随机推荐

  1. java中存储mysql数据库时间类型

    Mysql 与 java 的时间类型 MySql的时间类型有 Java中与之对应的时间类型   date                 java.sql.Date   Datetime        ...

  2. Linux SPI初始化及接口函数代码细究

    2012-01-08 22:11:38 目的:我需要掌握spi驱动相关数据结构关系,及在哪部分函数中把这些数值进行底层寄存器赋值的.结合应用层函数完成spi驱动的代码测试.已达到灵活修改的目的. 按顺 ...

  3. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'catchFromPBomService': Cannot create inner bean '(inner bean)#302efb82' of type [com.thinkgem.jeesite.modules.fd

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'catchFromPBo ...

  4. PHP环境配置遇到的小问题

    1.设置时区 2.默认打开文件 3.文件夹权限设置

  5. 用phantomjs进行web界面自动化测试的几个注意点

    貌似我以前说过不少界面自动化测试的坏话,哈哈.最近接触了phantomjs,发现用它进行web界面测试也挺有意思的,下面举几个我使用过程中发现的注意点. 1.需要指定phantomjs位置,否则使用时 ...

  6. Vue PC后台系统组件大全

    1.https://vue.ant.design/ 2.http://element-cn.eleme.io/#/zh-CN 3.https://www.iviewui.com/ 4.https:// ...

  7. Mac上超好用的计时器和秒表

    秒表 https://joaomoreno.github.io/thyme/ 计时器 https://github.com/michaelvillar/timer-app 更新---这个更棒!有网页有 ...

  8. No Directionality widget found.错误记录。

    import 'package:flutter/material.dart'; void main() => runApp(new Center(child: new Text('Hello, ...

  9. Python类元编程初探

    在<流畅的Python>一书中提到: Classes are first-class object in Python, so a function can be used to crea ...

  10. C# DataGridView 动态添加列和调整列顺序

    https://yq.aliyun.com/articles/421700 // DataGridView1的ColumnDisplayIndexChanged事件处理方法private void D ...