Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Static Code Analysis Tools?

Reply
Thread Tools

Static Code Analysis Tools?

 
 
Eric Schwartz
Guest
Posts: n/a
 
      12-16-2004
I was searching through CPAN today for a module that would generate a
static call tree, but couldn't seem to find one (lots of dynamic call
tree generators, though!). I'm less concerned with code coverage at
this point; I'm looking for a module (or tool) that will help me
refactor code by easily showing me who calls, say, MyMod::Foo.

Does anyone know of such a thing?

-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
 
Reply With Quote
 
 
 
 
Eric Schwartz
Guest
Posts: n/a
 
      12-16-2004
(Randal L. Schwartz) writes:
>>>>>> "Eric" == Eric Schwartz <> writes:

> Eric> I was searching through CPAN today for a module that would generate a
> Eric> static call tree, but couldn't seem to find one (lots of dynamic call
> Eric> tree generators, though!). I'm less concerned with code coverage at
> Eric> this point; I'm looking for a module (or tool) that will help me
> Eric> refactor code by easily showing me who calls, say, MyMod::Foo.
>
> Eric> Does anyone know of such a thing?
>
> Does B::Xref fit?


I think it can be made to-- thanks! It looks like it's intended to be
run on a program, and recursively descend down its call-tree, yes?
Which isn't a problem, I think-- if I have a sub in a module that
doesn't appear after running that code over all my executables, then
clearly that sub can be moved anywhere (or preferably, deleted).

-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
 
Reply With Quote
 
 
 
 
Michele Ouellet
Guest
Posts: n/a
 
      12-17-2004
> Which isn't a problem, I think-- if I have a sub in a module that
> doesn't appear after running that code over all my executables, then
> clearly that sub can be moved anywhere (or preferably, deleted).


Well, it is not quite clear to me. Of course, I have not looked at B::Xref
but it seems to me that if the sub does not appear, it can mean one of two
things:

* it is dead wood:
OR
* it is invoked based on some combination of conditions which were just not
exercised during your test.

Am I missing something?

Michèle.


 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      12-17-2004


Eric Schwartz wrote:

> I was searching through CPAN today for a module that would generate a
> static call tree, but couldn't seem to find one (lots of dynamic call
> tree generators, though!). I'm less concerned with code coverage at
> this point; I'm looking for a module (or tool) that will help me
> refactor code by easily showing me who calls, say, MyMod::Foo.
>
> Does anyone know of such a thing?


Beacuse Perl is not strongly typed it is impossible for static analysis
to resolve method calls.

It's also not possible for static analysis to resolve subroutine calls
through symrefs, run-time aliases or eval().

But subject to those limitations Perl does, as others have pointed out,
come with a static cross-reference tool.

 
Reply With Quote
 
Eric Schwartz
Guest
Posts: n/a
 
      12-17-2004
Brian McCauley <> writes:
> Beacuse Perl is not strongly typed it is impossible for static
> analysis to resolve method calls.


That's okay; I'll consider myself successful if I can get everybody to
stick to our coding standards, never mind teaching them OOP.

> It's also not possible for static analysis to resolve subroutine calls
> through symrefs, run-time aliases or eval().


Also true. Thankfully, with the exception of dispatch tables, we have
officially deemed most of those Evil(tm)(c)(r).

-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      12-18-2004


Randal L. Schwartz wrote:

>>>>>>"Brian" == Brian McCauley <> writes:

>
>
> Brian> Beacuse Perl is not strongly typed
>
> Well, for some definitions of "strongly typed".


OK sorry for my sloppy teminiology. I, of course, meant that you cannot
in general know the type of an object at compile time.

> Some would loudly disagree with you, for example.


Such loud disagreements always remind me of a passage from "Surely
You're Joking Mr Feynman".

I was able to find this passage quoted on the net in the following
"Letter to Professor Feynman". It starts in the last paragraph of the
3rd page (which is numbered page 442).

http://www.thoughtsandvisions.com/feynlet.pdf

Read and enjoy!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Evaluating static analysis and Dynamic analysis tools for C/C++ ssubbarayan C Programming 5 11-03-2009 12:50 AM
Static Java Code Analysis kramer31 Java 3 02-21-2009 02:20 AM
A method of static code analysis Logan Lee C Programming 5 12-24-2007 01:57 PM
Static code analysis Jens Nordahl C++ 1 04-22-2004 09:59 PM
Static Code Analysis Tools Don C Programming 1 07-25-2003 05:28 PM



Advertisments