<HTML>
<HEAD>
<TITLE>WHOUSES</TITLE>
<LINK REV="made" HREF="mailto:dsb@cleartool.com">
</HEAD>

<BODY>

<A NAME="__index__"></A>
<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#name">NAME</A></LI>
	<LI><A HREF="#motto">MOTTO</A></LI>
	<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
	<LI><A HREF="#description">DESCRIPTION</A></LI>
	<LI><A HREF="#.audit files">.AUDIT FILES</A></LI>
	<LI><A HREF="#classic code analysis compared">CLASSIC CODE ANALYSIS COMPARED</A></LI>
	<UL>

		<UL>

			<LI><A HREF="#minuses">MINUSES</A></LI>
			<LI><A HREF="#pluses">PLUSES</A></LI>
		</UL>

	</UL>

	<LI><A HREF="#author">AUTHOR</A></LI>
	<LI><A HREF="#copyright">COPYRIGHT</A></LI>
	<LI><A HREF="#status">STATUS</A></LI>
	<LI><A HREF="#porting">PORTING</A></LI>
	<LI><A HREF="#see also">SEE ALSO</A></LI>
</UL>
<!-- INDEX END -->

<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>whouses - impact analysis in a clearmake build environment</P>
<P>
<HR>
<H1><A NAME="motto">MOTTO</A></H1>
<P><EM>You give me a clean CR, I'll give you a clean impact analysis.</EM></P>
<P>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<P>Run this script with the <CODE>-help</CODE> option for usage details. Here are
some additional sample usages with explanations:</P>
<PRE>
  whouses foobar.h</PRE>
<P>Shows all DO's that make use of any file matching /foobar.h/.</P>
<PRE>
  whouses -recurse foobar.h</PRE>
<P>Same as above but follows the chain of derived files recursively.</P>
<PRE>
  whouses -exact /vobs_xyz/include/foobar.h</PRE>
<P>Shows all DO's that make use of the specified file (must be given as a
an absolute pathname).</P>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P><EM>Whouses</EM> provides a limited form of ``impact analysis'' in a clearmake
build environment. This is different from traditional impact analysis
(see <STRONG>CLASSIC CODE ANALYSIS COMPARED</STRONG> below for details) and in
particular operates at the granularity of files rather than language
elements.</P>
<P><EM>Whouses</EM> is best described by example. Imagine you have a VOB
'/vobs_sw' in which you build the incredibly simple application <EM>foo</EM>
from <EM>foo.c</EM>.  You have a Makefile which compiles <EM>foo.c</EM> to <EM>foo.o</EM>
and then links it to produce <EM>foo</EM>. And let's further assume you've
just done a build using clearmake.</P>
<P>Now, <EM>foo</EM> is a DO which has a config record (``CR'') showing how it was
made. <EM>Whouses</EM> analyzes that CR and prints the data in easy-to-read
indented format.  For instance:</P>
<PRE>
        % whouses -cr foo foo.c
        /vobs_sw/src/foo.c  =&gt;
          /vobs_sw/src/foo.o</PRE>
<P>The ``-cr foo'' points to the derived object from which to extract and
analyze the CR; it will be implicit in the remaining examples.  The
output indicates that <EM>foo.o <STRONG>uses</STRONG> foo.c</EM>, or in other words that
<EM>foo.c</EM> is a contributor to <EM>foo.o</EM>. If we add the <EM>-recurse</EM> flag:</P>
<PRE>
        % whouses -r foo.c
        /vobs_sw/src/foo.c =&gt;
          /vobs_sw/src/foo.o
            /vobs_sw/src/foo</PRE>
<P>We see all files to which <EM>foo.c</EM> contributes, indented according to
how many generations removed they are. If we now add <EM>-terminals</EM></P>
<PRE>
        % whouses -r -t foo.c
        /vobs_sw/src/foo.c =&gt;
          /vobs_sw/src/foo</PRE>
<P>Intermediate targets such as <EM>foo.o</EM> are suppressed so we see only the
``final'' targets descended from <EM>foo.c</EM>.</P>
<P>We can also go in the other direction using <EM>-backwards</EM>:</P>
<PRE>
        % whouses -b -e foo
        /vobs_sw/src/foo &lt;=
          /vobs_sw/src/foo.o</PRE>
<P>Which shows <EM>foo.o</EM> as a progenitor of <EM>foo</EM>. Note that the arrow
(<STRONG>&lt;=</STRONG>) is turned around to indicate <EM>-backwards</EM> mode. We also
introduced the <EM>-exact</EM> flag here. By default arguments to <EM>whouses</EM>
are treated as patterns, not file names, and since <EM>foo</EM> has no
extension it would have matched <EM>foo.c</EM> and <EM>foo.o</EM> as well. We can
combine recursion with backwards mode:</P>
<PRE>
        % whouses -b -e -r foo
        /vobs_sw/src/foo &lt;=
          /vobs_sw/src/foo.o
              /vobs_sw/src/foo.c
              /vobs_sw/src/foo.h
              /vobs_sw/src/bar.h</PRE>
<P>And discover that <EM>foo.h</EM> and <EM>bar.h</EM> were also used.</P>
<P>When used recursively in the forward direction, this script answers the
question ``if I change file X, which derived files will need to be
rebuilt''? This is the classic use, the one for which it was written.</P>
<P>Because extracting a recursive CR can be quite slow, <EM>whouses</EM>
provides ways of dumping the CR data to a file representation for
speed. Use of <EM>-save</EM>:</P>
<PRE>
        % whouses -cr foo -save ...</PRE>
<P>will write out the data to <EM>foo.crdb</EM>. Subsequently, if <EM>foo.crdb</EM>
exists and is newer than <EM>foo</EM> data will be taken from it rather
than re-generating the recursive <EM>catcr</EM> report. See also the <EM>-db</EM>
and <EM>-fmt</EM> flags.</P>
<P>The default save format is that of <EM>Data::Dumper</EM>. It was chosen
because it results in a nicely indented, human-readable text format
file. Provision is made for subclassing to alternate storage formats,
and subclasses for <EM>Storable</EM> and <EM>Data::Denter</EM> are provided as
examples. Although the <EM>Storable</EM> format may be somewhat faster than
the default, the real reason for the override capability is to allow an
actual, fast database to be used.</P>
<P>
<HR>
<H1><A NAME=".audit files">.AUDIT FILES</A></H1>
<P>Derived objects matching the Perl RE /\.AUDIT/i are ignored. These are
presumed to be ``meta-DO's'' by convention, which aren't part of the
build per se but rather pseudo-targets whose only purpose is to hold
CR's which refer back to all real deliverables.</P>
<P>
<HR>
<H1><A NAME="classic code analysis compared">CLASSIC CODE ANALYSIS COMPARED</A></H1>
<P><EM>Whouses</EM> can best be described by comparison with ``real'' impact
analysis products. There are a number of full-scale tools on the
market.  Typically, these work by parsing the source code into some
representation which they can then analyze. It's a powerful technique
but entails some tradeoffs:</P>
<P>
<H3><A NAME="minuses">MINUSES</A></H3>
<UL>
<LI>
A true code analysis tool must have knowledge of each programming
language in use. I.e. to add support for Java, a Java parser must be
added.
<P></P>
<LI>
A corollary of the above is that this tool requires lot of work
by expert programmers. Thus the tools tend to be large, complex
and expensive.
<P></P>
<LI>
Another corollary is that the tool must track each advance
in each language, usually with significant lag time.
<P></P>
<LI>
Also, since analysis basically entails compiling the code,
analysis of a large code base can take a long time,
potentially as long or longer than actually building it.
<P></P>
<LI>
If some part of your application is written in a language the tool
doesn't know (say Python or Visual Basic or Perl or an IDL), no
analysis of that area can take place.
<P></P></UL>
<P>
<H3><A NAME="pluses">PLUSES</A></H3>
<UL>
<LI>
The analysis can be as granular and as language-knowledgeable as its
developers can make it. If you change the signature of a C function, it
can tell you how many uses of that function, in what files and on what
lines, will need to change.
<P></P>
<LI>
A code analysis tool may be tied to a set of languages but by the same
token it's NOT tied to a particular SCM or build system.
<P></P></UL>
<P>The minuses above are not design flaws but inherent tradeoffs.  For
true code impact analysis you must buy one of these tools and accept
the costs.</P>
<P>Whouses doesn't attempt code analysis per se.  As noted above, true
code analysis programs are tied to language but not to an SCM system.
Whouses flips this around; it doesn't care about language but it only
works with build systems that use clearmake, which is part of
ClearCase.</P>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>David Boyce &lt;<A HREF="mailto:dsb@boyski.com">dsb@boyski.com</A>&gt;</P>
<P>
<HR>
<H1><A NAME="copyright">COPYRIGHT</A></H1>
<P>Copyright (c) 2000-2001 David Boyce. All rights reserved.  This Perl
program is free software; you may redistribute and/or modify it under
the same terms as Perl itself.</P>
<P>
<HR>
<H1><A NAME="status">STATUS</A></H1>
<P>This is currently ALPHA code and thus I reserve the right to change the
UI incompatibly. At some point I'll bump the version suitably and
remove this warning, which will constitute an (almost) ironclad promise
to leave the interface alone.</P>
<P>
<HR>
<H1><A NAME="porting">PORTING</A></H1>
<P>I've tried to write this in a platform independent style but it has not
been heavily tested on Windows (actually it hasn't been all that
heavily tested anywhere). It does pass ``make test'' on Windows and
appears to work fine in limited testing.</P>
<P>
<HR>
<H1><A NAME="see also">SEE ALSO</A></H1>
<P>perl(1), ClearCase::CRDB(3)</P>

</BODY>

</HTML>
