zoukankan      html  css  js  c++  java
  • linux内核常用函数或宏

    1. simple_strtoul

        用于将字符串转换为无符号长整数,第3个参数10意味着转换方式是10进制。

      ival = simple_strtoul(buffer, NULL, 10);

    2. 大部分体系结构把BUG()和BUG_ON()定义成某种非法操作,这样自然会产生需要的oops

    #ifndef HAVE_ARCH_BUG
    #define BUG() do { 
        printk("BUG: failure at %s:%d/%s()!
    ", __FILE__, __LINE__, __func__); 
        panic("BUG!"); 
    } while (0)
    #endif
    
    #ifndef HAVE_ARCH_BUG_ON
    #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
    #endif

    定义在include/asm-generic/bug.h中,在条件不满足时输出oops。需要linux 内核开启General setup->Configure standard kernel features->BUG() support。

    有些时候,你只是需要在终端上打印一下栈的回溯信息来帮助你测试。此时可以使用dump_stack()。它只在终端上打印寄存器上下文和函数的跟踪线索:

    if (!debug_check) {
           printk(KERN_DEBUG "provide some information.../n");
           dump_stack();
    }
  • 相关阅读:
    ubuntu install ssh server
    blug聚会&&小资早餐
    virtual box share folder usage
    关于xrdp的安装设置
    使用scp传送文件
    firefox插件集锦
    原来ubuntu早有关机功能
    blug聚会&&小资早餐
    加域工具
    ubuntu安装virtual box在命令行
  • 原文地址:https://www.cnblogs.com/embedded-linux/p/6538973.html
Copyright © 2011-2022 走看看