I''m trying to profile the time spent in libc functions in a large build
job (building Perl), and I have trouble getting ufunc and func working. (func()
is not strictly needed; I was just hoping to use it in order to profile idle
time.)
Here''s the story. I''ve written a dtrace script to start a
separate dtrace process for each invoked command:
int fileid;
proc:::exec-success
/pid == $target || progenyof($target)/
{
self->traceme = 1;
@proc[execname] = count();
}
/* This should fire AFTER libc has been dloaded. */
syscall::setcontext:entry
/self->traceme/
{
self->traceme = 0;
stop();
system("dtrace -q -s /export/home/dds/src/dtrace/libc.d -o
/export/home/
dds/src/dtrace/data/%07d-%d.out %d &", ++fileid, pid, pid);
}
and a script for actually profiling user and kernel functions:
BEGIN {
system("prun %d", $1);
}
/*
* The process we were launched to watch is terminating.
* We should also exit, because our work is done.
*/
proc:::exit
/pid == $1/
{
printf("\nCommand: %s\n", execname);
exit(0);
}
profile-997Hz
/arg1 != NULL && pid == $1/
{
@u[ufunc(arg1)] = count();
}
profile-997Hz
/arg2 != NULL/
{
@k[func(arg2)] = count();
}
END
{
printf("\nUser functions\n");
trunc(@u, 100);
printa(@u);
printf("\nKernel functions\n");
trunc(@k, 20);
printa(@k);
}
However, when I profile a run using these scripts, all I get is hexadecimal
addresses:
User functions
0xd2ef4caa 10
0xd2ef4c78 20
0xd2ef4c8a 20
0xd2ef4c9c 20
Kernel functions
0x92269c 1
0x929ee2 1
0x931610 1
[...]
I''ve been able to obtain user function addresses by specifying a
command directly in the command line. For example,
dtrace -n profile-937Hz''/arg1 != NULL/{@u[ufunc(arg1)] =
count()}'' -c ~/bin/run-stcmp
gives me:
libc.so.1`strcmp 140
However, I''ve never suceeded in obtaining kernel function names.
Running
dtrace -n profile-1234Hz''/arg2 != NULL/{@k[func(arg2)] =
count()}END{trunc(@k, 10);printa(@k);}''
gives me:
0x9fbf4c 1
0xa6fc19 1
0xaabb59 1
0xabb648 1
So my questions are:
- What is needed for ufunc() to work? I would think that even when dtrace
attaches to a pid, it could get the process''s namelist through
/proc/$pid/path/a.out.
- Why isn''t func() working? Do I need a specific / custom kernel
build? I''m runnning snv_50 i86pc.
This message posted from opensolaris.org