Discussion:
USDT probes
Rui Paulo
2010-08-10 15:46:51 UTC
Permalink
Hi,
I'm posting a question hoping someone will know the answer off hand thereby reducing my search time. :-)

With USDT probes, the tracepoint is only installed by libdtrace itself, never by the drti ioctl. So whenever I run a program with an USDT probe, no tracepoint is installed. Only after I run the dtrace command the tracepoint is actually installed on the victim process.

My question is about how Solaris discovers the correct instruction pointer (PC) on the target victim. The DOF only has information relative to the offset inside the function where the probe is defined and the address of the function in the _relocatable_ object.

So, whenever I'm building a program with an usdt probe I get:

libdtrace DEBUG: defined probe database:::query-start main() +0x13 (main)

When I run 'dtrace -n 'database*:::'' the fasttrap module inserts the probe at the 0x13 offset, not the actually vaddr of main() + offset. I added a debug printf in fasttrap_tracepoint_enable():

installing tracepoint on pid 1288 pc 0x13

Of course this doesn't work because main() is actually at 0x4011d0.

To overcome this I thought that dtrace(1) would try to grab the process and discover the vaddr of main. But from I can see dtrace(1) never grabs the process.

How does DTrace work for this case on Solaris? Where's the magic for installing the trap instruction at 0x4011d0 + 0x13 ?

Thanks,
--
Rui Paulo
Adam Leventhal
2010-08-10 18:29:29 UTC
Permalink
Hey Rui,

There are two relocations that take place. The provider.o file (generated by dtrace -G) contains relocations that are resolved with the final link pass occurs. We record the function offset (libdtrace) and then the linker adds in the base address of the function. The next relocation takes place when we ioctl(2) the DOF to the kernel. There, we provide the base address of the object.

tracepoint address = base address of object + function offset + offset into function
drti.o ld(1) dtrace -G / libdtrace

Adam
Post by Rui Paulo
Hi,
I'm posting a question hoping someone will know the answer off hand thereby reducing my search time. :-)
With USDT probes, the tracepoint is only installed by libdtrace itself, never by the drti ioctl. So whenever I run a program with an USDT probe, no tracepoint is installed. Only after I run the dtrace command the tracepoint is actually installed on the victim process.
My question is about how Solaris discovers the correct instruction pointer (PC) on the target victim. The DOF only has information relative to the offset inside the function where the probe is defined and the address of the function in the _relocatable_ object.
libdtrace DEBUG: defined probe database:::query-start main() +0x13 (main)
installing tracepoint on pid 1288 pc 0x13
Of course this doesn't work because main() is actually at 0x4011d0.
To overcome this I thought that dtrace(1) would try to grab the process and discover the vaddr of main. But from I can see dtrace(1) never grabs the process.
How does DTrace work for this case on Solaris? Where's the magic for installing the trap instruction at 0x4011d0 + 0x13 ?
Thanks,
--
Rui Paulo
_______________________________________________
dtrace-discuss mailing list
--
Adam Leventhal, Fishworks http://blogs.sun.com/ahl
Rui Paulo
2010-08-10 21:34:30 UTC
Permalink
Post by Adam Leventhal
Hey Rui,
There are two relocations that take place. The provider.o file (generated by dtrace -G) contains relocations that are resolved with the final link pass occurs. We record the function offset (libdtrace) and then the linker adds in the base address of the function. The next relocation takes place when we ioctl(2) the DOF to the kernel. There, we provide the base address of the object.
tracepoint address = base address of object + function offset + offset into function
drti.o ld(1) dtrace -G / libdtrace
Oh, apparently there was a problem with the base address of object. I'll try again.

Thanks,
--
Rui Paulo

Loading...