Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Aug 2004 21:30:24 -0700 (PDT)
From:      "Jeremy C. Reed" <reed@reedmedia.net>
To:        freebsd-chat@freebsd.org
Subject:   Re: tool for listing C functions used in source code?
Message-ID:  <Pine.LNX.4.43.0408202115030.11735-100000@pilchuck.reedmedia.net>
In-Reply-To: <126eac48040820184330a9c344@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 20 Aug 2004, [UTF-8] Josh =C5=8Cckert wrote:

> > What are some good tools for searching source code that can list all th=
e
> > standard libc functions used?

> for i in `ls /usr/share/man/man3/ | sed -e '/\\\..*$/d'`; do echo $i;
> grep -c $i filename.c; done

Thank you for your ideas. Nevertheless, I am looking for a tool that
actually parses the code and follows includes like cflow, cscope or cxref
(which I still can't figure out yet).

Your idea implies that the function used is accurately documented. Also it
is missing a cut or sed to chop the  ".3" off the end. Also, your idea
could have many false positives due to matching partial function names.
Also, it could match on code that is never used (because of C processor
directives or in comments). By the time, I get a bunch of sed and grep to
help organize it, it would be easier to find a program that already does
it.

> man sed
> man grep

I know sed and grep. Along with awk, they are my good friends :)

Some things I have tried:

cflows (I also packaged it for pkgsrc.)

  cflow /usr/src/bin/ls/*.c | egrep '{}$' | cut -f 3

But the output is missing getopt and printf and probably others. Also it
shows functions that aren't shown in code (like clock(3)), but that is
probably okay since they must be called by a function in the code. (I'd
like it to tell me what functions are calling the other functions.) Any
suggestions with cflow?

I also tried cxref, like:

 cxref -xref-all -raw /usr/src/*bin/*/*c | grep ^Calls | grep -v ' : /'

It appears to do a good job. I still need to figure out how to get it to
do source that is in different directories while still outputting to one
"-raw" standard output. Any examples for doing that?

I also tried cscope, but I can't figure out how to get it to what I want.
I do not want something interactive. And I don't want to manually have to
run it numerous times to get my info.

Any other suggestions?

 Jeremy C. Reed

 =09  =09 =09 technical support & remote administration
=09  =09 =09 http://www.pugetsoundtechnology.com/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.43.0408202115030.11735-100000>