[DTrace-devel] [External] : [PATCH 4/7] usdt: place uprobes by file offset
Eslam Almorshdy via B4 Relay
devnull+ealmorshdy.d-matrix.ai at kernel.org
Thu Oct 15 03:53:44 UTC 2026
From: Eslam Almorshdy <ealmorshdy at d-matrix.ai>
dt_pid_create_usdt_probes_proc() converts each tracepoint address from
dtprobed to a uprobe offset by subtracting the load address of the
object's first segment. That gives the address's distance from the
first segment, not its file offset: the same mistake as in the pid
provider, with the same effect on lld-linked executables and libraries.
Every USDT and is-enabled probe is placed 0x1000 bytes past its site.
In a small object, that address lies outside any executable mapping, so
the probe never fires and is-enabled stays false; otherwise the probe
fires in other code or makes enabling fail for the whole process
(ENOTSUPP).
Convert through the mapping that contains the address instead.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Eslam Almorshdy <ealmorshdy at d-matrix.ai>
---
libdtrace/dt_pid.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/libdtrace/dt_pid.c b/libdtrace/dt_pid.c
index 582862e4..7741e6d9 100644
--- a/libdtrace/dt_pid.c
+++ b/libdtrace/dt_pid.c
@@ -1087,7 +1087,14 @@ dt_pid_create_usdt_probes_proc(dtrace_hdl_t *dtp, pid_t pid, dt_proc_t *dpr,
psp.pps_dev = pmp->pr_dev;
psp.pps_inum = pmp->pr_inum;
psp.pps_pid = dpr->dpr_pid;
- psp.pps_off = tp->tracepoint.addr - pmp->pr_file->first_segment->pr_vaddr;
+ /*
+ * uprobes are placed by file offset: convert through
+ * the mapping that contains the tracepoint. That need
+ * not be the first segment, and its p_vaddr - p_offset
+ * can differ from the first segment's (LLVM lld).
+ */
+ psp.pps_off = tp->tracepoint.addr - pmp->pr_vaddr +
+ pmp->pr_offset;
psp.pps_nameoff = 0;
if (nargv) {
--
2.55.0
More information about the DTrace-devel
mailing list