Profiling with gcc

Profiling with gcc

Post by a.. » Sun, 19 Jun 1994 07:59:26



        I would appreciate explicit instructions
on how to get profiling to work under gcc/g++
on Linux, including version numbers for gcc,
libraries and kernel. I have read the faq and
tried numerous times to profile, but have never
achieved anything other than a program that
instantly seg-faults.

                Thanks,
                        Frederick Umminger

 
 
 

Profiling with gcc

Post by Topi Paavo » Mon, 20 Jun 1994 01:38:33




>    I would appreciate explicit instructions
> on how to get profiling to work under gcc/g++
> on Linux, including version numbers for gcc,
> libraries and kernel. I have read the faq and
> tried numerous times to profile, but have never
> achieved anything other than a program that
> instantly seg-faults.

The seg-faults are probably caused by a mismatch between the libraries.
I had the same problem and ftp'd the Slackware 1.2.0 libc.tgz (disk d5)
and extralib.tgz (d3) files (can't recall the version numbers right now,
sorry).  Everything works now.  Make sure that your kernel has been
compiled with CONFIG_PROFILE #defined.  Then do the following:

1. Compile your program using the "-pg" switch.  Use this switch for
   every file you want profiled, and link everything with -pg.
2. Run the program.  This creates the "gmon.out" file.
3. Do a "gprof <program>" and you get the flat profile and call graph
   listings.

There are some options for gprof but I don't know what they do.  hmm...
I wonder where the man pages could be found?  <off to search>

- tjp

 
 
 

Profiling with gcc

Post by Ta Ch » Thu, 23 Jun 1994 05:49:16


: sorry).  Everything works now.  Make sure that your kernel has been
: compiled with CONFIG_PROFILE #defined.  Then do the following:

: 1. Compile your program using the "-pg" switch.  Use this switch for
:    every file you want profiled, and link everything with -pg.
: 2. Run the program.  This creates the "gmon.out" file.
: 3. Do a "gprof <program>" and you get the flat profile and call graph
:    listings.

: There are some options for gprof but I don't know what they do.  hmm...
: I wonder where the man pages could be found?  <off to search>

: - tjp

I did exactly as what you said above except that I am not sure whether
my kernel was compiled with CONFIG_PROFILE #defined. All the running
time is attributed to _entry

% time  seconds   cumsec   calls  function
100.00     4.24     4.24          _entry

All others are just 0's.

Is this because my kernel was not compiled with CONFIG_PROFILE
#defined ?

-tchen

 
 
 

Profiling with gcc

Post by Topi Paavo » Thu, 23 Jun 1994 20:06:08




> % time  seconds   cumsec   calls  function
> 100.00     4.24     4.24          _entry

> All others are just 0's.

> Is this because my kernel was not compiled with CONFIG_PROFILE
> #defined ?

Uh... I'll leave this one to the experts, but I guess you'd
better try recompiling the kernel, just to be sure.

- tjp

 
 
 

1. Profiling with gcc

In my quest to port Duke Nukem 3D to FreeBSD, I'm trying to profile
the program to see what's making it so low, as suggested on the
3drealms forum.  I add -pg to CFLAGS and LDFLAGS, and when it gets to
the linking stage, it dies like this:

gcc -o build -g -pg -L/usr/local/lib -Wl,-rpath,/usr/local/lib \
    -lSDL-1.1 -pthread build.o bstub.o engine.o cache1d.o \
    sdl_driver.o unix_compat.o a.o pragmas.o
/usr/local/lib/libaa.so.1: undefined reference to `longjmp'
/usr/local/lib/libaa.so.1: undefined reference to `setjmp'
/usr/X11R6/lib/libX11.so.6: undefined reference to `getgid'
/usr/local/lib/libaa.so.1: undefined reference to `random'
/usr/local/lib/libesd.so.2: undefined reference to `connect'
[snip about 50 more similar lines]

If I take the -pg out, it compiles fine again.  After googling, I
thought I might be missing the profiling libraries, so I set NOPROFILE
to false in /etc/make.conf and did a full installworld and kernel
(4.8-R).  But I still get the same error above.  I looked in /usr/lib,
and I do have a bunch of lib*_p.a files, like libc_p.a.  They're all
dated from the day I originally installed this system, so it doesn't
look like my installworld installed them, but they do exist.

Anyone know what I'm missing here?

Thanks,
--
Aaron

2. Linux for my PPC ?

3. Profiling with gcc on solaris x86

4. Kernel 1.1.42 fixes serial bug!

5. profiling with gcc ???

6. root path

7. Profiling with GCC-2, and Solaris 2.3 (No Proworks)

8. Compiling for Unix Versions

9. Linker/Profile error GCC 2.6.3

10. GCC and profiling

11. GCC-2.95 configuration & profile.

12. gcc 2.95.3 + profiling + s8 = link errors

13. gcc-2.5.8, solaris 2.3, threads, and profiling