Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dylibprof(1) [opendarwin man page]

DYLIBPROF(1)						      General Commands Manual						      DYLIBPROF(1)

dylibprof - control the shared pc sampling of a dynamic shared library SYNOPSIS
dylibprof [-e | -d] | [-c | -r | -b | -h | -p [-o <file>] <dylib>] DESCRIPTION
Dylibprof along with the server /usr/libexec/profileServer allows shared program counter sampling of a dynamic shared library across all the programs that use the library. To use dylibprof(1), /usr/libexec/profileServer must be running. So first start /usr/libexec/profileServer and leave it running in the back ground: % /usr/libexec/profileServer >& /dev/console & /usr/libexec/profileServer starts up with shared pc sampling disabled. It should not be left running with shared pc sampling enabled if no sampling is being done as every launch of a program that uses the dynamic linker is effected. This is true even to a small extent if there no libraries being sampled. If you need to profile from boot up for all processes then the following line can be added to /etc/bootstrap.conf: server "/usr/libexec/profileServer" services NSProfileServer NSProfileControl; Before any dynamic shared library can be sampled sampling must be enabled as follows: % dylibprof -e It can then later be disabled when no more sampling is to be done with: % dylibprof -d EXAMPLE
To sample the dynamic shared library /System/Library/Frameworks/System.framework/Versions/B/System for example requires the following steps. First create a sample buffer for the library: % dylibprof -c /System/Library/Frameworks/System.framework/Versions/B/System Then begin the sampling: % dylibprof -b /System/Library/Frameworks/System.framework/Versions/B/System After this programs launched using this library will be part of the shared pc sampling. Typically what would be done is to then use the system normally for a number of hours. Then to halt the sampling: % dylibprof -h /System/Library/Frameworks/System.framework/Versions/B/System The profiling output file (a gmon.out file) can be created with: % dylibprof -p -o /tmp/gmon.out /System/Library/Frameworks/System.framework/Versions/B/System Using the profiling output file and the library a profile listing and a time based order file (time.order) can be created with: gprof(1): % gprof -S /System/Library/Frameworks/System.framework/Versions/B/System /tmp/gmon.out When no more sampling for this library is to be done the sample buffer can be removed with: % dylibprof -r /System/Library/Frameworks/System.framework/Versions/B/System The options are: -e Enable shared program counter sampling for dynamic libraries. -d Disable shared program counter sampling for dynamic libraries. -c Create a pc sample buffer for the library. -b Begin sampling for programs subsequently launched using the library. -h Halt sampling for programs subsequently launched using the library. -p Produce a profiling output file (a gmon.out file) for the library. -r Remove the pc sample buffer for the library. -o name Use the file name instead of gmon.out when producing the profiling output file with the -p above. FILES
gmon.out profile output file /var/tmp/profile/profile.XXXXXX the sample buffer file SEE ALSO
gprof(1) Apple Computer, Inc. March 19, 2002 DYLIBPROF(1)

Check Out this Related Man Page

monitor(3)						     Library Functions Manual							monitor(3)

       monitor, monstartup, moncontrol - prepare execution profile

       monitor(lowpc, highpc, buffer, bufsize, nfunc)
       int (*lowpc)(), (*highpc)();
       short buffer[];

       monstartup(lowpc, highpc)
       int (*lowpc)(), (*highpc)();


       These functions use the system call to control program-counter sampling.  Using the option -p when compiling or linking a program automati-
       cally generates calls to these functions.  You do need not to call these functions explicitly unless you want more control.

       Typically, you would call either or to initialize pc-sampling and enable it; call to disable or reenable it; and call at the end of  execu-
       tion to disable sampling and record the samples in a file.

       Your  initial  call  to	enables  pc-sampling.	The  parameters lowpc and highpc specify the range of addresses to be sampled.	The lowest
       address is that of lowpc and the highest is just below highpc.  The buffer parameter is the address of a (user allocated) array of  bufsize
       short  integers,  which	holds  a  record of the samples; for best results, the buffer should not be less than a few times smaller than the
       range of addresses sampled.  The nfunc parameter is ignored.

       The environment variable PROFDIR determines the name of the output file and whether pc-sampling takes place: if it is not set, the file	is
       named  mon.out;	if  set  to  the empty string, no pc-sampling occurs; if set to a non-empty string, the file is named string/pid.progname,
       where pid is the process id of the executing program and progname is the program's name as it appears in argv[0]. The  subdirectory  string
       must already exist.

       To profile the entire program, use the following:

	    extern eprol(), etext();
	    . . .
	    monitor(eprol, etext, buf, bufsize, 0);

       The  routine  lies just below the user program text, and lies just above it, as described in (Because the user program does not necessarily
       start at a low memory address, using a small number in place of is dangerous).

       The routine is an alternate form of that calls (see for you to allocate the buffer.

       The function selectively disables and re-enables pc-sampling within a program, allowing you to measure the cost of  particular  operations.
       The function disables pc-sampling, and reenables it.

       To stop execution monitoring and write the results in the output file, use the following:


       mon.out	     default name for output file
       libprof1.a    routines for pc-sampling

See Also
       cc(1), ld(1), profil(2), brk(2)

								       RISC								monitor(3)
Man Page