chen@digital.sps.mot.com (Jinfu Chen) (09/13/90)
I'm looking for a tool to extract names of function call in C files. A typical use of it is to build a cross-reference list for function calls. For example, given source files of RN, I would like to find out which file the ngdata_init() call is defined (and optionally) used. Shell scripts (including perl) are welcome. -- Jinfu Chen (602)898-5338 Motorola, Inc. SPS Mesa, AZ ...uunet!motsps!digital!chen chen@digital.sps.mot.com CMS: RXFR30 at MESAVM ----------
klee@wsl.dec.com (Ken Lee) (09/13/90)
In article <4cc48e05.12c9a@digital.sps.mot.com>, chen@digital.sps.mot.com (Jinfu Chen) writes: |> I'm looking for a tool to extract names of function call in C files. A |> typical use of it is to build a cross-reference list for function calls. Check out the ctags and cxref programs, available on most UNIX systems. -- Ken Lee DEC Western Software Laboratory, Palo Alto, Calif. Internet: klee@wsl.dec.com uucp: uunet!decwrl!klee
daniel@terra.ucsc.edu (Daniel Edelson) (09/13/90)
In article <4cc48e05.12c9a@digital.sps.mot.com> chen@digital.sps.mot.com (Jinfu Chen) writes: >I'm looking for a tool to extract names of function call in C files. A >typical use of it is to build a cross-reference list for function calls. For >example, given source files of RN, I would like to find out which file the >ngdata_init() call is defined (and optionally) used. >-- >Jinfu Chen (602)898-5338 / chen@digital.sps.mot.com The easiest way might be to first compile the files and then use nm(1) to obtain the symbols defined in each module. Daniel Edelson ``Do you think we daniel@cis.ucsc.edu, or should test it before ...!sun!practic!peren!daniel we ship it?''
chen@digital.sps.mot.com (Jinfu Chen) (09/14/90)
Thanks for all the replies and postings to my question. Suggestions include using sed, grep, ctags, nm, and cxref. I find that cxref(1) comes with SYS V is exactly what I need and works very well. Anyone still using sed/grep/ctags/nm should give cxref a look. My only problem with cxref is rather Apollo specific. On Apollos, cxref is under Sys 5.3 environment but all my programs are developed under BSD 4.3 environment. Worst yet, cxref is stamped as sys5.3 for systype and runtype so even explicitly calling the program still put me into sys5.3 environment. The result is cxref (actually /usr/lib/xcpp) couldn't find BSD style include files, or complain about incorret system calling syntax. I did try using -I/bsd4.3/usr/include but still no luck. I wonder if anyone in Apollo land could give me some help? -- Jinfu Chen (602)898-5338 Motorola, Inc. SPS Mesa, AZ ...uunet!motsps!digital!chen chen@digital.sps.mot.com CMS: RXFR30 at MESAVM ----------
lee@sq.sq.com (Liam R. E. Quin) (09/17/90)
chen@digital.sps.mot.com (Jinfu Chen) writes: >I'm looking for a tool to extract names of function call in C files. A >typical use of it is to build a cross-reference list for function calls. For >example, given source files of RN, I would like to find out which file the >ngdata_init() call is defined (and optionally) used. > Here is cfind, which prints out the entire function. It assumes a lot about indenting styes, though. It's easy to hack it to print just the name... You could also look at "calls", a sort of cross-reference generating program, and at "cpr", which emboldens function names. Lee #! /bin/sh if [ "x$1" = "x" -o "x$2" = "x" ] then echo "Usage: $0 function file [file...]" 1>&2 exit 1 fi pat="$1" echo "Looking for $pat" 1>&2 shift for i do echo "$i:" 1>&2 ; cat "$i" | sed -n -e '/^[ ]*[a-zA-Z0-9]*[ ]*[*]*[ ]*'"$pat"'/,/^}/p' done #end disclaimer: I've not looked at cfind for several years! Lee -- Liam R. E. Quin, lee@sq.com, SoftQuad Inc., Toronto, +1 (416) 963-8337 [Granny weatherwax] was opposed to books on strict moral grounds, since she had heard that many of them were written by dead people and therefore it stod to reason reading them would be as bad as necromancy. [Equal Rites 118]
kcantrel@digi.lonestar.org (Keith Cantrell) (09/18/90)
In article <4cc48e05.12c9a@digital.sps.mot.com> chen@digital.sps.mot.com (Jinfu Chen) writes: >I'm looking for a tool to extract names of function call in C files. A >typical use of it is to build a cross-reference list for function calls. For >example, given source files of RN, I would like to find out which file the >ngdata_init() call is defined (and optionally) used. > >Shell scripts (including perl) are welcome. > >-- >Jinfu Chen (602)898-5338 >Motorola, Inc. SPS Mesa, AZ > ...uunet!motsps!digital!chen >chen@digital.sps.mot.com >CMS: RXFR30 at MESAVM >---------- There was a program posted a while back (as in server years ago) call 'id' that does an excellent job of exactly what you want. It was written by Greg McGary. At the bottom of a README file I found the following: -- Greg McGary -- P.O. Box 286 -- Lincoln, MA 01773 -- -- 9/15/87 -- -- Until the end of 1987, -- Consulting to Sun's East Coast Division: -- gmcgary@ecd.sun.com -- gmcgary@suneast.uu.net -- -- After that, probably consulting in Europe... so I am not sure what the current status of this program is. This program does have a copyright notice on it, so I don't just want to posted it unless someone can convince me that I want get into any trouble :-). Type at you later, Keith Cantrell ----------------------------------------------------------------------- Keith Cantrell Phones: hm: 214-492-1088 Apollo Computer wk: 214-519-2399 @ DSC A Subsidiary of Hewlett-Packard USMAIL: EMAIL: 2100 Sonata Ln kcantrel@digi.lonestar.org Carrollton TX 75007 or ...!uunet!digi!kcantrel -----------------------------------------------------------------------