Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [photran] How difficult is it to find dead code

Hello

 

You can use coverage analysis for this task.

 

Recompile your code with -fprofile-arcs -ftest-coverage flags (both compilation and linking steps) then run the program.

 

Than you can run “gcov filename.f90” for whatever source file you are interested in which will tell you the percentage of lines executed during the run. To see which lines are not executed you can view the filename.f90.gcov and the lines are marked with #######.  Ideally you will have a number of tests to exercise as much of the code as possible.

 

For more details and tutorial on LCOV which gives HTML browsable output read http://www.softeng.rl.ac.uk/media/uploads/publications/2010/06/RAL_TR_2009_019.pdf

 

Hope that helps

 

David

 

From: photran-bounces@xxxxxxxxxxx [mailto:photran-bounces@xxxxxxxxxxx] On Behalf Of Jack Scheible
Sent: 30 July 2013 20:51
To: photran@xxxxxxxxxxx
Subject: Re: [photran] How difficult is it to find dead code

 

 Well, you can recompile the code with the profile flag (-pg).  Then run the program.  It will create a file in the current directory called gmon.out.

Then, run "gprof progra," (whatever program executable you called in the first step).  Uncalled subroutines and functions will not appear in the call list at the top.

Finding dead code INSIDE subroutines and functions is a bit harder.

-Jack

----------------------------------------------------------------------

Message: 1
Date: Mon, 29 Jul 2013 10:12:04 -0700 (PDT)
From: Carl Slater <ce.slater@xxxxxxxxx>
To: "photran@xxxxxxxxxxx" <photran@xxxxxxxxxxx>
Subject: [photran] How difficult is it to find dead code
Message-ID:
<1375117924.87392.YahooMailNeo@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Content-Type: text/plain; charset="us-ascii"

Hmmm I was thinking ... I know dangerous.

You have a database of function definitions and function usages .... how hard is it to identify routines that are never used?

When you inherit a code worked on by multiple authors it is easy to have "dead code" that gets updated but never used.

Regards
Carl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://dev.eclipse.org/mailman/private/photran/attachments/20130729/0b7c9ad0/attachment.html>

------------------------------

_______________________________________________
photran mailing list
photran@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/photran


End of photran Digest, Vol 95, Issue 10
***************************************


Back to the top