内核uprobes使用介绍

本文介绍了内核中的uprobe事件追踪工具,它是kprobe的用户态版本,用于在用户空间代码中设置探针。内容包括uprobe的启用、命令格式、如何查看事件监控文件及设置和清除检测点的示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

简介

uprobe 事件tracer工具是在内核3.5开发期间何入内核主线版本的,虽然uprobe已经存在很久了。uprobe是和kprobe类似的调试方法。编译内核时通过打开CONFIG_UPROBE_EVENT=y来时能该特性。和kprobe类似,使用时不需要通过current_tracer来激活,而是检测点通过/sys/kernel/debug/tracing/uprobe_events设置,通过/sys/kernel/debug/tracing/events/uprobes/<EVENT>/enabled来使能。

然而,和kprobe不同的是,使用时需要用户自己计算探测点在用户态文件中的偏移,可以通过nm等工具,这还是有点麻烦的。

命令格式

  p[:[GRP/]EVENT] PATH:SYMBOL[+offs] [FETCHARGS]    : Set a probe

 GRP        : Group name. If omitted, use "uprobes" for it.
 EVENT        : Event name. If omitted, the event name is generated
          based on SYMBOL+offs.
 PATH        : path to an executable or a library.
 SYMBOL[+offs]    : Symbol+offset where the probe is inserted.

 FETCHARGS    : Arguments. Each probe can have up to 128 args.
  %REG        : Fetch register REG

查看事件监控文件

可以通过/s

BPF and related observability tools give software professionals unprecedented visibility into software, helping them analyze operating system and application performance, troubleshoot code, and strengthen security. BPF Performance Tools: Linux System and Application Observability is the industry’s most comprehensive guide to using these tools for observability. Brendan Gregg, author of the industry’s definitive guide to system performance, introduces powerful new methods and tools for doing analysis that leads to more robust, reliable, and safer code. This authoritative guide: Explores a wide spectrum of software and hardware targets Thoroughly covers open source BPF tools from the Linux Foundation iovisor project’s bcc and bpftrace repositories Summarizes performance engineering and kernel internals you need to understand Provides and discusses 150+ bpftrace tools, including 80 written specifically for this book: tools you can run as-is, without programming — or customize and develop further, using diverse interfaces and the bpftrace front-end You’ll learn how to use BPF (eBPF) tracing tools to analyze CPUs, memory, disks, file systems, networking, languages, applications, containers, hypervisors, security, and the Linux kernel. You’ll move from basic to advanced tools and techniques, producing new metrics, stack traces, custom latency histograms, and more. It’s like having a superpower: with Gregg’s guidance and tools, you can analyze virtually everything that impacts system performance, so you can improve virtually any Linux operating system or application.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值