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

Nick Alcock nick.alcock at oracle.com
Wed Oct 25 11:46:13 UTC 2023


On 25 Oct 2023, Kris Van Hees via DTrace-devel said:

> 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).

I am kicking myself.

> 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);

I am quite surprised that this is all that is needed, but of course this
serves to unify all the actually-identical probes at different addresses
but the same actual offset :)

Assuming the tests pass (which they should!)

Reviewed-by: Nick Alcock <nick.alcock at oracle.com>

-- 
NULL && (void)



More information about the DTrace-devel mailing list