[ANN] cdepend - function call mapping of C projects

E

Eli Billauer

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
 
I

Ivan Vecerina

| 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
 
E

Eli Billauer

Ivan Vecerina said:
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
 
I

Ivan Vecerina

Hi Eli,
Eli Billauer said:
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
 
A

Alexander Leidinger

On 1 Nov 2003 03:56:00 -0800
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.
 
E

Eli Billauer

Ivan Vecerina said:
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
 
E

Ed Morton

Eli said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top