views:

132

answers:

5

I am looking for a command line utility on *nix, that can dump the names of all the functions, classes etc. defined in a file(C/C++/Java)

+5  A: 

ctags can give you that (and much more). It is included with most Linux distributions...
http://ctags.sourceforge.net/whatis.html

Gilad Naor
i know about ctags, but it generates its tags file, which then is needed to be imported to an editor e.g. vim. I was asking for a simple utility, that just prints the function names on console, if ctags does that I am not sure
Anonymous
then you want `ctags -x`, which prints a human readable summary of stuff.
TokenMacGuy
Also `ctags -f -` prints the output to stdout, and not a tag file. You can then use `awk` or something similar...
Gilad Naor
A: 

It is not clear which language you refer to: if:

  • complied elf file then you have readelf utility providing that you compiled file with debug information "-g"
Gadolin
This won't work for C++, due to name-mangling...
Gilad Naor
@Gilad Naor - But you can then use c++filt to demangle them
Michael Anderson
A: 

Not sure if it would be useful for your exact purpose, but take a look at GCC-XML

Antonio Perez
A: 

You can try Doxygen http://www.stack.nl/~dimitri/doxygen/

Anand Kumar
A: 

You might also want to take a look at cscope which is similar to ctags suggested in the accepted answer. It creates its own symbol database. It provides a nice interface for you, enabling search of a given symbol/inclusion/file/declaration within your project.

codaddict