Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2008 22:25:10 +0100
From:      Marcus von Appen <mva@sysfault.org>
To:        freebsd-current@freebsd.org
Subject:   Re: BSD cflow available
Message-ID:  <20080117212510.GB1094@medusa.sysfault.org>
In-Reply-To: <20080117195348.GA67081@hoeg.nl>
References:  <20080117190011.GA1094@medusa.sysfault.org> <20080117195348.GA67081@hoeg.nl>

next in thread | previous in thread | raw e-mail | index | archive | help

--JP+T4n/bALQSJXh8
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On, Thu Jan 17, 2008, Ed Schouten wrote:

> Hello Marcus,
>=20
[...]
=20
> I just tried cgraph to see how it works, I've never used cflow before (I
> didn't even know it was part of POSIX). I don't know if this is required
> by the standards, but here it goes:
>=20
> When I create 2 C files:
>=20
> ~~~~~~~~~~~~~~~~~~
> a.c:
>=20
> void a(void)
> {
> 	b();
> }
> ~~~~~~~~~~~~~~~~~~
>=20
> ~~~~~~~~~~~~~~~~~~
> b.c:
>=20
> void b(void)
> {
> }
> ~~~~~~~~~~~~~~~~~~
>=20
> Two very simple C files with a function call that connects the objects
> together. When I run cgraph, I get this:
>=20
> | 1 a: void(), <a.c 1>
> | 2   b: <>
> | 1 b: void(), <b.c 1>
>=20
> Isn't the application supposed to resolve b as well? cflow looks like a
> useful utility. Hope to see it get integrated. :-)

No, it should not resolve b here. In contrast to the POSIX requirements
this implementation accepts multiple source code files at once in order
to ease the generation of multiple graphs at once. Technically those are
built one after each other, without knowing about the contents of the
previously parsed file.

The problem with your expectation lies within the nature of C code
itself (you surely know that): How should the parser know that b is the
correct function to be referenced by a()? It can't know and letting it
guess this can quickly lead to unwanted, wrong results in the parsing
and output tree. Imagine two static functions, both with the same name
in each C file. Or a.c is linked to a library, which also defines b()
and thus is not related to b.c itself.

As cflow - in my opinion - is a useful tool to get a better overview
about the control flow in (possibly unknown) source code, being "better
safe than sorry" would be the best way to go here, I think.

Your expectation however shows that both, the output for multiple
files, and the man pages should reflect that :-).

Regards
Marcus

--JP+T4n/bALQSJXh8
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (FreeBSD)

iEYEARECAAYFAkePx7YACgkQo/JpszXavhxXrwCgithreTAjZNCnrqWn3d+S/NpY
lbsAn3Wb4Mb6I/lv+Qy48TSy08clTqQ7
=N1hj
-----END PGP SIGNATURE-----

--JP+T4n/bALQSJXh8--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080117212510.GB1094>