Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

code analysis graph

by mostart (Initiate)
on May 20, 2011 at 10:12 UTC ( #905898=perlquestion: print w/ replies, xml ) Need Help??
mostart has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I have a huge perl Code base (nice bunch of xmlrpc daemons).

Now since some of it became unmaintainable I'm looking around for some Analysis tools which are able to produce some nice graphs of call flows etc. I found some rather old posts on this suggesting tools like B::Xref and GraphViz which I tried but got only Segmentation faults. (perl -MO=Xref,-r

Is there any up to date tool for this ?

Thanks for any hint..

Comment on code analysis graph
Re: code analysis graph
by moritz (Cardinal) on May 20, 2011 at 11:25 UTC
Re: code analysis graph
by chrestomanci (Priest) on May 20, 2011 at 12:51 UTC

    Do you want to statically analyse a perl program without running it, and get a call graph for all possible flows of the program, or do you want to run the program normally under some sort of debug environment so that you get back a call graph for your test run?

    As moritz said, if you run a perl program under a profiler, then then you should be able to get a call graph from your profiling tool. The problem is that you only learn about the run you have just done, and not about any exceptional circumstances that you can't simulate. Also if your legacy code has bit rotted to the point where it won't run at all, and you can't easily fix it into a runnable state, then profiling it won't help you.

    Instead it is tempting to want to generate a call graph from static analysis of a perl program without running it. Unfortunately that is a lot harder, not least because (as you will frequency hear) Only perl can parse perl. The meaning of the saying is that only the perl binary (perl.exe) can reliably parse perl, and the only way it can do so is to run the perl program. You can attempt to write a separate parser for perl, but perl.exe is the only definitive perl parser, and the only one guaranteed to be correct. Additionally, if the perl program you are trying to analyse is broken or otherwise buggy, then it's meaning is undefined, so by definition there is no correct outcome to parsing it.

      thanks for your answers monks. NYTProf is a nice tool.
      But still I agree with you what I need is a static analysis without actually running the code.
      I tried B::Xref which caused segfaults only.
      Since compiler backend seems to be the most promising idea aren't there any other tools around ?
        If there are bugs in B::Xref or any other modules, 1) upgrade 2) report bugs

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://905898]
Approved by GrandFather
Front-paged by chrestomanci
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-08-20 23:03 GMT
Find Nodes?
    Voting Booth?

    The best computer themed movie is:

    Results (125 votes), past polls