systemtap - 如何使用 systemtap 从用户空间探测访问返回值

标签 systemtap

我想访问从 glibc 的“打开”函数返回的数据,例如文件名或文件描述符

我试试

probe process("/lib*/libc.so.*").function("open") { 
   fd = $fd
   filename = user_string($filename)
   printf("%d %d %s %s\n",pid(),ppid(),filename,fd)
}

但是报错

semantic error: unresolved target-symbol expression: identifier '$fd' at malloc.stp:3:10 source: fd = $fd ^

Pass 2: analysis failed. [man error::pass2]

最佳答案

open 系统调用没有fd 参数,因此.function 探测器自然找不到它。如果您想查看文件描述符 open 返回,然后探测.function("...").return 点, 和 $return

probe process("/lib*/libc.so.6").function("open").return {
    fd=$return
    path=user_string(@entry($filename))
    printf("open %s -> $d\n", path, fd)
}

关于systemtap - 如何使用 systemtap 从用户空间探测访问返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32945176/

相关文章:

linux - 查看其他应用程序创建的现有套接字上的套接字选项?

macos - 如何在Mac的docker的centos容器中使用systemtap(stap)

linux - systemtap:如何确定探测事件和参数

linux - 如何监控哪些文件消耗iops?

linux - 获取正在换出的页面的 pid

linux-kernel - kprobes中未定义异常处理程序(__und_svc)的作用是什么?

linux-kernel - 适用于Linux内核的utrace补丁

gcc - 如何在systemtap中检查用户空间函数的变量?

function - systemtap 用户空间函数跟踪