Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!ncrlnk!ncr-sd!hp-sdd!hplabs!hpfcso!hpfcmgw!bobm From: bobm@hpfcmgw.HP.COM (Bob Montgomery) Newsgroups: comp.sys.hp Subject: Re: Problems with prof(1) and gprof(1) Message-ID: <1080089@hpfcmgw.HP.COM> Date: 17 Oct 89 17:32:31 GMT References: <364@node17.mecazh.UUCP> Organization: HP Fort Collins, CO Lines: 29 Re: profiling a number of C and Pascal programs with prof(1) and gprof(1) under HP-UX6.5 on a 9000/340. > main() > { > int i; > > monitor( (int (*)()) 2, (int (*)()) &etext, monbuf, MONBUFSZ, 20 ); > for (i = 0; i < 10; i++) foo_proc(); > monitor( (int (*)()) 0, (int (*)()) 0, 0, 0, 0 ); > exit( 0 ); > } > For prof, I compile as:- > cc -p -o foo foo.c > What am I (or someone else) doing wrong? > Paul Breslaw, Mecasoft SA Get rid of the calls to monitor. When you compile and link with -p, the C startup code from mcrt0.o sets up the buffers and calls monitor before calling main and then calls monitor again at exit. I suspect that your extra calls are causing a munged mon.out file which is confusing the prof command. Selective profiling by turning the profiler on and off is harder than this. Bob Montgomery