At my last job (legacy FORTRAN 77 code), we had files of cross references that list what subroutines called other subroutines, in what files subroutines were defined, what common blocks held what variables, what subroutines included what common blocks, etc. These were then used by shell scripts that grepped the cross reference files and would tell you things about the design of the program.
I'm now at a new company (C++ code), and I've found ctags to replace some of that functionality. The one thing I miss the most is a command we called "who.calls" that lists what subroutines (I mean functions or methods, gotta get used to the OO-speak) call a given subroutine. For example, if the subroutine foo
calls the subroutine bar
:
>who.calls bar
foo
Any suggestions for how to do this without re-engineering the programming environment from my old company? I'm looking for a super regex or some other method that I can use at the command line, but I'm open to other methods that take some totally different approach to give me the same information. I basically want to discover a debug function stack without running the debugger.
You might want to consider using doxygen. It can produce web pages that show you the entire call tree and class structure, as well as pulling out properly formatted comments to document the classes and methods just like Javadocs do for java.
Another possibility is to start using an IDE. After 25 years of using vi (and then gvim) and ctags, I've recently joined the 21st century and started using Eclipse (I'm doing Java, but I've seen C++ plugins for Eclipse). As well as being able to do everything that tags can do, it can also take you to all the callers of the current method. And on top of that, it has a damn good interactive debugger built in.