Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Grep-ing for a function name to see where it's being used returns a list of rows and row numbers. Is there a smart way of using grep and awk to get the name of the calling procedure instead?

Thanks

share|improve this question
    
What do you mean by name of the calling procedure? –  soandos Mar 22 '12 at 10:55
    
When you find the file with the name you are looking for and you open it, you have to scroll up to find the procedure that calls it. I am using vi so the option of an IDE isn't a choice. –  Andreas Mar 22 '12 at 10:56
    
I mean, for example, you are looking for instances of a function called "foo()" in all files in a tree. The calling procedure/function would be the function that uses foo(), or that has foo() as part of its definition. –  Andreas Mar 22 '12 at 10:57
    
The aim of this is after finding the line that the function call appears in, to find the context in which it's being used. –  Andreas Mar 22 '12 at 11:05
    

1 Answer 1

For jumping to the definition of an identifier: Exuberant Ctags

http://ctags.sourceforge.net/

For finding uses of an identifier: GNU ID-Utils (mkid indexer, lid query command)

http://www.gnu.org/software/idutils/

share|improve this answer
    
ctags also has hotkey support in vim at least (and I'm sure other editors) to quickly jump to function definitions while coding. –  mikebabcock May 30 '12 at 16:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.