For any c application (let's say apache in this case) I want to return a list of all the methods and the file they are found in. For example, I want would to see something like:
int add (int a, int b)..... math.c
int subtract (int a, int b)..... math.c
int Multiply (int a, int b)..... math.c
int foo ()..... foo.c
I'd like to do this and avoid the hairy task of manually parsing the physical c files for method output. I know other languages have reflector.
Thanks all.
man nm(1)
But, the symbols source files are only available if the debugging information was compiled in (-g).
You did not specify the platform, so one possible solution is the 'ctags' program:
DESCRIPTION The ctags utility shall be provided on systems that support the User Portability Utilities option, the Software Development Utilities option, and either or both of the C-Language Development Utilities option and FORTRAN Development Utilities option. On other systems, it is optional.
The ctags utility shall write a tagsfile or an index of objects from C-language or FORTRAN source files specified by the pathname operands. The tagsfile shall list the locators of language-specific objects within the source files. A locator consists of a name, pathname, and either a search pattern or a line number that can be used in searching for the object definition. The objects that shall be recognized are specified in the EXTENDED DESCRIPTION section.
OPTIONS ... -x Produce a list of object names, the line number, and filename in which each is defined, as well as the text of that line, and write this to the standard output. A tagsfile shall not be created when -x is specified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With