I am wondering how I can effectively find the usages of a function/structure in the files using find & grep
combination.
For example, I have source code for git
on my machine. If you look at the commit.h
, you can see commit
structure is defined like,
struct commit {
struct object object;
void *util;
unsigned int indegree;
unsigned long date;
struct commit_list *parents;
struct tree *tree;
char *buffer;
};
I am interested to find out from where this structure is initialized and how are they initializing buffer. First I tried,
grep -rn "(struct commit)" .
This gave me a file which has this structure initialization. Now I need to find out where the buffer
variable which is a member of this structure is initialized.
grep -rn "buffer" .
returnes a lot of results and tough to find out where it is used.
So I am wondering, how do you find out the usages of a symbol effectively? I am not talking about what an IDE provides but with using standard linux tools like grep
and find
. How do you manage to hack into a big codebase and understand how it works?