Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!teknowledge-vaxc!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Execution profiling - CODE COVERAGE Message-ID: <327@quintus.UUCP> Date: 30 Aug 88 04:40:05 GMT References: <1988Aug28.150742.17805@gpu.utcs.toronto.edu> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Distribution: na Organization: Quintus Computer Systems, Inc. Lines: 23 > From: mdr@reed.UUCP (Mike Rutenberg) > I'm interested in finding a code coverage tool which > will let me know (ideally in terms of C constructs, > but assembler is fine) what portions of my program > has not been executed during a run. Does anyone know > of such beasts (ideally running under unix)? Many versions of UNIX have a tool called "tcov". For example, to analyse a program "fred.c", do cc -a fred.c # produces a.out and fred.d a.out # tcov fred.c # reads fred.c, fred.d, writes fred.tcov The "fred.tcov" file is a listing of the source files named in the "tcov" command, with each basic block preceded by a count of the number of times it was executed. Unexecuted basic blocks are preceded by "#####". A basic block is just a straight-line chunk of code. You can get counts for each statement too. I find that it is a big help in debugging. Several people mentioned "prof". Unfortunately, "prof" only tells you about procedures, not basic blocks, so isn't much use for finding out which parts of a program have been exercised, though System V comes with a marker macro you can use to break it down a bit.