Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[ANN] cdepend - function call mapping of C projects

4 views
Skip to first unread message

Eli Billauer

unread,
Oct 30, 2003, 6:41:28 PM10/30/03
to
cdepend is a utility, which analyzes a project in C language. Its
output is a mapping of which C function calls which. cdepend works on
projects consisting of several source files.

cdepend makes a list of unused functions, and functions that are not
declared. For each function you also get a detailed report file,
saying where the function is called (file and row number). It's also
easy to get a picture of which library functions the project relies
on.

All this is accomplished by reading the assembly code, which gcc
creates when invoked with the -S flag. Hence, the entire project needs
to be recompiled to generate the necessary data for cdepend.

More about the project (and download):
http://www.billauer.co.il/cdepend.html

The current release is an early Alpha, and is expected to work on
recent i386-Linux distros.

The project is licensed under GPL.

Hope you like it,
Eli

Ivan Vecerina

unread,
Oct 31, 2003, 11:16:22 AM10/31/03
to
"Eli Billauer" <eli_bi...@users.sf.net> wrote in message
news:6bff2723.03103...@posting.google.com...

| cdepend is a utility, which analyzes a project in C language. Its
| output is a mapping of which C function calls which. cdepend works on
| projects consisting of several source files.
...

| All this is accomplished by reading the assembly code, which gcc
| creates when invoked with the -S flag. Hence, the entire project needs
| to be recompiled to generate the necessary data for cdepend.

Note:
There are some tools that provide similar information based on
the analysis of source code. IIRC, doxygen (www.doxygen.org)
can output a 'called-by' list in the documentation of each function.


Regards,
Ivan
--
http://ivan.vecerina.com


Eli Billauer

unread,
Nov 1, 2003, 6:56:00 AM11/1/03
to
"Ivan Vecerina" <NONE_use_form@website_to_contact_me> wrote in message

> Note:
> There are some tools that provide similar information based on
> the analysis of source code. IIRC, doxygen (www.doxygen.org)
> can output a 'called-by' list in the documentation of each function.
>

I wrote cdepend because I couldn't find a tool that does anything
similar. I did find several questions in newsgroups, where people
asked for such a tool, and were answered, more or less, that such tool
doesn't exist. For ten years.

Since I published cdepend, I'm repeatedly being told that there are
similar tools, usually without naming them. Are there indeed? I just
tried doxygen with EXTRACT_ALL=YES, but what I got was far from a
function call cross-reference. Did I miss some option in the config
file?

So if there's anyone out there who can put another tool on the table,
preferably with a demonstration of how it works, I think it'll be of a
vast benefit for everyone.

Just to focus on what we're talking about: You just encountered a
function in a large C project. You want to know who calls it (grep
isn't a solution). Or you want to get a list of functions that are
never used.

What existing tool will give you that?

Regards,
Eli

Ivan Vecerina

unread,
Nov 1, 2003, 8:28:36 AM11/1/03
to
Hi Eli,

"Eli Billauer" <eli_bi...@users.sf.net> wrote in message
news:6bff2723.03110...@posting.google.com...

> "Ivan Vecerina" <NONE_use_form@website_to_contact_me> wrote in message
>
> > Note:
> > There are some tools that provide similar information based on
> > the analysis of source code. IIRC, doxygen (www.doxygen.org)
> > can output a 'called-by' list in the documentation of each function.
>
> I wrote cdepend because I couldn't find a tool that does anything
> similar. I did find several questions in newsgroups, where people
> asked for such a tool, and were answered, more or less, that such tool
> doesn't exist. For ten years.

I did not say doxygen was a replacement for cdepend, but I do
believe that it can do something similar.

> Since I published cdepend, I'm repeatedly being told that there are
> similar tools, usually without naming them. Are there indeed? I just
> tried doxygen with EXTRACT_ALL=YES, but what I got was far from a
> function call cross-reference. Did I miss some option in the config
> file?

See: http://www.doxygen.org/config.html#cfg_referenced_by_relation
also: http://www.doxygen.org/config.html#cfg_call_graph
I do not have at hand public code documentation that uses these
features, but I have used it in former projects.
doxygen is actively supported by Dimitri (main author) and on
its mailing lists, do not hesitate to contact them if you
encounter any problem.

> So if there's anyone out there who can put another tool on the table,
> preferably with a demonstration of how it works, I think it'll be of a
> vast benefit for everyone.
>
> Just to focus on what we're talking about: You just encountered a
> function in a large C project. You want to know who calls it (grep
> isn't a solution). Or you want to get a list of functions that are
> never used.
>
> What existing tool will give you that?

For a list never-called functions, doxygen has no specific support
that I know of. (Not sure if the info is available in the xml output.
Processing another output formal may allow to extract the info).

Some commercial IDEs I've used provide interactive browsing to callers
of a function. In an IDE like Borland's, available breakpoint sites
are also highlighted, with unused functions (stripped at link time)
unavailable. Some linkers also can export an ASCII link map...


I only mentioned doxygen as a specific solution because it is
portable, and can do several other things as well by parsing
source code. It is a valuable free tool, to be put in the hands
of every developer.

The approach you implemented with cdepend also has merits.
But I thought that alternatives are always worth mentioning as a
reference (admittedly, a more in-depth comparison would be
of interest too).


Kind regards,
Ivan
--
http://ivan.vecerina.com


Alexander Leidinger

unread,
Nov 1, 2003, 10:32:10 AM11/1/03
to
On 1 Nov 2003 03:56:00 -0800
eli_bi...@users.sf.net (Eli Billauer) wrote:

> So if there's anyone out there who can put another tool on the table,
> preferably with a demonstration of how it works, I think it'll be of a
> vast benefit for everyone.

See below, an example walktrough is provided on the website.

> Just to focus on what we're talking about: You just encountered a
> function in a large C project. You want to know who calls it (grep
> isn't a solution). Or you want to get a list of functions that are
> never used.
>
> What existing tool will give you that?

http://www.spinellis.gr/cscout/

Bye,
Alexander.

--
http://www.Leidinger.net Alexander @ Leidinger.net
GPG fingerprint = C518 BC70 E67F 143F BE91 3365 79E2 9C60 B006 3FE7

Eli Billauer

unread,
Nov 2, 2003, 5:45:11 AM11/2/03
to
"Ivan Vecerina" <please_us...@ivan.vecerina.com> wrote in message

>
> I did not say doxygen was a replacement for cdepend, but I do
> believe that it can do something similar.
>

Indeed it does. I simply missed out the globals.html file. :(

"Similar" is probably the right word. Doxygen is more documentation
oriented, and gives (as far as I could see) less information about the
calling tree.

>
> But I thought that alternatives are always worth mentioning as a
> reference (admittedly, a more in-depth comparison would be
> of interest too).

By all means, yes. Especially as cdepend's developer, I would like to
know about any similar, open source utilities. And I think others
would be interested as well.

Is there any good listing of open-source tools for C somewhere?

Eli

Ed Morton

unread,
Nov 2, 2003, 10:20:12 AM11/2/03
to

Eli Billauer wrote:

> cdepend is a utility, which analyzes a project in C language. Its
> output is a mapping of which C function calls which. cdepend works on
> projects consisting of several source files.

Don't know if this is exaclty equivalent, but: "cscope" builds a symbol
database from a list of source files and provides a textual
(curses-based) interface where you can search code for:

# all references to a symbol
# global definitions
# functions called by a function
# functions calling a function
# text string
# regular expression pattern
# a file
# files including a file

Its GUI front-end "cbrowser" provides a hierarchical function call tree
plus other features.

cscope is at http://cscope.sourceforge.net/
cbrowser is at http://cbrowser.sourceforge.net/

There are other text-based tools that post-process the database that
cscope builds, e.g. "ccalls" (to print function call pairings) and "dt"
(to take those pairings and produce a function call hierarchy) but I
don't know of a free download for those. You can get ccalls at least for
a small charge from
http://www.bell-labs.com/project/wwexptools/paypackages.html

Regards,

Ed.

0 new messages