Discussion:
issue dtracing function return value in pid provider
Andrea Cucciarre'
2011-06-12 11:04:28 UTC
Permalink
Hello,

I need to use the pid provider to trace the inputs and return value of
the following function

calc_guest_util(rs_guest_util_t *gutil, int ncpu, int fcpu)
{
<snip>
return ((100.0 * (double)used_cycles) / (double)(total_cycles));
}

I can trace the input arguments with the following dscript (if there's a
quicker and cleaver dscript to do that please correct me):

#!/usr/sbin/dtrace -qs

typedef struct rs_guest_util {
uint64_t lifespan;
uint64_t wallclock_delta;
uint64_t active_delta;
uint64_t stopped_cycles;
uint64_t yielded_cycles;
} rs_guest_util_t;

pid$1::calc_guest_util:entry
{
self->guest=((rs_guest_util_t *)(copyin(arg0,sizeof(rs_guest_util_t))));
printf("arg0 %x\n",arg0);
printf("ncpu %d\n",arg1);
printf("fcup %d\n",arg2);
printf("active delta %d\n",self->guest->active_delta);
printf("stopped cycles %d\n",self->guest->stopped_cycles);
printf("yielded cycles %d\n",self->guest->yielded_cycles);
}

Then I added the following to trace the return value of the function

pid$1::calc_guest_util:return
{
printf("return %x\n",arg1);
}

But I get the following output:

arg0 ffbffb80
ncpu 8
fcup 0
active delta 583970560
stopped cycles 0
yielded cycles 4652066048
total cycles 4671764480
return ffbffb80

As you can see the return value is an address, actually the same address
as arg0 in entry.
I suspect I'm doing something wrong in dtrace but I can't realize
what....Could you please advice?

Regards
Andrea


/
/
Adam Leventhal
2011-06-12 17:28:15 UTC
Permalink
Hey Andrea,
As you can see the return value is an address, actually the same address as
arg0 in entry.
I suspect I'm doing something wrong in dtrace but I can't realize
what....Could you please advice?
The return type of calc_guest_util() was cut off, but I infer that
it's a double. DTrace doesn't have much by way of support for
floating-point values -- adding access to the floating-point registers
and support for manipulating floating-point datatypes have long been
RFEs for DTrace. I'd offer to add them to illumos, but I doubt that
would be of much help to users of Oracle Solaris.

Adam

On Sun, Jun 12, 2011 at 4:04 AM, Andrea Cucciarre'
Hello,
I need to use the pid provider to trace the inputs and return value of the
following function
calc_guest_util(rs_guest_util_t *gutil, int ncpu, int fcpu)
  {
   <snip>
   return ((100.0 * (double)used_cycles) / (double)(total_cycles));
  }
I can trace the input arguments with the following dscript (if there's a
#!/usr/sbin/dtrace -qs
typedef struct rs_guest_util {
        uint64_t        lifespan;
        uint64_t        wallclock_delta;
        uint64_t        active_delta;
        uint64_t        stopped_cycles;
        uint64_t        yielded_cycles;
 } rs_guest_util_t;
pid$1::calc_guest_util:entry
{
self->guest=((rs_guest_util_t *)(copyin(arg0,sizeof(rs_guest_util_t))));
printf("arg0 %x\n",arg0);
printf("ncpu %d\n",arg1);
printf("fcup %d\n",arg2);
printf("active delta %d\n",self->guest->active_delta);
printf("stopped cycles %d\n",self->guest->stopped_cycles);
printf("yielded cycles %d\n",self->guest->yielded_cycles);
}
Then I added the following to trace the return value of the function
pid$1::calc_guest_util:return
{
printf("return %x\n",arg1);
}
arg0 ffbffb80
ncpu 8
fcup 0
active delta 583970560
stopped cycles 0
yielded cycles 4652066048
total cycles 4671764480
return ffbffb80
As you can see the return value is an address, actually the same address as
arg0 in entry.
I suspect I'm doing something wrong in dtrace but I can't realize
what....Could you please advice?
Regards
Andrea
_______________________________________________
dtrace-discuss mailing list
--
Adam Leventhal, Delphix
http://dtrace.org/blogs/ahl

275 Middlefield Road, Suite 50
Menlo Park, CA 94025
http://www.delphix.com
Loading...