I am trying to use grep
to find all the callers of a particular C function.
E.g.:
void foo()
{
...
ret = my_bar()
}
For all occurrances of my_bar()
I want to print the corresponding function name from where my_bar()
is called.
I have tried (based on Regex (grep) for multi-line search needed)
grep -Pzo "(?s)^{\N*?.*?my_bar" *.c
using Perl regex, but this doesn't quite work as expected. It starts the match at the function before foo()
till my_bar()
Is this possible with grep/perl and regex, or will I have to use tools like cscope
?