Hi! > > > + size_t offset = (size_t) &test_profil, count = 0; > > > + int ret, i, data[8]; > > > + > > > + /* make data depend on runtime value, so gcc can't make assumptions */ > > > + memset(data, getpid(), sizeof(data)); > > > + > > > + /* reset for test looping */ > > > + profil_done = 0; > > > + > > > + /* profil_count in glibc calculates offset as > > > + * i = (pc - pc_offset - (void *) 0) / 2 > > > + * i = i * pc_scale / 65536 > > > + * set scale to 2*65536 to have 1:1 mapping for $pc */ > > > + ret = profil(buf, PROFIL_BUFSZ, offset, 2*65536); > > ^ ^ > > sizeof(buf) ? why 2* ? > > profil_count() formula divides by 2, I'm not sure why. > It doesn't make a big difference for test, but it made it easier when > comparing output from testcase with disassembled code.
Strange, looking into glibc sources to sysdeps/posix/profil.c /* Enable statistical profiling, writing samples of the PC into at most SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling is enabled, the system examines the user PC and increments SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero, disable profiling. Returns zero on success, -1 on error. */ but man page suggests that the formula is (PC - OFFSET) * SCALE / 65536 The glibc sources mentions POSIX.1 but recent enough POSIX does not seem to contain any reference to profil().... -- Cyril Hrubis chru...@suse.cz ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list