PROFIL(2) BSD Programmer's Manual PROFIL(2)
p
\bpr
\bro
\bof
\bfi
\bil
\bl - control process profiling
S
\bSY
\bYN
\bNO
\bOP
\bPS
\bSI
\bIS
\bS
p
\bpr
\bro
\bof
\bfi
\bil
\bl(_
\bc_
\bh_
\ba_
\br _
\b*_
\bs_
\ba_
\bm_
\bp_
\bl_
\be_
\bs, _
\bi_
\bn_
\bt _
\bs_
\bi_
\bz_
\be, _
\bi_
\bn_
\bt _
\bo_
\bf_
\bf_
\bs_
\be_
\bt, _
\bi_
\bn_
\bt _
\bs_
\bc_
\ba_
\bl_
\be);
D
\bDE
\bES
\bSC
\bCR
\bRI
\bIP
\bPT
\bTI
\bIO
\bON
\bN
The p
\bpr
\bro
\bof
\bfi
\bil
\bl() function enables or disables program counter profiling of
the current process. If profiling is enabled, then at every clock tick,
the kernel updates an appropriate count in the _
\bs_
\ba_
\bm_
\bp_
\bl_
\be_
\bs buffer.
The buffer _
\bs_
\ba_
\bm_
\bp_
\bl_
\be_
\bs contains _
\bs_
\bi_
\bz_
\be bytes and is divided into a series of
16-bit bins. Each bin counts the number of times the program counter was
in a particular address range in the process when a clock tick occurred
while profiling was enabled. For a given program counter address, the
number of the corresponding bin is given by the relation:
[(pc - offset) / 2] * scale / 65536
The _
\bo_
\bf_
\bf_
\bs_
\be_
\bt parameter is the lowest address at which the kernel takes pro-
gram counter samples. The _
\bs_
\bc_
\ba_
\bl_
\be parameter ranges from 1 to 65536 and can
be used to change the span of the bins. A scale of 65536 maps each bin
to 2 bytes of address range; a scale of 32768 gives 4 bytes, 16384 gives
8 bytes and so on. Intermediate values provide approximate intermediate
ranges. A _
\bs_
\bc_
\ba_
\bl_
\be value of 0 disables profiling.
R
\bRE
\bET
\bTU
\bUR
\bRN
\bN V
\bVA
\bAL
\bLU
\bUE
\bES
\bS
If the _
\bs_
\bc_
\ba_
\bl_
\be value is nonzero and the buffer _
\bs_
\ba_
\bm_
\bp_
\bl_
\be_
\bs contains an illegal
address, p
\bpr
\bro
\bof
\bfi
\bil
\bl() returns -1, profiling is terminated and _
\be_
\br_
\br_
\bn_
\bo is set
appropriately. Otherwise p
\bpr
\bro
\bof
\bfi
\bil
\bl() returns 0.
/usr/lib/gcrt0.o profiling C run-time startup file
gmon.out conventional name for profiling output file
The following error may be reported:
[EFAULT] The buffer _
\bs_
\ba_
\bm_
\bp_
\bl_
\be_
\bs contains an invalid address.
S
\bSE
\bEE
\bE A
\bAL
\bLS
\bSO
\bO
This routine should be named p
\bpr
\bro
\bof
\bfi
\bil
\ble
\be().
The _
\bs_
\ba_
\bm_
\bp_
\bl_
\be_
\bs argument should really be a vector of type _
\bu_
\bn_
\bs_
\bi_
\bg_
\bn_
\be_
\bd _
\bs_
\bh_
\bo_
\br_
\bt.
The format of the gmon.out file is undocumented.