[DTrace-devel] [PATCH 1/2] uprobes: name uprobes based on offset in inode rather than address

Kris Van Hees kris.van.hees at oracle.com
Wed Oct 25 03:51:35 UTC 2023


When PIC code is used, USDT probes (using uprobes) can appear at different
addresses for distinct instances of the same ELF object because the base
address is not fixed.  As a result, uprobes were being created using names
that were not stable.  Since (dev, inode, offset) is a unique triplet for
any uprobe, use that instead of (dev, inode, address).

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 libcommon/uprobes.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libcommon/uprobes.c b/libcommon/uprobes.c
index cf82882c..3bb423fc 100644
--- a/libcommon/uprobes.c
+++ b/libcommon/uprobes.c
@@ -307,6 +307,7 @@ uprobe_create_from_addr(ps_prochandle *P, uint64_t addr, int is_enabled,
 	if (!spec)
 		return NULL;
 
+	addr -= mapp.pr_file->first_segment->pr_vaddr;
 	name = uprobe_create_named(mapp.pr_dev, mapp.pr_inum, addr, spec, 0,
 				   is_enabled, prv, mod, fun, prb);
 	free(spec);
-- 
2.40.1




More information about the DTrace-devel mailing list