Uprobes: howto calculate the probe offset

Frank Ch. Eigler fche@redhat.com
Fri Jan 20 17:17:00 GMT 2006


prasanna wrote:

> [...for an executable...]
> 	/* calculate the offset for function foo() */
> 	uprobe.offset = uprobe.kp.addr & 0x00000fff;

> [...for a shared library...]
> 	uprobe.kp.addr = (kprobe_opcode_t *) 0x4ecb1420;
> 	/*Calculate the offset */
> 	$cat /proc/1/mmaps
> [...]
> 	$4ec6f000-4ed93000 r-xp 00000000 08:02 1111959    /lib/tls/libc-2.3.4.so
> [...]
> 	$uprobe.offset  = [...]
> 			= 0x4ecb1420 -  0x4ec6f000;
> 			= 0x42420;

Could you explain why the uprobe.offset number is sometimes simply an
intra-page offset (which kprobes could compute), and sometimes a
mapping-relative one?

Also, given that it's possible to map a shared library at different
addresses within different processes, does the latter computation
imply that a uprobe only works for exactly those threads that have the
same shlib mapped at the same address?  What happens to other threads?


- FChE



More information about the Systemtap mailing list