linux内核探测工具

1. printk

printk函数的用法

References

2. systemtap

//脚本解析器
#!/usr/bin/stap -gv

/* 
 * 在函数末尾加上“.call”,表示函数被调用时probe
 * 在函数末尾加上“.return”,表示返回时probe
 */

//函数
probe kernel.function("kernel_function_name").return
{
    printf("kernel_function_name return %d.\n", $return);
}

probe kernel.function("build_open_flags").call {
    //打印rbp寄存器的值
    printf("rbp=%p\n", register("rbp"));
}

//模块函数
probe module("module_name").function("module_function_name").return
{
    printf("module_function_name return %d.\n", $return);
    
    //打印函数参数
    printf("module_function_name return(%s).\n", $$parm$);

    //打印变量
    printf("var = %d.\n", $var);

    //打印调用堆栈信息
    print_backtrace();
}

//函数名支持通配符
probe module("ext3").function("ext3_get*") 
{
     ... 
}

//通过条件符号,如果函数存在才生效:
kernel.function("may_not_exist") ? { ... }

References

systemtap源码: https://sourceware.org/systemtap/ftp/releases/
systemtap官方:https://sourceware.org/systemtap/wiki
systemtap官网自学教程:https://sourceware.org/systemtap/documentation.html
IBM编写的systemtap指南:http://www.redbooks.ibm.com/abstracts/redp4469.html
systemtap从入门到放弃(一) - 知乎
systemtap从入门到放弃(二) - 知乎

3. strace

References

4. ltrace

References

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值