PROFIL(2) BSD Programmer's Manual PROFIL(2) NNAAMMEE pprrooffiill - control process profiling SSYYNNOOPPSSIISS _i_n_t pprrooffiill(_c_h_a_r _*_s_a_m_p_l_e_s, _i_n_t _s_i_z_e, _i_n_t _o_f_f_s_e_t, _i_n_t _s_c_a_l_e); DDEESSCCRRIIPPTTIIOONN The pprrooffiill() 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 _s_a_m_p_l_e_s buffer. The buffer _s_a_m_p_l_e_s contains _s_i_z_e 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 _o_f_f_s_e_t parameter is the lowest address at which the kernel takes pro- gram counter samples. The _s_c_a_l_e 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 _s_c_a_l_e value of 0 disables profiling. RREETTUURRNN VVAALLUUEESS If the _s_c_a_l_e value is nonzero and the buffer _s_a_m_p_l_e_s contains an illegal address, pprrooffiill() returns -1, profiling is terminated and _e_r_r_n_o is set appropriately. Otherwise pprrooffiill() returns 0. FFIILLEESS /usr/lib/gcrt0.o profiling C run-time startup file gmon.out conventional name for profiling output file EERRRROORRSS The following error may be reported: [EFAULT] The buffer _s_a_m_p_l_e_s contains an invalid address. SSEEEE AALLSSOO gprof(1) BBUUGGSS This routine should be named pprrooffiillee(). The _s_a_m_p_l_e_s argument should really be a vector of type _u_n_s_i_g_n_e_d _s_h_o_r_t. The format of the gmon.out file is undocumented. 4.4BSD June 4, 1993 1