documentation must mention pid provider caveat with respect to function pointers calls
State
10-Fix Delivered:Verified (Fix available in build)
Category:Subcategory
doc:dtrace
Keywords
Responsible Engineer
Paul Echeverri
Reported Against
Duplicate Of
Introduced In
Commit to Fix
s10u6_fcs
Fixed In
s10u6_fcs
Release Fixed
solaris_10u6
Related Bugs
Submit Date
6-December-2007
Last Update Date
24-February-2009
Description
The chapter about "pid Provider" in
http://docs.sun.com/app/docs/doc/817-6223/6mlkidlls?q=dtrace&a=view
suggests any function could in any case be probed with dtrace pid provider,
but unfortunately this is not the case:
http://www.opensolaris.org/jive/thread.jspa?messageID=182894&tstart=0
If the function to be probed contains code that uses function pointers to call some sub-function the pid provider may not be working anymore. Reason is that dtrace then (wrongly) assumes a jump table be inside the function which it can't handle.
% dtrace -xdebug -l -n 'pid3870::sge_mirror_process_event_list:return'
libdtrace DEBUG: typedef bufinfo_t added as id 32801
libdtrace DEBUG: typedef devinfo_t added as id 32804
libdtrace DEBUG: typedef fileinfo_t added as id 32810
libdtrace DEBUG: type struct cpuinfo added as id 32812
libdtrace DEBUG: typedef cpuinfo_t added as id 32823
libdtrace DEBUG: grabbed pid 3870
libdtrace DEBUG: /scratch4/rd141302/cluster/ts1/bin/sol-amd64/sge_qmaster stret 0 0 0 0
libdtrace DEBUG: creating probe pid3870:sge_qmaster:sge_mirror_process_event_list:return
libdtrace DEBUG: error at 0xf8b (assuming jump table) <-------- LOOK HERE -------------------
libdtrace DEBUG: /lib/amd64/ld.so.1 stret 0 0 0 0
libdtrace DEBUG: /lib/amd64/libdl.so.1 stret 0 0 0 0
libdtrace DEBUG: /lib/amd64/libsocket.so.1 stret 0 0 0 0
libdtrace DEBUG: /lib/amd64/libnsl.so.1 stret 0 0 0 0
libdtrace DEBUG: /lib/amd64/libm.so.2 stret 0 0 0 0
libdtrace DEBUG: /lib/amd64/libthread.so.1 stret 0 0 0 0
libdtrace DEBUG: /lib/amd64/libc.so.1 stret 0 0 0 0
libdtrace DEBUG: /scratch4/rd141302/cluster/ts1/lib/sol-amd64/libspoolc.so stret 0 0 0 0
libdtrace DEBUG: set context to pid3870::sge_mirror_process_event_list:return [0] prp=0 attr=[u/u/c] argc=0
libdtrace DEBUG: set label to
libdtrace DEBUG: set label to
ID PROVIDER MODULE FUNCTION NAME
dtrace: failed to match pid3870::sge_mirror_process_event_list:return: No probe matches description
the attached output of
# dis -F sge_mirror_process_event_list ./sge_mirror.o
contains an example where dtrace suspects a jump table at
> sge_mirror_process_event_list+0xdf: 41 ff e0 jmp *%r8
even though that was just a function pointer
Work Around
Two workarounds:
(1) explicictly place a probe on the addresses of the function entry/return
as explained in
http://www.opensolaris.org/jive/thread.jspa?messageID=182894&tstart=0
that way dtrace disassembly analysis is not needed anymore
(2) Do not use function pointers in functions that need to be probed
void f(func_ptr_t *fptr)
{
fptr();
}
or do code reconstructions like this
void f(func_ptr_t *fptr)
{
f_(fptr);
}
void f_(func_ptr_t *fptr)
{
fptr();
}
that way entry/return of function 'f' can still be probed, since the function pointer call is done by a sub-function