Subject: Profiling broken in current?
To: None <current-users@netbsd.org>
From: Anders Hjalmarsson <hjalmar@hjalmar.to>
List: current-users
Date: 01/08/2006 02:11:40
Linking with -pg seems to be broken in current, probably since the move to
sharing files between libc and libkern.

mcount.c is now wrapped in
#if defined(GPROF) && !defined(_STANDALONE)
but GPROF seems not to be defined when compiling it.

Adding
CPPFLAGS.mcount.c+= -DGPROF
to gmon/Makefile.inc seems to fix the linking problem.

Unfortunately something is still wrong with profiling after that fix


When running gprof I get something like this:
Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    
  0.00      0.00     0.00     1000     0.00     0.00  __ieee754_sqrt


So the number of calls are ok, but no time accumulated.
I can reproduce this both on i386 and alpha, does anyone else see this ?

-hjalmar



Example:
Compiling a simple program with -pg (on 386):

cc -static -pg -o t t.c
/var/tmp//cco6YQsz.o(.text+0x7): In function `main':
: undefined reference to `__mcount'
/usr/lib/libc_p.a(getuid.po)(.text+0x4): In function `getuid':
: undefined reference to `__mcount'
/usr/lib/libc_p.a(getgid.po)(.text+0x4): In function `getgid':
: undefined reference to `__mcount'
/usr/lib/libc_p.a(setitimer.po)(.text+0xc): In function `setitimer':
: undefined reference to `__mcount'
/usr/lib/libc_p.a(profil.po)(.text+0xc): In function `profil':
: undefined reference to `__mcount'
/usr/lib/libc_p.a(warn.po)(.text+0x7): more undefined references to `__mcount' follow

Running size on the object files for libc:
size *mcount.*o
   text    data     bss     dec     hex filename
      0       0       0       0       0 mcount.o
      0       0       0       0       0 mcount.po
      0       0       0       0       0 mcount.so