第 22 章 使用 perf 创建 uprobes

22.1. 在功能级别使用 perf 创建 uprobes

您可以使用 perf 工具在进程或应用程序的任意点处创建动态追踪点。然后,这些追踪点可以与其他 perf 工具(如 perf statperf 记录 )一起使用,以更好地理解进程或应用程序行为。

先决条件

  • 已安装 perf 用户空间工具,如安装 perf 所述。

流程

  1. 在对进程或应用程序感兴趣的位置监控的进程或应用程序中创建 uprobe:

    # perf probe -x /path/to/executable -a function
    Added new event:
      probe_executable:function   (on function in /path/to/executable)
    
    You can now use it in all perf tools, such as:
    
            perf record -e probe_executable:function -aR sleep 1