No subject
Prashanth Kumar
pra_udupi at yahoo.co.in
Tue Nov 12 04:06:13 UTC 2013
Hello,
I had been doing some work on the pid provider in Dtrace.I have made a few modification
so that it will list all the functions used in the program as seen in Solaris or MacOSX.
Presently in FreeBSD, you have to name each functions you have to probe in the program. For
example "dtrace -n 'pid$target:program::entry' -c ./program" will list all the functions called
in the program.This modification was made in libproc library(proc_sym.c).
Also while creating probe points for return probe type, any function with more than one return
path will fail.This is because "fasttrap_probe_spec_t" type variable is not fully copied into the
kernel in fasttrap_ioctl() function.I have modified in line with Solaris code where the copying is
done manually by Dtrace, rather than the kernel.(fasttap.c, fasttrap.h)
Also in "fasttrap_pid_probe()" (fasttrap_isa.c) for the case of "FASTTRAP_T_PUSHL_EBP", the ebp register
has to be copied to the stack not esp.
I had attached the patch files for review.
One other issue i noticed is that if the program being traced uses Thread Local Storage than
for the case of entry probe, it will hang in ___tls_get_addr function in ld-elf.so.
If you use scanf or fscanf in your program you can notice this behaviour. This i believe is due to
Dtrace using gs segment register to point to the scratch space, and TLS also loading the thread variable
from gs register.
if you change the following code in fasttrap_isa.c
<code>
#ifdef __i386__
addr = USD_GETBASE(&curthread->td_pcb->pcb_gsd);
#else
addr = curthread->td_pcb->pcb_gsbase;
#endif
addr += sizeof (void *);
</code>
to
<code>
#ifdef __i386__
addr = USD_GETBASE(&curthread->td_pcb->pcb_gsd);
#else
addr = curthread->td_pcb->pcb_gsbase;
#endif
addr += sizeof (void *) * 3;
</code>
the Dtrace will not hang. I am not sure what is happening here and
whether this is the correct solution.
This changes were made in FreeBSD 9.2-386-RELEASE. I applied the above patches on
FreeBSD 10-BETA (with some manual work) and it was still working.
More information about the freebsd-dtrace
mailing list