Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!brutus.cs.uiuc.edu!apple!motcsd!hpda!hpcuhb!hpsqf!hpopd!andyc From: andyc@hpopd.HP.COM (Andrew Cunningham) Newsgroups: comp.sys.hp Subject: Re: Problems with prof(1) and gprof(1) Message-ID: <8490003@hpopd.HP.COM> Date: 17 Oct 89 12:28:41 GMT References: <364@node17.mecazh.UUCP> Organization: HP PWD, Pinewood UK. Lines: 82 / hpopd:comp.sys.hp / paul@mecazh.UUCP (Paul Breslaw) / 1:34 pm Oct 16, 1989 / >I have tried profiling a number of C and Pascal programs with prof(1) >and gprof(1) under HP-UX6.5 on a 9000/340. > >A simple example follows. The purpose of the meaningless loop in foo_proc >is to consume time so that profile(2) gets a look in. > >/******************************/ >/* foo.c */ > >#include >#include >#include > >#define MONBUFSZ 65536 > >extern etext; > >WORD monbuf[ MONBUFSZ ]; > >void foo_proc(); > >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 ); >} > > > >void foo_proc() >{ > int i, j; > > for (i = 0; i < 100000; i++) > j = i; >} > >/********************************************/ > > >For prof, I compile as:- > cc -p -o foo foo.c > >For gprof:- > cc -G -o foo foo.c > >Then both > prof foo >and > gprof foo >crash with a Floating exception. > >What am I (or someone else) doing wrong? When you compile with -G or -p, the calls to monitor are generated automatically. So, if you delete the two calls to monitor things will work fine. You can use thses calls manually to selectively profile your program; but I haven;t tried this. If you do cc -o foo foo.c foo you will find that mon.out (which is read by prof) is created (by the second monitor() call) without a -p option in sight. This still leads to a floating exception, so I would expect that you haven't got these calls quite right. Hope this helps...... --------------------------------------------------------------------------------- DISCLAIMER: I am not speaking as an employee of Hewlett-Packard. Andrew Cunningham, HP Software Engineering Systems Division, Pinewood E-mail: andyc@hpopd.HP.COM hplabs!hpopd!andyc